修改配置文件模板和配置文件位置
This commit is contained in:
parent
a404a704da
commit
542c7e8994
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
config.json
|
||||
config/config.json
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
create_config_with_tls_cert() {
|
||||
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
||||
|
||||
cp "$script_dir/../config_template/tls_cert_config.json" "$script_dir/../config.json"
|
||||
cp "$script_dir/../config/template/tls_cert_config.json" "$script_dir/../config/config.json"
|
||||
|
||||
# 设置端口
|
||||
bash "$script_dir/update_port.sh"
|
||||
@ -36,7 +36,7 @@ create_config_with_tls_cert() {
|
||||
done
|
||||
|
||||
# 替换配置文件中的占位符
|
||||
local config_file="$script_dir/../config.json"
|
||||
local config_file="$script_dir/../config/config.json"
|
||||
|
||||
# 使用 sed 替换邮箱
|
||||
sed -i "s/你的邮箱/$user_email/g" "$config_file"
|
||||
@ -53,7 +53,7 @@ create_config_with_tls_cert() {
|
||||
create_self_tls_config() {
|
||||
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
||||
|
||||
cp "$script_dir/../config_template/self_cert_config.json" "$script_dir/../config.json"
|
||||
cp "$script_dir/../config/template/self_cert_config.json" "$script_dir/../config/config.json"
|
||||
|
||||
# 设置端口
|
||||
bash "$script_dir/update_port.sh"
|
||||
@ -74,12 +74,12 @@ create_config(){
|
||||
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
||||
|
||||
# 如果配置文件不存在, 创建空白配置文件
|
||||
if [ ! -e "$script_dir/../config.json" ]; then
|
||||
touch "$script_dir/../config.json"
|
||||
if [ ! -e "$script_dir/../config/config.json" ]; then
|
||||
touch "$script_dir/../config/config.json"
|
||||
fi
|
||||
|
||||
local config_password=$(jq -r '.auth.password' "$script_dir/../config.json")
|
||||
if [ -s "$script_dir/../config.json" ] && [ "$config_password" != "你的密码" ]; then
|
||||
local config_password=$(jq -r '.auth.password' "$script_dir/../config/config.json")
|
||||
if [ -s "$script_dir/../config/config.json" ] && [ "$config_password" != "你的密码" ]; then
|
||||
local regenerate
|
||||
read -p "检测到配置已存在,是否重新生成配置?(y/n): " regenerate
|
||||
if [ "$regenerate" != "y" ] && [ "$regenerate" != "Y" ]; then
|
||||
@ -110,5 +110,3 @@ create_config(){
|
||||
|
||||
|
||||
create_config
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ gen_self_tls() {
|
||||
local domain="${1:-bing.com}"
|
||||
local script_dir="$(dirname "$(realpath "$0")")"
|
||||
local key_dir="$script_dir/../key"
|
||||
local config_file="$script_dir/../config.json"
|
||||
local config_file="$script_dir/../config/config.json"
|
||||
|
||||
# 导入utils文件夹中的jq_util.sh脚本
|
||||
source "$script_dir/utils/jq_util.sh"
|
||||
|
||||
@ -9,14 +9,14 @@ print_share_link() {
|
||||
check_jq
|
||||
|
||||
# 检查配置文件是否存在
|
||||
if [ ! -f "$config_dir/config.json" ]; then
|
||||
if [ ! -f "$config_dir/config/config.json" ]; then
|
||||
red "error: 配置文件未生成, 查看配置失败"
|
||||
echo '请选择"生成配置 / 重置配置"'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查是否已启动过容器
|
||||
local password=$(jq -r '.auth.password' "$config_dir/config.json")
|
||||
local password=$(jq -r '.auth.password' "$config_dir/config/config.json")
|
||||
if [ "$password" = "你的密码" ]; then
|
||||
red "error: 容器未启动过, 查看配置失败"
|
||||
echo '请选择"启动容器"'
|
||||
@ -25,12 +25,12 @@ print_share_link() {
|
||||
|
||||
# 检查是否使用ACME证书
|
||||
local allowInsecure=1 # 默认跳过证书验证
|
||||
if jq -e '.acme' "$config_dir/config.json" > /dev/null 2>&1; then
|
||||
if jq -e '.acme' "$config_dir/config/config.json" > /dev/null 2>&1; then
|
||||
allowInsecure=0 # 不跳过证书验证
|
||||
fi
|
||||
|
||||
# 读取配置文件内容
|
||||
local config=$(cat "$config_dir/config.json")
|
||||
local config=$(cat "$config_dir/config/config.json")
|
||||
|
||||
# 提取所需信息
|
||||
password=$(echo "$config" | jq -r '.auth.password')
|
||||
|
||||
@ -14,11 +14,11 @@ run() {
|
||||
check_bash_installed
|
||||
|
||||
# 如果配置没有创建
|
||||
if [ ! -e "$config_dir/config.json" ]; then
|
||||
touch "$config_dir/config.json"
|
||||
if [ ! -e "$config_dir/config/config.json" ]; then
|
||||
touch "$config_dir/config/config.json"
|
||||
fi
|
||||
local password=$(jq -r '.auth.password' "$config_dir/config.json")
|
||||
if [ ! -s "$config_dir/config.json" ] || [ "$password" = "你的密码" ]; then
|
||||
local password=$(jq -r '.auth.password' "$config_dir/config/config.json")
|
||||
if [ ! -s "$config_dir/config/config.json" ] || [ "$password" = "你的密码" ]; then
|
||||
bash "$script_dir/create_config.sh" # 创建配置
|
||||
fi
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# 更新密码的函数
|
||||
update_obfs_password() {
|
||||
local script_dir="$(dirname "$(realpath "$0")")"
|
||||
local config_file="$script_dir/../config.json"
|
||||
local config_file="$script_dir/../config/config.json"
|
||||
|
||||
# 加载工具脚本
|
||||
source "$script_dir/utils/jq_util.sh"
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# 更新密码的函数
|
||||
update_password() {
|
||||
local script_dir="$(dirname "$(realpath "$0")")"
|
||||
local config_file="$script_dir/../config.json"
|
||||
local config_file="$script_dir/../config/config.json"
|
||||
|
||||
# 加载工具脚本
|
||||
source "$script_dir/utils/jq_util.sh"
|
||||
|
||||
@ -50,7 +50,7 @@ change_port(){
|
||||
source "$script_dir/utils/jq_util.sh"
|
||||
|
||||
local port=$(find_free_port)
|
||||
modify_json_file "$config_dir/config.json" ".listen" ":$port"
|
||||
modify_json_file "$config_dir/config/config.json" ".listen" ":$port"
|
||||
echo "已分配新的空闲端口, 设置端口成功"
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ services:
|
||||
network_mode: "host"
|
||||
volumes:
|
||||
- acme:/acme
|
||||
- ./config.json:/etc/hysteria/config.json
|
||||
- ./config/config.json:/etc/hysteria/config.json
|
||||
- ./key/server.crt:/etc/hysteria/server.crt
|
||||
- ./key/server.key:/etc/hysteria/server.key
|
||||
command: ["server", "-c", "/etc/hysteria/config.json"]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user