hysteria_docker/bin/update_domain.sh

37 lines
883 B
Bash

#!/bin/bash
source "$(dirname "$0")/utils/base.sh"
source "$(dirname "$0")/utils/jq_util.sh"
# 修改域名
update_domain(){
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径
local config_file="$script_dir/../config/config.json"
# 检查jq是否安装
check_jq
# 输入新的domain
local domain
read -p "请输入新的域名: " domain
# 如果输入为空,退出脚本
if [[ -z "$domain" ]]; then
echo "输入域名为空,退出脚本"
exit 1
fi
modify_json_file "$config_file" ".masquerade.proxy.url" "https://$domain"
# 是否存在acme域名, 存在则修改
local acme_exists=$(jq -r 'has("acem")' "$config_file")
if [[ "$acme_exists" == "true" ]]; then
modify_json_file "$config_file" ".acme.domains[0]" "$domain"
fi
echo "修改域名成功"
}
update_domain