This commit is contained in:
Olia Lisa
2026-05-23 10:13:28 +08:00
parent b88d670967
commit 900378b8ec
+19 -13
View File
@@ -18,13 +18,12 @@ create_self_tls_file() {
} }
update_self_tls(){ update_self_tls(){
local CONFIG_FILE="${1:-}" local CONFIG_FILE="${1}"
local DOMAIN="${2:-bing.com}" # 域名,默认为bing.com local DOMAIN="${2}" # 域名
if [[ -z "$CONFIG_FILE" ]]; then if [[ -z "$CONFIG_FILE" ]]; then
local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 echo "[Error] config_file配置文件路径 不能为空"
local CONFIG_DIR=$(readlink -f "$SCRIPT_DIR/../config") return 1
CONFIG_FILE="$CONFIG_DIR/config.json"
fi fi
# 生成自签名证书, 设置域名 # 生成自签名证书, 设置域名
@@ -33,19 +32,18 @@ update_self_tls(){
} }
update_acme_tls(){ update_acme_tls(){
local CONFIG_FILE="${1:-}" local CONFIG_FILE="${1}"
if [[ -z "$CONFIG_FILE" ]]; then if [[ -z "$CONFIG_FILE" ]]; then
local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 echo "[Error] config_file配置文件路径 不能为空"
local CONFIG_DIR=$(readlink -f "$SCRIPT_DIR/../config") return 1
CONFIG_FILE="$CONFIG_DIR/config.json"
fi fi
# 获取邮箱 # 获取邮箱
local USER_EMAIL local USER_EMAIL
read -p "请输入你的邮箱: " USER_EMAIL read -p "请输入你的邮箱: " USER_EMAIL
while [[ -z "$USER_EMAIL" ]]; do while [[ -z "$USER_EMAIL" ]]; do
echo "[错误] 邮箱不能为空" echo "[Error] 邮箱不能为空"
read -p "请输入你的邮箱: " USER_EMAIL read -p "请输入你的邮箱: " USER_EMAIL
done done
@@ -53,7 +51,7 @@ update_acme_tls(){
local USER_DOMAIN local USER_DOMAIN
read -p "请输入你的域名 (例如: example.com): " USER_DOMAIN read -p "请输入你的域名 (例如: example.com): " USER_DOMAIN
while [[ -z "$USER_DOMAIN" ]]; do while [[ -z "$USER_DOMAIN" ]]; do
echo "[错误] 域名不能为空" echo "[Error] 域名不能为空"
read -p "请输入你的域名: " USER_DOMAIN read -p "请输入你的域名: " USER_DOMAIN
done done
@@ -61,7 +59,7 @@ update_acme_tls(){
local CLOUDFLARE_TOKEN local CLOUDFLARE_TOKEN
read -p "请输入你的 Cloudflare API Token: " CLOUDFLARE_TOKEN read -p "请输入你的 Cloudflare API Token: " CLOUDFLARE_TOKEN
while [[ -z "$CLOUDFLARE_TOKEN" ]]; do while [[ -z "$CLOUDFLARE_TOKEN" ]]; do
echo "[错误] Cloudflare API Token 不能为空" echo "[Error] Cloudflare API Token 不能为空"
read -p "请输入你的 Cloudflare API Token: " CLOUDFLARE_TOKEN read -p "请输入你的 Cloudflare API Token: " CLOUDFLARE_TOKEN
done done
@@ -74,11 +72,19 @@ update_acme_tls(){
update_acme_domain(){ update_acme_domain(){
local CONFIG_FILE="${1}" # 配置文件 local CONFIG_FILE="${1}" # 配置文件
local DOMAIN="${2}" # 域名 local DOMAIN="${2}" # 域名
if [[ -z "$CONFIG_FILE" ]]; then
echo "[Error] config_file配置文件路径 不能为空"
return 1
fi
modify_json_file "$CONFIG_FILE" ".inbounds[0].tls.acme.domain[0]" "$DOMAIN" modify_json_file "$CONFIG_FILE" ".inbounds[0].tls.acme.domain[0]" "$DOMAIN"
} }
update_server_name(){ update_server_name(){
local CONFIG_FILE="${1}" # 配置文件 local CONFIG_FILE="${1}" # 配置文件
local DOMAIN="${2}" # 域名 local DOMAIN="${2}" # 域名
if [[ -z "$CONFIG_FILE" ]]; then
echo "[Error] config_file配置文件路径 不能为空"
return 1
fi
modify_json_file "$CONFIG_FILE" ".inbounds[0].tls.server_name" "$DOMAIN" modify_json_file "$CONFIG_FILE" ".inbounds[0].tls.server_name" "$DOMAIN"
} }