shell脚本自动配置yum源auto_yum_config.sh
Posted HeiDi_BoKe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell脚本自动配置yum源auto_yum_config.sh相关的知识,希望对你有一定的参考价值。
[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 "