76 lines
1.9 KiB
Bash
76 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
create_reality_config(){
|
|
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
local config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径
|
|
cp "$config_dir/template/reality_config.json" "$config_dir/config.json"
|
|
|
|
# 生成uui, 写入到config.json文件
|
|
update_uuid
|
|
|
|
# 生成密钥对, 修改config.json中的密钥属性
|
|
update_key
|
|
|
|
# 设置端口
|
|
update_port
|
|
|
|
# 设置realty_dest目标域名
|
|
update_reality_dest
|
|
|
|
green "成功创建配置"
|
|
}
|
|
|
|
create_xhttp_reality_config(){
|
|
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件绝对路径
|
|
|
|
local config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径
|
|
cp "$config_dir/template/xhttp_reality_config.json" "$config_dir/config.json"
|
|
|
|
# 生成uui, 写入到config.json文件
|
|
update_uuid
|
|
|
|
# 生成密钥对, 修改config.json中的密钥属性
|
|
update_key
|
|
|
|
# 生成xhttp_path, 写入到config.json文件
|
|
update_xhttp_path
|
|
|
|
# 设置realty_dest目标域名
|
|
update_reality_dest
|
|
|
|
# 设置端口
|
|
update_port
|
|
|
|
green "成功创建配置"
|
|
}
|
|
|
|
|
|
|
|
create_config(){
|
|
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件绝对路径
|
|
# 检查jq是否安装
|
|
check_jq
|
|
|
|
local config_file="$script_dir/../conf/config.json" # 配置文件绝对路径
|
|
# 如果配置文件已存在, 询问是否重新生成
|
|
if [ -e "$config_file" ]; then
|
|
local regenerate
|
|
read -p "检测到配置已存在,是否重新生成配置?(y/n): " regenerate
|
|
if [ "$regenerate" != "y" ] && [ "$regenerate" != "Y" ]; then
|
|
echo "取消重新生成配置."
|
|
return
|
|
fi
|
|
fi
|
|
|
|
echo "请选择配置文件类型:"
|
|
echo "1. 创建reality配置"
|
|
echo "2. 创建xhttp_reality配置"
|
|
read -p "请输入选择 (1 或 2): " choice
|
|
case $choice in
|
|
1) create_reality_config ;;
|
|
2) create_xhttp_reality_config ;;
|
|
*) echo "无效选择,退出" ;;
|
|
esac
|
|
}
|