Skip to content

Commit c32af00

Browse files
committed
feat(install): 增加授权下载功能
- 添加授权下载逻辑,支持通过 token 进行下载 - 根据是否提供 token,选择不同的下载主机和授权 URL - 修改 JDK 和 Jpom 下载 URL 以支持授权下载
1 parent 17245a2 commit c32af00

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

docs/.vuepress/public/docs/install.sh

+19-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,25 @@ JPOM_TYPE="$1"
3333
ARGS="$*"
3434
module="$2"
3535
offline=$(echo "$module" | grep "offline")
36+
authorize=$(echo "$module" | grep "authorize")
3637
binAbsPath=$(absPath "$(dirname "$0")")
3738

39+
authorizeUrl=""
40+
downloadHost=""
41+
42+
if [ "$authorize" == "" ]; then
43+
authorizeUrl=""
44+
downloadHost="d.jpom.download"
45+
else
46+
token="$3"
47+
if [ "$token" == "" ]; then
48+
errorExit "请指定授权token参数:./install.sh $JPOM_TYPE ${module} xxxx"
49+
fi
50+
authorizeUrl="?token=${token}"
51+
downloadHost="download.jpom.top"
52+
echo "使用授权下载中心:${downloadHost} 授权码:${token}"
53+
fi
54+
3855
function errorExit() {
3956
msg="$1"
4057
echo "$msg" 2>&2
@@ -154,7 +171,7 @@ function installJdkFn() {
154171
errorExit "系统环境变量中已经存在 JAVA_HOME,请检查配置是否正确.或者终端是否重新加载环境变量:source $userProfileName"
155172
fi
156173

157-
download_url=$(curl -s https://d.jpom.download/jdk-url/8/${ARCH})
174+
download_url=$(curl -s https://${downloadHost}/jdk-url/8/${ARCH}{authorizeUrl})
158175

159176
curl -LfSo jdk.tar.gz "${download_url}"
160177

@@ -456,7 +473,7 @@ done
456473
# 判断是否存在文件
457474
if [[ ! -f "${fileName}" ]]; then
458475
echo "================开始下载 $fileName================"
459-
curl -LfSo "${fileName}" "https://d.jpom.download/$use_tag/${versions}/${url_type}-${versions}-release.tar.gz"
476+
curl -LfSo "${fileName}" "https://${downloadHost}/$use_tag/${versions}/${url_type}-${versions}-release.tar.gz${authorizeUrl}"
460477
fi
461478
# 解压
462479
tar -zxf "${fileName}" -C "${jpom_dir}"

0 commit comments

Comments
 (0)