Created
February 21, 2022 09:41
-
-
Save HUGHNew/e26857afed54a824cf8fd3517728a7bb to your computer and use it in GitHub Desktop.
Maybe works for Debian and its derivative versions which use apt/dpkg as package manager
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
#!/bin/bash | |
set -e | |
fn=sources.list | |
sfn=/etc/apt/$fn | |
ali="mirrors.aliyun.com" | |
ustc="mirrors.ustc.edu.cn" | |
ts="mirrors.tuna.tsinghua.edu.cn" | |
raw="$(awk -F / '{print $3}' /etc/apt/sources.list.raw |grep -v "^$"|head -n 1)" | |
cp $sfn ./$fn | |
sudo mv $sfn $sfn.raw | |
sed -e "1c # USTC Source" -e "s/$raw/$ustc/g" $fn |sudo tee $sfn > /dev/null | |
sed -e "1c # Aliyun Source" -e "s/$raw/$ali/g" $fn |sudo tee -a $sfn > /dev/null | |
rm ./$fn | |
echo "change source successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment