码迷,mamicode.com
首页 > 系统相关 > 详细

【shell脚本】自动配置yum源auto_yum_config.sh

时间:2020-06-19 21:05:36      阅读:68      评论:0      收藏:0      [点我收藏+]

标签:rhel   redhat   http   ror   cas   centos6   name   url   color   

[root@rhel8 shell]# cat auto_yum_config.sh 
#!/bin/bash
##########################################################################
# yum config case                                                        #
# by author tanbaobao 2020/06/16                                         #
##########################################################################

YUM_IP=本机ip
# CentOS系统:`cat /etc/redhat-release | awk ‘{print $4}‘ | awk -F"." ‘{print $1"."$2}‘`
OS_VERSION=`cat /etc/redhat-release | awk ‘{print $6}‘ | awk -F"." ‘{print $1"."$2}‘`
YUM_DIR=/etc/yum.repos.d

# 如果目录不存在,则执行后面语句
[ -d "$YUM_DIR" ] || mkdir -p $YUM_DIR/bak
mv $YUM_DIR/*.repo $YUM_DIR/bak

case "$OS_VERSION" in
    8.1)
        cat >$YUM_DIR/repo8u1.repo <<-EOF
        [repo8u1]
        name=repo8u1
        baseurl=ftp://$YUM_IP/repo8u1
        gpgcheck=0
        EOF
        echo "8.1 yum configure.."
        ;;
    7.3)
        cat >$YUM_DIR/repo8u1.repo <<-EOF
        [centos7u3]
        name=centos7u3
            baseurl=file:///centos7u3
            gpgcheck=0
        EOF
        ;;    
    6.8)
        wget -O $YUM_DIR/centos6u8.repo http://mirrors.aliyun.com/repo/Centos-6.repo
        ;;
    5.9)
        curl -o $YUM_DIR/CentOS_Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
        ;;
    *)
        echo -e "\033[34mError\033[0m"
esac

 

【shell脚本】自动配置yum源auto_yum_config.sh

标签:rhel   redhat   http   ror   cas   centos6   name   url   color   

原文地址:https://www.cnblogs.com/HeiDi-BoKe/p/13166232.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!