帮我写一个centos服务器更换成阿里源的shell脚本
时间: 2023-03-07 13:14:18 浏览: 139
#!/bin/bash
#centos更换阿里源的shell脚本#备份现有源
cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak#使用阿里源替换原源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo#更新缓存
yum clean all
yum makecache#检查并返回结果
if [ -f "/etc/yum.repos.d/CentOS-Base.repo" ];then
echo "更换阿里源成功"
else
echo "更换阿里源失败"
fi
阅读全文