新增 clash secret 自定义功能

This commit is contained in:
wanhebin 2023-04-17 17:00:40 +08:00
parent 47994382ae
commit cf88a9570e
2 changed files with 11 additions and 4 deletions

1
.env
View File

@ -1,2 +1,3 @@
# Clash 订阅地址 # Clash 订阅地址
export CLASH_URL='更改为你的clash订阅地址' export CLASH_URL='更改为你的clash订阅地址'
export CLASH_SECRET=''

View File

@ -17,6 +17,14 @@ Temp_Dir="$Server_Dir/temp"
Log_Dir="$Server_Dir/logs" Log_Dir="$Server_Dir/logs"
URL=${CLASH_URL} URL=${CLASH_URL}
# 获取CLASH SECRET 值
if [ ! $CLASH_SECRET ]; then
# 随机生成并更新 API Secret
Secret=`openssl rand -hex 32`
else
Secret=${CLASH_SECRET}
fi
# 自定义action函数实现通用action功能 # 自定义action函数实现通用action功能
success() { success() {
echo -en "\\033[60G[\\033[1;32m OK \\033[0;39m]\r" echo -en "\\033[60G[\\033[1;32m OK \\033[0;39m]\r"
@ -103,8 +111,6 @@ cat $Temp_Dir/proxy.txt >> $Temp_Dir/config.yaml
Work_Dir=$(cd $(dirname $0); pwd) Work_Dir=$(cd $(dirname $0); pwd)
Dashboard_Dir="${Work_Dir}/dashboard/public" Dashboard_Dir="${Work_Dir}/dashboard/public"
sed -ri "s@^# external-ui:.*@external-ui: ${Dashboard_Dir}@g" $Conf_Dir/config.yaml sed -ri "s@^# external-ui:.*@external-ui: ${Dashboard_Dir}@g" $Conf_Dir/config.yaml
# 随机生成并更新 API Secret
Secret=`openssl rand -hex 32`
sed -r -i '/^secret: /s@(secret: ).*@\1'${Secret}'@g' $Conf_Dir/config.yaml sed -r -i '/^secret: /s@(secret: ).*@\1'${Secret}'@g' $Conf_Dir/config.yaml
# 获取CPU架构 # 获取CPU架构
@ -142,8 +148,8 @@ fi
# Output Dashboard access address and Secret # Output Dashboard access address and Secret
echo '' echo ''
echo -e "Clash Dashboard 访问地址http://<ip>:9090/ui" echo -e "Clash Dashboard 访问地址: http://<ip>:9090/ui"
echo -e "Secret${Secret}" echo -e "Secret: ${Secret}"
echo '' echo ''
# 添加环境变量(root权限) # 添加环境变量(root权限)