43 lines
1.2 KiB
Bash
43 lines
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
|
|
run() {
|
|
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径
|
|
|
|
local config_dir=$(readlink -f "$script_dir/../config")
|
|
|
|
source "$script_dir/utils/base.sh"
|
|
|
|
# 检查jq是否安装
|
|
check_jq
|
|
|
|
# 检查bash是否安装
|
|
check_bash_installed
|
|
|
|
# 如果配置没有创建
|
|
local config_file="$config_dir/config.json"
|
|
if [ ! -e "$config_file" ]; then
|
|
touch "$config_file"
|
|
fi
|
|
local password=$(jq -r '.inbounds[0].users[0].password' "$config_file")
|
|
if [ ! -s "$config_file" ] || [ "$password" = "你的密码" ]; then
|
|
bash "$script_dir/create_config.sh" # 创建配置
|
|
fi
|
|
|
|
# 检查容器是否已启动,如果启动则先关闭
|
|
local compose_file="$script_dir/../docker-compose.yml"
|
|
if docker-compose -f "$compose_file" ps | grep -q "Up"; then
|
|
echo "检测到容器正在运行,正在关闭容器..."
|
|
docker-compose -f "$compose_file" down
|
|
echo "容器已关闭"
|
|
fi
|
|
|
|
# 启动docker容器
|
|
docker-compose -f "$script_dir/../docker-compose.yml" up -d
|
|
|
|
# 打印分享链接
|
|
bash "$script_dir/print_share_link.sh"
|
|
}
|
|
|
|
run # 启动容器
|