Created
September 9, 2018 15:54
-
-
Save rbpi/e2fe777bef05d3b251b88dc7e0acaf80 to your computer and use it in GitHub Desktop.
CentOS 7 mirrors&epel with aliyun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup | |
echo "CentOS-Base.repo backup successful" | |
/bin/cat <<'EOF' > /etc/yum.repos.d/CentOS-Base.repo | |
# CentOS-Base.repo | |
# | |
# The mirror system uses the connecting IP address of the client and the | |
# update status of each mirror to pick mirrors that are updated to and | |
# geographically close to the client. You should use this for CentOS updates | |
# unless you are manually picking other mirrors. | |
# | |
# If the mirrorlist= does not work for you, as a fall back you can try the | |
# remarked out baseurl= line instead. | |
# | |
# | |
[base] | |
name=CentOS-$releasever - Base - mirrors.aliyun.com | |
failovermethod=priority | |
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ | |
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ | |
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/ | |
gpgcheck=1 | |
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 | |
#released updates | |
[updates] | |
name=CentOS-$releasever - Updates - mirrors.aliyun.com | |
failovermethod=priority | |
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ | |
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ | |
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/ | |
gpgcheck=1 | |
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 | |
#additional packages that may be useful | |
[extras] | |
name=CentOS-$releasever - Extras - mirrors.aliyun.com | |
failovermethod=priority | |
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ | |
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ | |
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/ | |
gpgcheck=1 | |
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 | |
#additional packages that extend functionality of existing packages | |
[centosplus] | |
name=CentOS-$releasever - Plus - mirrors.aliyun.com | |
failovermethod=priority | |
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ | |
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ | |
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/ | |
gpgcheck=1 | |
enabled=0 | |
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 | |
#contrib - packages by Centos Users | |
[contrib] | |
name=CentOS-$releasever - Contrib - mirrors.aliyun.com | |
failovermethod=priority | |
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ | |
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ | |
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/ | |
gpgcheck=1 | |
enabled=0 | |
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 | |
EOF | |
echo "aliyun CentOS-Base.repo write successful" | |
yum makecache | |
yum install -y epel-release | |
echo "epel-release install successful" | |
#mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup | |
#mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup | |
/bin/cat <<'EOF' > /etc/yum.repos.d/epel.repo | |
[epel] | |
name=Extra Packages for Enterprise Linux 7 - $basearch | |
baseurl=http://mirrors.aliyun.com/epel/7/$basearch | |
failovermethod=priority | |
enabled=1 | |
gpgcheck=0 | |
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 | |
[epel-debuginfo] | |
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug | |
baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug | |
failovermethod=priority | |
enabled=0 | |
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 | |
gpgcheck=0 | |
[epel-source] | |
name=Extra Packages for Enterprise Linux 7 - $basearch - Source | |
baseurl=http://mirrors.aliyun.com/epel/7/SRPMS | |
failovermethod=priority | |
enabled=0 | |
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 | |
gpgcheck=0 | |
EOF | |
echo "epel.repo write successful" | |
yum update -y | |
echo "yum update successful" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment