cat yum_if.sh
1 #!/bin/bash 2 3 4 #if for many branches yum 5 #version 1 by feng 6 7 yum_server=192.168.0.117 8 Os_version=$(cat /etc/redhat-release |awk '{print $4}'|cut -c 1-3) 9 [ -d /etc/yum.repos.d/bak ]||mkdir /etc/yum.repos.d/bak && mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak 10 if [ "$Os_version" = "7.4" ] ;then 11 cat >/etc/yum.repos.d/Centos7u4.repo<<-eof 12 [Centos7u4] 13 name=Centos7u4 14 baseurl=http://$yum_server/Base7u4.repo 15 gpgcheck=0 16 eof 17 elif [ "$Os_version" = "6.8" ];then 18 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 19 elif [ "$Os_version" = "8.3" ];then 20 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo 21 else 22 echo "error……" 23 fi
[root@localhost if]# cat /etc/yum.repos.d/Centos7u4.repo [Centos7u4] name=Centos7u4 baseurl=http://192.168.0.117/Base7u4.repo gpgcheck=0 [root@localhost if]#