修改文件名

This commit is contained in:
Olia Lisa
2026-05-19 10:44:29 +08:00
parent aa5bcdd5b7
commit 3b00c2719f
4 changed files with 0 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
# 修改域名
update_domain(){
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径
local config_file="$script_dir/../config/config.json"
# 检查jq是否安装
check_jq
# 获取旧的domain
local old_domain=$(jq -r ".inbounds[0].tls.server_name" "$config_file")
# 输入新的domain
local domain
read -p "请输入域名[当前域名: $old_domain]: " domain
# 如果输入为空,退出脚本
if [[ -z "$domain" ]]; then
echo "输入域名为空,退出脚本"
exit 1
fi
# 修改server_name
modify_json_file "$config_file" ".inbounds[0].tls.server_name" "$domain"
# 是否存在acme域名, 存在则修改
local acme_exists=$(jq -r 'has("inbounds") and (.inbounds[0] | has("tls")) and (.inbounds[0].tls | has("acme"))' "$config_file")
if [[ "$acme_exists" == "true" ]]; then
modify_json_file "$config_file" ".inbounds[0].tls.acme.domain[0]" "$domain"
fi
echo "修改域名成功"
}