refactor: 添加检查jq安装和容器启动逻辑
This commit is contained in:
parent
cdc84896c8
commit
bb7409ceed
@ -1,18 +1,25 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# 检查 jq 命令是否可用
|
|
||||||
if ! command -v jq &> /dev/null
|
|
||||||
then
|
|
||||||
echo "jq 命令未安装,请先安装 jq。"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 获取脚本bin目录路径
|
# 获取脚本bin目录路径
|
||||||
script_dir=$(cd "$(dirname "$0")"; pwd)
|
script_dir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
|
||||||
# 读取配置文件内容
|
# 读取配置文件内容
|
||||||
config=$(cat "${script_dir}/../config.json")
|
config=$(cat "${script_dir}/../config.json")
|
||||||
|
|
||||||
|
source "${script_dir}/utils/base.sh"
|
||||||
|
|
||||||
|
# 检查jq是否安装
|
||||||
|
check_jq
|
||||||
|
|
||||||
|
# 检查是否已启动过容器
|
||||||
|
password=$(jq -r '.auth.password' $config_dir/config.json)
|
||||||
|
if [ "$password" = "你的密码" ]; then
|
||||||
|
red "error: 容器未启动过, 查看配置失败"
|
||||||
|
echo '请选择"启动容器"'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# 提取所需信息
|
# 提取所需信息
|
||||||
password=$(echo "$config" | jq -r '.auth.password')
|
password=$(echo "$config" | jq -r '.auth.password')
|
||||||
sni=$(echo "$config" | jq -r '.masquerade.proxy.url' | awk -F'/' '{print $3}')
|
sni=$(echo "$config" | jq -r '.masquerade.proxy.url' | awk -F'/' '{print $3}')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user