CentOS 6.9 & 7.4 RESET.sh (持續更新中)
阿新 • • 發佈:2018-12-15
#!/bin/bash ###################################### # 【指令碼說明】 # 指令碼檔名:CentOS 6.9 & 7.4 RESET.sh # 指令碼用途:初始化 CentOS 6.9 & 7.4 系統初始設定 ###################################### #------------------------------------------------------- # 全域性指令碼 #------------------------------------------------------- CENTOS_VERSION=`awk -F'.' '{print $1}' /etc/redhat-release | awk '{print $NF}' `; source /etc/rc.d/init.d/functions; #------------------------------------------------------- # 請務必先執行全域性指令碼! # 修改ssh配置檔案,使每一次遠端連線驗證減少等待時間 #------------------------------------------------------- cp /etc/ssh/sshd_config{,_bak}; sed -ri 's/(GSSAPIAuthentication )yes/\1no/' /etc/ssh/sshd_config; sed -ri 's/#(UseDNS ).*/\1no/' /etc/ssh/sshd_config; grep -e "GSSAPIAuthentication" -e "UseDNS" /etc/ssh/sshd_config; if [ $CENTOS_VERSION = 6 ]; then service sshd restart; elif [ $CENTOS_VERSION = 7 ]; then systemctl restart sshd; [ $? = 0 ] && action "Restarting sshd:" /bin/true; fi #------------------------------------------------------- # 請務必先執行全域性指令碼! # 修改yum倉庫配置檔案 #------------------------------------------------------- rm -vf /etc/yum.repos.d/*.repo; echo "[base]" >> /etc/yum.repos.d/base.repo; echo "name=CentOS `awk -F'release' '{print $2}' /etc/redhat-release | awk '{print $1}'` DVD" >> /etc/yum.repos.d/base.repo; echo "baseurl=file:///mnt" >> /etc/yum.repos.d/base.repo; echo "gpgcheck=0" >> /etc/yum.repos.d/base.repo; cat /etc/yum.repos.d/base.repo; yum clean all && yum repolist; #------------------------------------------------------- # 請務必先執行全域性指令碼! # 安裝自動掛載服務 #------------------------------------------------------- yum -y install autofs lrzsz tree; if [ $CENTOS_VERSION = 6 ]; then chkconfig autofs on; chkconfig --list autofs; service autofs start; elif [ $CENTOS_VERSION = 7 ]; then systemctl enable autofs; [ $? = 0 ] && action "Enabled autofs on startup:" /bin/true; systemctl start autofs; [ $? = 0 ] && action "Starting autofs:" /bin/true; fi #------------------------------------------------------- # 請務必先執行全域性指令碼! # 更新yum倉庫配置檔案 #------------------------------------------------------- sed -ri '
[email protected](baseurl=file://)/[email protected]\1/misc/[email protected]' /etc/yum.repos.d/base.repo; cat /etc/yum.repos.d/base.repo; umount /mnt; yum clean all && yum repolist; #------------------------------------------------------- # 請務必先執行全域性指令碼! #-------------------------------------------------------