[root@haimati shell]# cat Yum_Aliyun.sh #!/bin/bash# 替换默认Yum源为 国内阿里云Yum源# 适用于Linux Centos 6-8 版本!、/etc/init.d/functionsREDHAT=$(cat /etc/redhat-release | awk '{print $4}'| awk -F 、'{print $1}')if [ $REDHAT -eq 7 ];thenif ! [ -d /etc/yum.repos.d/Yum.bak ];thenmkdir /etc/yum.repos.d/Yum.bak/fimv /etc/yum.repos.d/CentOS-base.repo /etc/yum.repos.d/Yum.bakmv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/Yum.bak(wget -O /etc/yum.repos.d/CentOS-base.repo https://mirrors.aliyun.com/repo/Centos-7.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo) &>/dev/nullif [ $? -eq 0 ];thenaction "Yum:"elseaction "Yum" false fielif [ $REDHAT -eq 6 ];thenif ! [ -d /etc/yum.repos.d/Yum.bak ];thenmkdir /etc/yum.repos.d/Yum.bak/fi(mv /etc/yum.repos.d/CentOS-base.repo /etc/yum.repos.d/Yum.bakmv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/Yum.bak) &>/dev/null(wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repowget -O /etc/yum.repos.d/CentOS-base.repo https://mirrors.aliyun.com/repo/Centos-6.repo) &>/dev/nullif [ $? -eq 0 ];thenaction "Yum:"elseaction "Yum" false fielif [ $REDHAT -eq 8 ];thenif ! [ -d /etc/yum.repos.d/Yum.bak ];thenmkdir /etc/yum.repos.d/Yum.bak/fi(mv /etc/yum.repos.d/CentOS-base.repo /etc/yum.repos.d/Yum.bakmv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/Yum.bak) &>/dev/null(wget -O /etc/yum.repos.d/CentOS-base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repoyum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpmsed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*) &>/dev/nullif [ $? -eq 0 ];thenaction "Yum:"elseaction "Yum" false fifi
更换阿里云Yum源脚本
时间:2023-07-15
相关推荐