From 499b085f05d349af72fd77b6d01238e50da797aa Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Thu, 28 May 2026 14:51:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81,=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AF=86=E7=A0=81=E5=87=BD=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BC=A0=E5=85=A5=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=B7=AF=E5=BE=84=E5=B9=B6=E5=A2=9E=E5=8A=A0=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/create_config_hysteria.sh | 8 +++---- bin/create_config_tuic.sh | 4 ++-- bin/password.sh | 40 +++++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/bin/create_config_hysteria.sh b/bin/create_config_hysteria.sh index e46f788..2737778 100644 --- a/bin/create_config_hysteria.sh +++ b/bin/create_config_hysteria.sh @@ -38,10 +38,10 @@ create_hysteria_self_tls_config() { update_port # 设置密码 - update_password + update_password "$CONFIG_FILE" # 设置混淆密码 - update_obfs_password + update_obfs_password "$CONFIG_FILE" green "成功创建配置" } @@ -58,10 +58,10 @@ create_hysteria_acme_tls_config() { update_port # 设置密码 - update_password + update_password "$CONFIG_FILE" # 设置混淆密码 - update_obfs_password + update_obfs_password "$CONFIG_FILE" green "成功创建配置" } diff --git a/bin/create_config_tuic.sh b/bin/create_config_tuic.sh index 851bb64..d83fe2b 100644 --- a/bin/create_config_tuic.sh +++ b/bin/create_config_tuic.sh @@ -38,7 +38,7 @@ create_tuic_acme_tls_config() { update_port # 设置密码 - update_password + update_password "$CONFIG_FILE" # 设置UUID update_uuid @@ -59,7 +59,7 @@ create_tuic_self_tls_config() { update_port # 设置密码 - update_password + update_password "$CONFIG_FILE" # 设置UUID update_uuid diff --git a/bin/password.sh b/bin/password.sh index f58886a..bdad227 100644 --- a/bin/password.sh +++ b/bin/password.sh @@ -2,30 +2,38 @@ # 更新密码的函数 update_password() { - local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 - local CONFIG_FILE="$SCRIPT_DIR/../config/config.json" - - + local CONFIG_FILE="${1}" + + if [[ -z "$CONFIG_FILE" ]]; then + echo "[Error] config_file配置文件路径 不能为空" + return 1 + fi + # 生成一个长度为16的随机密码 - local NEW_PASSWORD=$(gen_password 16) - + local NEW_PASSWORD + NEW_PASSWORD=$(gen_password 16) + # 修改密码 - sed -i 's/你的密码/'"$NEW_PASSWORD"'/g' $CONFIG_FILE - + sed -i 's/你的密码/'"$NEW_PASSWORD"'/g' "$CONFIG_FILE" + echo "设置密码成功" } # 更新混淆密码 update_obfs_password() { - local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 - local CONFIG_FILE="$SCRIPT_DIR/../config/config.json" - - + local CONFIG_FILE="${1}" + + if [[ -z "$CONFIG_FILE" ]]; then + echo "[Error] config_file配置文件路径 不能为空" + return 1 + fi + # 生成一个长度为16的随机密码 - local NEW_PASSWORD=$(gen_password 16) - + local NEW_PASSWORD + NEW_PASSWORD=$(gen_password 16) + # 修改密码 - sed -i 's/你的混淆密码/'"$NEW_PASSWORD"'/g' $CONFIG_FILE - + sed -i 's/你的混淆密码/'"$NEW_PASSWORD"'/g' "$CONFIG_FILE" + echo "设置密码成功" }