更新 hy2.sh

This commit is contained in:
2026-03-19 15:39:51 +08:00
parent daa3ae854f
commit 1a9c6bece4

11
hy2.sh
View File

@@ -24,6 +24,10 @@ require_cmd() {
} }
} }
random_subdomain_prefix() {
openssl rand -hex 8 | cut -c1-8
}
prompt_nonempty() { prompt_nonempty() {
local prompt="$1" local prompt="$1"
local value="" local value=""
@@ -444,7 +448,12 @@ main() {
email="$(prompt_nonempty '请输入 ACME 邮箱: ')" email="$(prompt_nonempty '请输入 ACME 邮箱: ')"
zone="$(prompt_nonempty '请输入 Cloudflare Zone例如 example.com: ')" zone="$(prompt_nonempty '请输入 Cloudflare Zone例如 example.com: ')"
subdomain="$(prompt_nonempty '请输入要创建的子域名前缀(例如 hy2: ')"
default_subdomain="$(random_subdomain_prefix)"
read -r -p "请输入要创建的子域名前缀(例如 hy2直接回车使用默认值 ${default_subdomain}: " subdomain
subdomain="${subdomain:-$default_subdomain}"
subdomain="$(printf '%s' "$subdomain" | tr 'A-Z' 'a-z' | tr -cd 'a-z0-9-')"
CF_API_TOKEN="$(prompt_nonempty '请输入 Cloudflare API Token: ')" CF_API_TOKEN="$(prompt_nonempty '请输入 Cloudflare API Token: ')"
export CF_API_TOKEN export CF_API_TOKEN