From cf88a9570e1374599910c8a4fc7eb2401d6e5234 Mon Sep 17 00:00:00 2001 From: wanhebin Date: Mon, 17 Apr 2023 17:00:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20clash=20secret=20=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 + start.sh | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.env b/.env index ec3b556..6159115 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ # Clash 订阅地址 export CLASH_URL='更改为你的clash订阅地址' +export CLASH_SECRET='' diff --git a/start.sh b/start.sh index 6869777..a03910e 100755 --- a/start.sh +++ b/start.sh @@ -17,6 +17,14 @@ Temp_Dir="$Server_Dir/temp" Log_Dir="$Server_Dir/logs" URL=${CLASH_URL} +# 获取CLASH SECRET 值 +if [ ! $CLASH_SECRET ]; then + # 随机生成并更新 API Secret + Secret=`openssl rand -hex 32` +else + Secret=${CLASH_SECRET} +fi + # 自定义action函数,实现通用action功能 success() { 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) Dashboard_Dir="${Work_Dir}/dashboard/public" 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 # 获取CPU架构 @@ -142,8 +148,8 @@ fi # Output Dashboard access address and Secret echo '' -echo -e "Clash Dashboard 访问地址:http://:9090/ui" -echo -e "Secret:${Secret}" +echo -e "Clash Dashboard 访问地址: http://:9090/ui" +echo -e "Secret: ${Secret}" echo '' # 添加环境变量(root权限)