From e8061425cc25b989a82ea45655c8a336505b73f4 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Sun, 11 Jan 2026 12:02:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=20base.sh=20=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=A1=AE=E4=BF=9D=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=AD=98=E5=9C=A8=E4=B8=94=E4=B8=BA=E6=9C=89?= =?UTF-8?q?=E6=95=88=E7=9A=84=20JSON=20=E6=A0=BC=E5=BC=8F=EF=BC=9B?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=20install.sh=20=E4=B8=AD=E7=9A=84=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/utils/base.sh | 17 +++++++++++++++++ install.sh | 20 +------------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/bin/utils/base.sh b/bin/utils/base.sh index 9c57cff..995bfaf 100644 --- a/bin/utils/base.sh +++ b/bin/utils/base.sh @@ -126,3 +126,20 @@ check_bash_installed() { return 1 fi } + +check_config_file(){ + local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../" # 脚本文件夹绝对路径 + local config_file="$script_dir/../config/config.json" + + # 检查配置文件是否存在 + if [ ! -e "$config_file" ]; then + echo "配置文件不存在, 请先生成配置文件." + exit 1 + fi + + # 检查配置文件是否为有效的JSON格式 + if ! jq '.' "$config_file" >/dev/null 2>&1; then + echo "配置文件不是有效的JSON格式, 请重新生成配置文件." + exit 1 + fi +} \ No newline at end of file diff --git a/install.sh b/install.sh index daf34a9..b3d9e4c 100644 --- a/install.sh +++ b/install.sh @@ -30,24 +30,6 @@ install(){ } -check_config_file(){ - local script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录 - local config_file="$script_dir/../config/config.json" - - # 检查配置文件是否存在 - if [ ! -e "$config_file" ]; then - echo "配置文件不存在, 请先生成配置文件." - exit 1 - fi - - # 检查配置文件是否为有效的JSON格式 - if jq '.' "$config_file" >/dev/null 2>&1; then - echo "有效的JSON文件" - else - echo "无效的JSON文件" - fi -} - main(){ local script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录 source "${script_dir}/utils/base.sh" @@ -115,4 +97,4 @@ main(){ esac } -main \ No newline at end of file +main