#!/bin/bash
releasetmp=`cat /etc/redhat-release | awk '{match($0,"release ")
print substr($0,RSTART+RLENGTH)}' | awk -F '.' '{print $1}'`
echo 版本号为:$releasetmp
sleep 5
yum install wget -y
echo 安装wget命令
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
echo 备份完毕
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-$releasetmp.repo
if [[ $? -eq 0 ]];then
echo -e "\033[32m# yum 源已成功更新为 aliyun_repo #\033[0m";
sleep 3;
else
echo -e "\033[31m# yum 源未成功更新为 aliyun_repo #\n3s 后退出...\033[0m";
exit;
fi
yum clean all
yum makecache
yum update -y;
config_file="/etc/selinux/config"
sed -i 's/SELINUX=enforcing/#SELINUX=enforcing/' $config_file
sed -i "/#SELINUX=enforcing/a\SELINUX=disabled" $config_file
echo 修改完毕,需重启生效
sleep 5
yum -y install iputils net-tools.x86_64
sleep 5
reboot