refactor: 修改脚本引用文件并添加错误提示

This commit is contained in:
Olia Lisa 2025-02-08 21:36:55 +08:00
parent 27e9871c8b
commit 0cab56158a
3 changed files with 16 additions and 2 deletions

View File

@ -2,7 +2,7 @@
script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
source "$script_dir/utils/package_manager.sh"
source "$script_dir/utils/base.sh"
# 检查jq是否安装
check_jq

View File

@ -1,11 +1,20 @@
#!/bin/bash
script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径
source "$script_dir/utils/package_manager.sh"
source "$script_dir/utils/base.sh"
# 检查jq是否安装
check_jq
# 检查是否已启动过容器
uuid=$(jq -r '.inbounds[0].settings.clients[0].id' $config_dir/config.json)
if [ "$uuid" = "你的UUID" ]; then
red "error: 容器未启动过, 查看配置失败"
echo '请选择"启动容器"'
exit 1
fi
# 获取本机IP
ipv4=$(curl -4 -sSL --connect-timeout 3 --retry 2 ip.sb || echo "null")

View File

@ -1,5 +1,10 @@
#!/bin/bash
red(){
echo -e "\033[31m$1\033[0m"
}
# 获取系统包管理器
get_package_manager(){
if command -v apt-get &> /dev/null; then