Skip to content

Commit

Permalink
简单的换源shell脚本
Browse files Browse the repository at this point in the history
仅支持Debian,第一版仅支持更换中科大源。
  • Loading branch information
MeGuMinEx authored Jun 7, 2021
0 parents commit 30e2fb4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions shell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#sudo apt-get update
echo "仅支持Debian 10,9,8,7"
result=`lsb_release -a`

target="/etc/apt/sources.list"
echo ======================================
mv /etc/apt/sources.list /etc/apt/sourcesbackup.list
echo "原sources.list文件已在/etc/apt路径下备份为sourcesbackup.list"
echo ======================================
echo $result
echo ======================================
codename=${result##*:}
#截取result变量获取到的内容,从右向左第一个 : 开始左边全部删除并存入codename变量
echo codename
echo $codename
echo ======================================
echo result
echo ${result##*:}
echo ======================================
echo "写入中"
echo ======================================
echo "deb http://mirrors.ustc.edu.cn/debian/ "${codename}" main non-free contrib" > $target
echo "deb http://mirrors.ustc.edu.cn/debian/ "${codename}"-proposed-updates main non-free contrib" >> $target
echo "deb-src http://mirrors.ustc.edu.cn/debian/" ${codename} "main non-free contrib">> $target
echo "deb-src http://mirrors.ustc.edu.cn/debian/" ${codename}"-proposed-updates main non-free contrib" >>$target
echo "写入完成"
echo ======================================
echo "更新软件源"
sudo apt-get update
#更新apt软件源
echo ======================================
echo "升级"
sudo apt-get upgrade
echo ======================================
#执行一次升级

0 comments on commit 30e2fb4

Please sign in to comment.