脚本内容如下
ls /etc/yum.repos.d/
echo ""
echo "############################"
read -p "clean yum,your answer(y|*):" ans
if [ "$ans" == "y" ];then
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/CentOS* /etc/yum.repos.d/bak/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
yum clean all
yum makecache
fi
echo ""
echo "############################"
if systemctl status firewalld &>/dev/null;then
systemctl stop firewalld &>/dev/null
systemctl disable firewalld &>/dev/null
else
echo "防火墙已关闭"
fi
echo ""
echo "############################"
read -p "check net device,if continue:" answ
if [ "$answ" == "y" ];then
if systemctl status NetworkManager &>/dev/null;then
systemctl stop `NetworkManager` &>/dev/null
systemctl disable NetworkManager &>/dev/null
else
echo "NetworkManager已关闭"
fi
fi
echo ""
echo "############################"
se_stat=`getenforce`
if [ "$se_stat" == "Enforcing" ];then
setenforce 0
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
else
echo "selinux状态为$se_stat"
fi
echo ""
echo "############################"
if ! which rsync &>/dev/null;then
yum install rsync -y
which rsync
fi
files_num=`ulimit -n`
if [ $files_num != 102400 ];then
echo "root soft nofile 102400" >>/etc/security/limits.conf
echo "root hard nofile 102400" >>/etc/security/limits.conf
else
echo "文件最大打开数为${files_num}"
fi
echo ""
echo "############################"
echo "-------check_http_proxy------"
echo "$http_proxy" "$https_proxy"
echo ""
echo "-----------------------------"
echo ""
echo "############################"
[ -d "/data" ] || mkdir /data && ls -ld /data/
echo ""
echo "############################"
echo "please check date,you can you these cmd to change!"
echo "-------------------------------------------------"
echo ""
echo "date -s 10:20:00;hwclock --systohc"
echo "cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime"