diff --git a/bin/init.sh b/bin/init.sh index b474039..534bf98 100644 --- a/bin/init.sh +++ b/bin/init.sh @@ -2,8 +2,18 @@ # 检查 jq 是否安装 if ! command -v jq &> /dev/null; then - echo "jq 未安装" - exit 1 + echo "jq 未安装, 安装 jq" + + # 如果是ubuntu系统安装jq + if [ -f /etc/lsb-release ]; then + sudo apt-get update + sudo apt-get install -y jq + fi + + # 如果是centos系统安装jq + if [ -f /etc/redhat-release ]; then + sudo yum install -y jq + fi fi script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 @@ -13,6 +23,3 @@ bash $script_dir/update_uuid.sh # 生成密钥对, 修改config.json中的密钥属性 bash $script_dir/update_key.sh - -# 打印分享链接 -bash $script_dir/print_share_link.sh diff --git a/bin/run.sh b/bin/run.sh new file mode 100644 index 0000000..6bebdf8 --- /dev/null +++ b/bin/run.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 +config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径 + +uuid=$(jq -r '.inbounds[0].settings.clients[0].id' $config_dir/config.json) + +# 如果配置未初始化 +if [ $uuid = "你的UUID" ]; then + # 执行初始化脚本 + bash $script_dir/init.sh +fi + +## 启动docker容器 +docker-compose up -d -f $script_dir/../docker-compose.yml + +# 打印分享链接 +bash $script_dir/print_share_link.sh