2024-07-24 00:56:26 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
declare version=$(cat /etc/os-release | grep VERSION_CODENAME | awk -F '=' '{print $2}')
|
|
|
|
|
|
|
|
case "$version" in
|
|
|
|
'bookworm')
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "暂不支持该系统一键换源"
|
|
|
|
exit
|
|
|
|
esac
|
|
|
|
|
2024-07-24 12:50:44 +08:00
|
|
|
declare -A sources_dick
|
|
|
|
sources_dick['中国科技技术大学(默认)']='http://mirrors.ustc.edu.cn'
|
|
|
|
sources_dick['清华大学']='https://mirrors.tuna.tsinghua.edu.cn'
|
|
|
|
sources_dick['阿里云']='https://mirrors.aliyun.com'
|
2024-07-24 13:25:35 +08:00
|
|
|
sources_dick['网易云']='https://mirrors.163.com'
|
2024-07-24 00:56:26 +08:00
|
|
|
|
2024-07-24 12:50:44 +08:00
|
|
|
declare -a pcik_array
|
|
|
|
declare pick=0
|
2024-07-24 00:56:26 +08:00
|
|
|
echo "========Sources========"
|
2024-07-24 12:50:44 +08:00
|
|
|
for i in "${!sources_dick[@]}";
|
|
|
|
do
|
|
|
|
pick=$(( pick+1 ))
|
|
|
|
pcik_array[$pick]=$i
|
|
|
|
echo "${pick}.${i}"
|
|
|
|
done
|
2024-07-24 00:56:26 +08:00
|
|
|
echo "========Sources========"
|
2024-07-24 12:50:44 +08:00
|
|
|
read -p "请输入:" pick
|
2024-07-24 00:56:26 +08:00
|
|
|
|
|
|
|
|
2024-07-24 12:50:44 +08:00
|
|
|
if [[ ${pick} -le 0 || ${pick} -gt ${#sources_dick[*]} ]];then
|
2024-07-24 00:56:26 +08:00
|
|
|
echo "输入错误"
|
|
|
|
exit
|
2024-07-24 12:50:44 +08:00
|
|
|
elif [[ -z $pick ]];then
|
|
|
|
declare url='http://mirrors.ustc.edu.cn'
|
|
|
|
else
|
|
|
|
pick=${pcik_array[$pick]}
|
|
|
|
declare url=${sources_dick[$pick]}
|
2024-07-24 00:56:26 +08:00
|
|
|
fi
|
|
|
|
|
2024-07-24 12:50:44 +08:00
|
|
|
|
|
|
|
|
2024-07-24 00:56:26 +08:00
|
|
|
case "$version" in
|
|
|
|
'bookworm')
|
|
|
|
{
|
2024-07-24 12:50:44 +08:00
|
|
|
echo "deb ${url}/debian/ bookworm main contrib non-free non-free-firmware"
|
|
|
|
echo "deb ${url}/debian/ bookworm-updates main contrib non-free non-free-firmware"
|
|
|
|
echo "deb ${url}/debian/ bookworm-backports main contrib non-free non-free-firmware"
|
2024-07-24 00:56:26 +08:00
|
|
|
} > /etc/apt/sources.list
|
|
|
|
sudo apt-get update
|
|
|
|
;;
|
|
|
|
esac
|