#!/usr/bash/bin yum_server=192.168.201.130 os_version=`cat /etc/redhat-release | awk '{print $4}' | awk -F"." '{print $1"."$2}'` [ -d /etc/yum.repos.d] || mkdir /etc/yum.repos.d/bak mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak if [ "$os_version"="7.3" ];then cat > /etc/yum.repos.d/centos7u3.repo <<-EOF [centos7u3] name=centos7u3 baseurl=ftp://$yum_server/centos7u3 gpgcheck=0 EOF echo "7.3 yum configure.." elif [ "$os_version"="6.8" ];then curl -o /etc/yum.repos.d/centos6u8.repo ftp://$yum_server/centos6u8 else echoo "error" fi
case格式: case 变量 in 模式1) 命令序列1 ;; 模式2) 命令序列2 ;; *) 无匹配后命令序列 esac
#!/usr/bash/bin yum_server=192.168.201.130 os_version=`cat /etc/redhat-release | awk '{print $4}' | awk -F"." '{print $1"."$2}'` [ -d /etc/yum.repos.d] || mkdir /etc/yum.repos.d/bak mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak case $os_version in 7.3) cat > /etc/yum.repos.d/centos7u3.repo << EOF [centos7u3] name=centos7u3 baseurl=ftp://$yum_server/centos7u3 gpgcheck=0 EOF echo "7.3 yum configure.." ;; 6.8) curl -o /etc/yum.repos.d/centos6u8.repo ftp://$yum_server/centos6u8 ;; *) esac
标签:case,repos,cat,etc,version,yum,系统配置 From: https://www.cnblogs.com/smatter/p/16937052.html