每次安装完系统都要进行这些配置,虽说装系统的次数不多,但是每次安装完成后都需要进行配置基本环境,而且每次配置都需要在网上查几次资料才能配置好对应的环境,就是因为使用次数少容易忘记配置,才需要上网查一下对应的配置,但下一次又会忘记了,所示编写成一个shell脚本,不管重装多少次系统,直接执行该脚本就能搞定了,这里的基本环境指的是刚安装好Centos7系统yum的镜像替换成国内的镜像源,关闭防火墙、关闭seLinux,该shell脚本只做了适配Centos7系统使用,执行完该脚本会重启系统
vi init_env
install_softwart() {
IS_INSTALLED=$(rpm -qa|grep wget)
if [ $? -ge 1 ]
then
echo "========= install basic software =================="
set -e
yum -y install wget
fi
}
install_softwart
echo "============= update yum =================="
set -e
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum clean all && yum makecache
systemctl disable --now firewalld
if [ $? -eq 0 ]
then
echo "============== firewalld close Successfully =================="
fi
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config && setenforce 0
echo "============== Restart The Computer Please reconnect later.... =================="
reboot
bash init_env