hysteria_docker/bin/run.sh
Olia Lisa c91e4935c3 fix: enhance config file checks to prevent errors on missing or empty files
Add checks using `-s` flag to verify config.json existence and non-emptiness before processing passwords,
avoiding potential script failures when the file is absent or zero-length, improving robustness.
2025-11-20 19:04:15 +08:00

29 lines
717 B
Bash

#!/bin/bash
run() {
local script_dir=$(cd "$(dirname "$0")"; pwd)
local config_dir=$(readlink -f "$script_dir/../")
source "$script_dir/utils/base.sh"
# 检查jq是否安装
check_jq
# 检查bash是否安装
check_bash_installed
# 如果配置没有创建
local password=$(jq -r '.auth.password' "$config_dir/config.json")
if [ ! -s "$config_dir/config.json" ] || [ "$password" = "你的密码" ]; then
bash "$script_dir/create_config.sh" # 创建配置
fi
# 启动docker容器
docker-compose -f "$config_dir/docker-compose.yml" up -d
# 打印分享链接
bash "$script_dir/print_share_link.sh"
}
run # 启动容器