diff --git a/bin/create_config_hysteria.sh b/bin/create_config_hysteria.sh index cddc7b1..6ef3a13 100644 --- a/bin/create_config_hysteria.sh +++ b/bin/create_config_hysteria.sh @@ -2,8 +2,7 @@ create_hysteria_config(){ - local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 - local CONFIG_FILE="$SCRIPT_DIR/../config/config.json" + local CONFIG_DIR="${1}" # 配置文件目录 echo "请选择配置类型:" echo "1. Hysteria 自签名证书配置" @@ -13,11 +12,11 @@ create_hysteria_config(){ case $CHOICE in 1) echo "重置为hysteria自签名证书配置..." - create_hysteria_self_tls_config + create_hysteria_self_tls_config $CONFIG_DIR ;; 2) echo "重置为hysteria acme tls证书配置..." - create_hysteria_acme_tls_config + create_hysteria_acme_tls_config $CONFIG_DIR ;; *) echo "无效的选择, 请重新选择." @@ -26,8 +25,7 @@ create_hysteria_config(){ } create_hysteria_self_tls_config() { - local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 - local CONFIG_DIR="$SCRIPT_DIR/../config" + local CONFIG_DIR="${1}" # 配置文件目录 local CONFIG_FILE="$CONFIG_DIR/config.json" cp "$CONFIG_DIR/template/hysteria/hysteria_self_tls_config.json" "$CONFIG_FILE" @@ -48,8 +46,7 @@ create_hysteria_self_tls_config() { } create_hysteria_acme_tls_config() { - local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 - local CONFIG_DIR="$SCRIPT_DIR/../config" + local CONFIG_DIR="${1}" # 配置文件目录 local CONFIG_FILE="$CONFIG_DIR/config.json" cp "$CONFIG_DIR/template/hysteria/hysteria_acme_tls_config.json" "$CONFIG_FILE" diff --git a/bin/create_config_tuic.sh b/bin/create_config_tuic.sh index b188dfd..79f255a 100644 --- a/bin/create_config_tuic.sh +++ b/bin/create_config_tuic.sh @@ -2,8 +2,7 @@ create_tuic_config(){ - local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 - local CONFIG_FILE="$SCRIPT_DIR/../config/config.json" + local CONFIG_DIR="${1}" # 配置文件目录 echo "请选择配置类型:" echo "1. Tuic 自签名证书配置" @@ -13,11 +12,11 @@ create_tuic_config(){ case $CHOICE in 1) echo "重置为 tuic 自签名证书配置..." - create_tuic_self_tls_config + create_tuic_self_tls_config $CONFIG_DIR ;; 2) echo "重置为 tuic acme tls证书配置..." - create_tuic_acme_tls_config + create_tuic_acme_tls_config $CONFIG_DIR ;; *) echo "无效的选择, 请重新选择." @@ -26,8 +25,7 @@ create_tuic_config(){ } create_tuic_acme_tls_config() { - local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 - local CONFIG_DIR="$SCRIPT_DIR/../config" + local CONFIG_DIR="${1}" # 配置文件目录 local CONFIG_FILE="$CONFIG_DIR/config.json" cp "$CONFIG_DIR/template/tuic/tuic_acme_tls_config.json" "$CONFIG_FILE" @@ -47,8 +45,7 @@ create_tuic_acme_tls_config() { } create_tuic_self_tls_config() { - local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 - local CONFIG_DIR="$SCRIPT_DIR/../config" + local CONFIG_DIR="${1}" local CONFIG_FILE="$CONFIG_DIR/config.json" cp "$CONFIG_DIR/template/tuic/tuic_self_tls_config.json" "$CONFIG_FILE" diff --git a/install.sh b/install.sh index 3937322..4007d5d 100644 --- a/install.sh +++ b/install.sh @@ -103,7 +103,8 @@ check_config_file(){ # 创建配置文件 create_config(){ local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/bin" # 脚本文件夹绝对路径 - local CONFIG_FILE="$SCRIPT_DIR/../config/config.json" + local CONFIG_DIR="$SCRIPT_DIR/../config" + local CONFIG_FILE="$CONFIG_DIR/config.json" # 如果配置文件已存在,提示用户是否重新生成 if [ -e "$CONFIG_FILE" ]; then @@ -122,10 +123,10 @@ create_config(){ read -p "输入您的选择: " CHOICE case $CHOICE in 1) - create_tuic_config + create_tuic_config $CONFIG_DIR ;; 2) - create_hysteria_config + create_hysteria_config $CONFIG_DIR ;; *) echo "无效的选择, 请重新选择."