Skip to content

Commit 1d824a5

Browse files
authored
Merge pull request #1 from shenmo7192/master
feat: Support aptss accelerate and mirror server
2 parents 3af1340 + 0b3675a commit 1d824a5

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

fcitx5_customizer.sh

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Author: DebuggerX <[email protected]>
55

66
BASE_URL="www.debuggerx.com/fcitx5_customizer/"
7-
7+
BASE_URL_SPARK_MIRROR="cdn.d.store.deepinos.org.cn/spark-community-mirror/fcitx5-customizer-assets/"
88
SELECTED_SKIN=''
99

1010
function select_skin {
@@ -58,7 +58,7 @@ function download_and_unzip() {
5858
echo "$2下载成功"
5959
else
6060
echo "重试下载$2[http://$BASE_URL$1]"
61-
curl -o /tmp/"$1" "http://$BASE_URL$1"
61+
curl -o /tmp/"$1" "http://$BASE_URL_SPARK_MIRROR$1"
6262
if unzip -z /tmp/"$1"; then
6363
echo "$2下载成功"
6464
else
@@ -101,6 +101,28 @@ function check_installed() {
101101
fi
102102
return 1
103103
}
104+
# 添加aptss支持:若aptss可用,对deepin加速(deepin官方源似乎....已经买不起大流量了?)
105+
function decide_apt_command()
106+
{
107+
if grep -Eqii "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then
108+
DISTRO='Deepin'
109+
elif grep -Eqi "UnionTech" /etc/issue || grep -Eq "UnionTech" /etc/*-release; then
110+
DISTRO='UniontechOS'
111+
elif grep -Eqi "UOS" /etc/issue || grep -Eq "UOS" /etc/*-release; then
112+
DISTRO='UniontechOS'
113+
else
114+
DISTRO='OtherOS'
115+
fi
116+
117+
if [ "$DISTRO" = "Deepin" ] && [ "`which aptss`" != "" ];then
118+
echo "检测到正在使用deepin,且aptss加速可用,使用aptss进行安装加速"
119+
apt_command="aptss"
120+
else
121+
echo "使用/usr/bin/apt来提供安装服务"
122+
apt_command=/usr/bin/apt
123+
fi
124+
}
125+
104126

105127
# 检查包,未安装则执行安装
106128
# params: <包名> <包的中文名>
@@ -115,7 +137,7 @@ function check_and_install() {
115137
else
116138
echo "安装$2"
117139
fi
118-
sudo apt install -y "$1"
140+
sudo ${apt_command} install -y "$1"
119141
fi
120142
}
121143

@@ -126,6 +148,9 @@ if ! [ -e /usr/bin/apt ] ; then
126148
exit
127149
fi
128150

151+
152+
decide_apt_command
153+
129154
# 先确保dialog、unzip和curl已安装
130155
check_and_install unzip ''
131156
check_and_install dialog ''

0 commit comments

Comments
 (0)