Skip to content

Commit b2c02b5

Browse files
authored
修改GH代理方式 (#414)
修改脚本中gh代理设置方式,可在安装或者更新时,手动指定代理地址
1 parent 7afe549 commit b2c02b5

File tree

1 file changed

+36
-2
lines changed
  • docs/.vuepress/public

1 file changed

+36
-2
lines changed

docs/.vuepress/public/v3.sh

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ fi
3838
# 配置部分
3939
#######################
4040
# GitHub 相关配置
41-
GH_PROXY='' # 可以修改为其他代理地址,如果不需要代理可以设置为空
4241
GH_DOWNLOAD_URL="${GH_PROXY}https://github.com/alist-org/alist/releases/latest/download"
4342
#######################
4443

@@ -190,10 +189,27 @@ INSTALL() {
190189
# 保存当前目录
191190
CURRENT_DIR=$(pwd)
192191

192+
# 询问是否使用代理
193+
echo -e "${GREEN_COLOR}是否使用 GitHub 代理?(默认无代理)${RES}"
194+
echo -e "${GREEN_COLOR}代理地址必须为 https 开头,斜杠 / 结尾 ${RES}"
195+
echo -e "${GREEN_COLOR}例如:https://ghproxy.com/ ${RES}"
196+
read -p "请输入代理地址或直接按回车继续: " proxy_input
197+
198+
# 如果用户输入了代理地址,则使用代理拼接下载链接
199+
if [ -n "$proxy_input" ]; then
200+
GH_PROXY="$proxy_input"
201+
GH_DOWNLOAD_URL="${GH_PROXY}https://github.com/alist-org/alist/releases/latest/download"
202+
echo -e "${GREEN_COLOR}已使用代理地址: $GH_PROXY${RES}"
203+
else
204+
# 如果不需要代理,直接使用默认链接
205+
GH_DOWNLOAD_URL="https://github.com/alist-org/alist/releases/latest/download"
206+
echo -e "${GREEN_COLOR}使用默认 GitHub 地址进行下载${RES}"
207+
fi
208+
193209
# 下载 Alist 程序
194210
echo -e "\r\n${GREEN_COLOR}下载 Alist ...${RES}"
195211

196-
# 使用 GitHub 源下载
212+
# 使用拼接后的 GitHub 下载地址
197213
if ! download_file "${GH_DOWNLOAD_URL}/alist-linux-musl-$ARCH.tar.gz" "/tmp/alist.tar.gz"; then
198214
echo -e "${RED_COLOR}下载失败!${RES}"
199215
exit 1
@@ -227,6 +243,7 @@ INSTALL() {
227243
rm -f /tmp/alist*
228244
}
229245

246+
230247
INIT() {
231248
if [ ! -f "$INSTALL_PATH/alist" ]; then
232249
echo -e "\r\n${RED_COLOR}出错了${RES},当前系统未安装 Alist\r\n"
@@ -304,6 +321,23 @@ UPDATE() {
304321

305322
echo -e "${GREEN_COLOR}开始更新 Alist ...${RES}"
306323

324+
# 询问是否使用代理
325+
echo -e "${GREEN_COLOR}是否使用 GitHub 代理?(默认无代理)${RES}"
326+
echo -e "${GREEN_COLOR}代理地址必须为 https 开头,斜杠 / 结尾 ${RES}"
327+
echo -e "${GREEN_COLOR}例如:https://ghproxy.com/ ${RES}"
328+
read -p "请输入代理地址或直接按回车继续: " proxy_input
329+
330+
# 如果用户输入了代理地址,则使用代理拼接下载链接
331+
if [ -n "$proxy_input" ]; then
332+
GH_PROXY="$proxy_input"
333+
GH_DOWNLOAD_URL="${GH_PROXY}https://github.com/alist-org/alist/releases/latest/download"
334+
echo -e "${GREEN_COLOR}已使用代理地址: $GH_PROXY${RES}"
335+
else
336+
# 如果不需要代理,直接使用默认链接
337+
GH_DOWNLOAD_URL="https://github.com/alist-org/alist/releases/latest/download"
338+
echo -e "${GREEN_COLOR}使用默认 GitHub 地址进行下载${RES}"
339+
fi
340+
307341
# 停止 Alist 服务
308342
echo -e "${GREEN_COLOR}停止 Alist 进程${RES}\r\n"
309343
systemctl stop alist

0 commit comments

Comments
 (0)