欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

更换阿里云Yum源脚本

时间:2023-07-15

[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

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。