更新CentOS 7系统的repo源为阿里云镜像源
脚本内容如下
#! /bin/bash
echo "备份源镜像源,备份文件名为:CentOS-Base.repo.$(date +%Y%m%d%H%M).bak"
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.$(date +%Y%m%d%H%M).bak
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
if [ $? -eq 0 ];then
echo "开始更新镜像源缓存"
yum clean all && yum makecache
if [ $? -eq 0 ];then
echo "镜像源已更新完成"
else
echo "更新镜像源缓存出现异常,请手动更新"
exit 2
fi
else
echo "下载阿里镜像源文件失败,请手动下载"
exit 1
fi