Last active
August 21, 2024 13:20
-
-
Save lesstif/8185f143ba7b8881e767900b1c8e98ad to your computer and use it in GitHub Desktop.
우분투(ubuntu)의 apt 기본 미러(mirror)를 다음 카카오(kakao), 카이스트(kaist), 부경대(harukasan) 으로 변경
This file contains 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
#!/usr/bin/env bash | |
SL=/etc/apt/sources.list | |
PARAM="r:hm:dnak" | |
KAKAO=mirror.kakao.com | |
KAIST=ftp.kaist.ac.kr | |
HARU=ftp.harukasan.org | |
if [ "$(id -u)" != "0" ]; then | |
echo "'$0' must be run as root" 1>&2 | |
exit 1 | |
fi | |
function usage { | |
echo "USAGE: $0 [OPTION] "; | |
echo -e "\r\n-b : make backup file"; | |
echo "-r[sources.list] : specify source list file (default ${SL})" | |
echo "-m[mirror-url] : speficy mirror site url" | |
echo "-k : use kakao mirror (${KAKAO})" | |
echo "-n : use kaist mirror (${KAIST})" | |
echo "-a : use harukasan mirror (${HARU})" | |
exit 0; | |
} | |
REPOS=${KAKAO} | |
while getopts $PARAM opt; do | |
case $opt in | |
r) | |
echo "-r option was supplied. OPTARG: $OPTARG" >&2 | |
SL=$OPTARG; | |
;; | |
m) | |
echo "Using mirror repository(${OPTARG})." >&2 | |
REPOS=${OPTARG} | |
;; | |
k) | |
echo "Using Kakao repository(${KAKAO})." >&2 | |
REPOS=${KAKAO} | |
;; | |
n) | |
echo "Using kaist repository(${KAIST})." >&2 | |
REPOS=${KAIST} | |
;; | |
a) | |
echo "Using harukasan repository(${HARU})." >&2 | |
REPOS=${HARU} | |
;; | |
h) | |
usage; | |
;; | |
esac | |
done | |
echo "using repository(${REPOS})" | |
## change mirror | |
sed -i.bak -re "s/([a-z]{2}.)?archive.ubuntu.com|security.ubuntu.com/${REPOS}/g" ${SL} | |
## check | |
apt update |
CentOS 미러 변경은 change-centos-mirror.sh를 참고하세요.
Could you please modify /bin/sh to /bin/bash for more clear?
Rocky Linux 미러 변경은 change rocky mirror 을 참고하세요.
간지나는 코드네요 ㄷ 한줄로도 실행해봅시다
bash <(curl -Ss https://gist.githubusercontent.com/lesstif/8185f143ba7b8881e767900b1c8e98ad/raw/b749a8fc590ad2391fd0f8849417eeec998b33a7/change-ubuntu-mirror.sh)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
굳굳