编辑
2022-05-09
sh
00

目录

init

init

提示

适用于Rhel系列

sh
#!/bin/bash # #******************************************************************** #Author: zhangwei #QQ: 200957079 #Date: 2020-03-02 #FileName: disk-lvm.sh #URL: http://vanblog.ztunan.top #Description: The test script #Copyright (C): 2020 All rights reserved #******************************************************************** color () { RES_COL=60 MOVE_TO_COL="echo -en \\033[${RES_COL}G" SETCOLOR_SUCCESS="echo -en \\033[1;32m" SETCOLOR_FAILURE="echo -en \\033[1;31m" SETCOLOR_WARNING="echo -en \\033[1;33m" SETCOLOR_NORMAL="echo -en \E[0m" echo -n "$1" && $MOVE_TO_COL echo -n "[" if [ $2 = "success" -o $2 = "0" ] ;then ${SETCOLOR_SUCCESS} echo -n $" OK " elif [ $2 = "failure" -o $2 = "1" ] ;then ${SETCOLOR_FAILURE} echo -n $"FAILED" else ${SETCOLOR_WARNING} echo -n $"WARNING" fi ${SETCOLOR_NORMAL} echo -n "]" echo } #关闭SELinux disable_selinux () { sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config } #关闭防火墙 disable_firewall (){ systemctl disable --now firewalld color "防火墙已经关闭" 0 } #支持光盘,/misc/cd对应就是光盘内容 set_cdrom () { yum -y install autofs systemctl enable --now autofs } #配置yum 仓库 yum_config (){ mkdir /etc/yum.repos.d/backup mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/ cat > /etc/yum.repos.d/base.repo <<EOF [BaseOS] name=BaseOS baseurl=https://mirror.tuna.tsinghua.edu.cn/centos/8/BaseOS/x86_64/os/ https://mirrors.huaweicloud.com/centos/8/BaseOS/x86_64/os/ https://mirrors.cloud.tencent.com/centos/8/BaseOS/x86_64/os/ https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/ gpgcheck=0 [AppStream] name=AppStream baseurl=https://mirror.tuna.tsinghua.edu.cn/centos/8/AppStream/x86_64/os/ https://mirrors.huaweicloud.com/centos/8/AppStream/x86_64/os/ https://mirrors.cloud.tencent.com/centos/8/AppStream/x86_64/os/ https://mirrors.aliyun.com/centos/8/AppStream/x86_64/os/ gpgcheck=0 [epel] name=EPEL baseurl=https://mirror.tuna.tsinghua.edu.cn/epel/\$releasever/Everything/\$basearch https://mirrors.cloud.tencent.com/epel/\$releasever/Everything/\$basearch https://mirrors.huaweicloud.com/epel/\$releasever/Everything/\$basearch https://mirrors.aliyun.com/epel/\$releasever/Everything/\$basearch gpgcheck=0 enabled=1 [extras] name=extras baseurl=https://mirror.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/os https://mirrors.cloud.tencent.com/centos/\$releasever/extras/\$basearch/os https://mirrors.huaweicloud.com/centos/\$releasever/extras/\$basearch/os https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/os gpgcheck=0 enabled=1 [PowerTools] name=CentOS- - PowerTools - mirrors.aliyun.com baseurl=https://mirror.tuna.tsinghua.edu.cn/centos/\$releasever/PowerTools/\$basearch/os/ https://mirrors.cloud.tencent.com/centos/\$releasever/PowerTools/\$basearch/os/ https://mirrors.huaweicloud.com/centos/\$releasever/PowerTools/\$basearch/os/ https://mirrors.aliyun.com/centos/\$releasever/PowerTools/\$basearch/os/ gpgcheck=0 enabled=1 gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official EOF color "yum仓库配置成功" 0 } #修改网卡名称 config_network () { sed -ri '/GRUB_CMDLINE_LINUX=/s#(.*)"$#\1 net.ifnames=0"#' /etc/default/grub grub2-mkconfig -o /boot/grub2/grub.cfg } #最小化安装系统后,建议安装常用软件 install_packages () { yum -y install autofs vim-enhanced tcpdump autofs chrony lrzsz tree telnet ftp lftp redhat-lsb-core bash-completion net-tools postfix wget bzip2 zip unzip xz lsof mlocate man-pages rsync } set_env () { cat > /etc/profile.d/env.sh <<EOF PS1='\[\e[1;36m\][\u@\h \W]\\$\[\e[0m\]' export EDITOR=vim export HISTTIMEFORMAT="%F %T " EOF } #优化内核参数 set_kernel () { cat >> /etc/sysctl.conf <<EOF #inotify 事件队列最大长度,如值太小会出现 Event Queue Overflow 错误 fs.inotify.max_queued_events=66666 #可以监视的文件的总数量 fs.inotify.max_user_watches=100000 EOF } sysctl -p &>/dev/null disable_selinux disable_firewall set_cdrom yum_config config_network install_packages set_env set_kernel color "系统初始化已完成!" 0 sleep 2 reboot
如果对你有用的话,可以打赏哦
打赏
ali pay
wechat pay

本文作者:笑一个吧~

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 本文为博主「笑一个吧~」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 许可协议。转载请注明出处!