From 99e53a16807762bff6075f6967c1463c7ed712f2 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Thu, 20 Nov 2025 12:32:36 +0800 Subject: [PATCH] update --- bin/init_with_tls_cert.sh | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/bin/init_with_tls_cert.sh b/bin/init_with_tls_cert.sh index 1fbd320..cdaad33 100644 --- a/bin/init_with_tls_cert.sh +++ b/bin/init_with_tls_cert.sh @@ -16,7 +16,39 @@ init_with_tls_cert() { # 设置混淆密码 bash "$script_dir/update_obfs_password.sh" - echo "[提示] 请自行设置域名和cloudflare_api_token" + # 获取邮箱 + read -p "请输入你的邮箱: " user_email + while [[ -z "$user_email" ]]; do + echo "[错误] 邮箱不能为空" + read -p "请输入你的邮箱: " user_email + done + + # 获取域名 + read -p "请输入你的域名 (例如: example.com): " user_domain + while [[ -z "$user_domain" ]]; do + echo "[错误] 域名不能为空" + read -p "请输入你的域名: " user_domain + done + + # 获取 Cloudflare API Token + read -p "请输入你的 Cloudflare API Token: " cloudflare_token + while [[ -z "$cloudflare_token" ]]; do + echo "[错误] Cloudflare API Token 不能为空" + read -p "请输入你的 Cloudflare API Token: " cloudflare_token + done + + # 替换配置文件中的占位符 + local config_file="$script_dir/../config.json" + + # 使用 sed 替换邮箱 + sed -i "s/你的邮箱/$user_email/g" "$config_file" + + # 替换域名 (在 domains 数组和 masquerade url 中) + sed -i "s/你的域名/$user_domain/g" "$config_file" + + # 替换 Cloudflare API Token + sed -i "s/你的cloudflare_api_token/$cloudflare_token/g" "$config_file" + echo "初始化设置完成" }