Created
March 18, 2022 06:39
-
-
Save fumiyas/08cf22ddd84f94ca0b6c32b922888958 to your computer and use it in GitHub Desktop.
CentOS: Replace obsolete CentOS repos with CentOS Vault mirrored in Japan
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
## | |
## CentOS: Replace obsolete CentOS repos with CentOS Vault mirrored in Japan | |
## Copyright (c) 2022 SATOH Fumiyasu @ OSSTech Corp., Japan | |
## | |
## License: GNU General Public License version 3 | |
## | |
set -u | |
set -e | |
umask 0022 | |
latest_baseurl="\ | |
http://ftp.iij.ad.jp/pub/linux/centos-vault/\$contentdir/\$releasever/\\2/\$basearch/\\3/,\ | |
http://ftp.jaist.ac.jp/pub/Linux/CentOS-vault/\$contentdir/\$releasever/\\2/\$basearch/\\3/\ | |
" | |
mkdir -p /etc/yum.repos.d/dist | |
for repo in /etc/yum.repos.d/CentOS-*.repo; do | |
repo_dist="/etc/yum.repos.d/dist/$(basename $repo)" | |
if [[ ! -f $repo ]]; then | |
continue | |
fi | |
if [[ ! -f $repo_dist ]]; then | |
cp -a "$repo" "$repo_dist" | |
fi | |
sed \ | |
-e 's/^\[\(.*\)\]/[\L\1]/' \ | |
-e 's!^mirrorlist=!#&!' \ | |
-e "s!^#* *\(baseurl=\).*/\([a-zA-Z]*\)/[^/]*/\([a-z]*\)/\$!\1$latest_baseurl!" \ | |
<"$repo_dist" \ | |
>"$repo" \ | |
; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment