yum自动脚本

echo -e "\033[34mstop server:\033[0m"
service iptables stop
service NetworkManager stop
chkconfig --del iptables
chkconfig --del NetworkManager
setenforce 0
cat /etc/redhat-release | cut -d' ' -f3 | cut -d. -f1 >/so.txt
#read -p "Input source.1/2/3:" MI
if [ $(cat /so.txt) -eq 6 ];then
        cd /etc/yum.repos.d/
        [ -f /etc/yum.repos.d/CentOS-Base.repo ] && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak && echo "backup local source OK!"
        [ -f /etc/yum.repos.d/CentOS6-Base.repo ] && echo "yum source exist" && yum list && exit 4
        [ ! -f /etc/yum.repos.d/CentOS6-Base.repo ] && wget http://10.56.126.75/.help/CentOS6-Base.repo
        [ -f /etc/yum.repos.d/CentOS6-Base.repo ] && yum clean all &>/dev/null && echo "Clean Yum cache OK" || echo "Loading error." 
        yum makecache
        yum list
        rm -rf /so.txt
elif [ $(cat /so.txt) -eq 7 ];then
        cd /etc/yum.repos.d/
        [ -f /etc/yum.repos.d/CentOS-Base.repo ] && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak && echo "backup local source OK!"
        [ -f /etc/yum.repos.d/CentOS7-Base.repo ] && echo "yum source exist" && exit 4
        [ ! -f /etc/yum.repos.d/CentOS7-Base.repo ] && wget http://10.56.126.75/.help/CentOS7-Base.repo
        [ -f /etc/yum.repos.d/CentOS7-Base.repo ] && yum clean all &>/dev/null && echo "Clean Yum cache OK" || echo "Loading error." && exit 4
        echo "please waiting..." 
        yum makecahe
        yum list
        rm -rf /so.txt
elif [ $(cat /so.txt) -eq 5 ];then
        [ -f /etc/yum.repos.d/CentOS-Base.repo ] && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak && echo "backup local source OK!"
        [ -f /etc/yum.repos.d/CentOS5-Base.repo ] && echo "yum source exist" && yum list && exit 4
        [ ! -f /etc/yum.repos.d/CentOS5-Base.repo ] && wget http://10.56.126.75/.help/CentOS5-Base.repo
        [ -f /etc/yum.repos.d/CentOS5-Base.repo ] && yum clean all &>/dev/null && echo "Clean Yum cache OK" || echo "Loading error." 
        yum makecache
        yum list
        rm -rf /so.txt

else
        echo "error option"
        exit 4
fi

转载于:https://www.cnblogs.com/ligao/p/5995505.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值