From 544eb665b8b5f9fa6f10fc7c6d9afa331a3327f4 Mon Sep 17 00:00:00 2001 From: Kiolow Date: Sun, 15 Dec 2024 21:02:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=AF=E5=8A=A8=E8=84=9A?= =?UTF-8?q?=E6=9C=AC,=20=E5=88=9D=E5=A7=8B=E5=8C=96=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E6=89=93=E5=8D=B0=E5=88=86=E4=BA=AB=E9=93=BE?= =?UTF-8?q?=E6=8E=A5,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/init.sh | 17 ++++++++++++----- bin/run.sh | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 bin/run.sh 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