重构代码, 迁移函数

This commit is contained in:
Olia Lisa
2026-05-21 19:12:55 +08:00
parent 8fda1e330e
commit 58a84340f1
2 changed files with 17 additions and 18 deletions
+17
View File
@@ -85,6 +85,23 @@ ask_update_domain(){
echo "修改域名成功"
}
# 检查配置文件
check_config_file(){
local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[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格式, 请重新生成配置文件."
exit 1
fi
}
main(){
local container_status=$(check_container_status)