优化逻辑

This commit is contained in:
Olia Lisa 2026-01-10 19:43:16 +08:00
parent 8f70ddc2ce
commit 3ef5c64c30

View File

@ -1,11 +1,17 @@
#!/bin/bash
restart_docker(){
# 如果docker容器没有启动, 则退出
restart_docker() {
local running_count=$(docker-compose -f ./docker-compose.yml ps -q | wc -l)
if [ "$running_count" -eq 0 ]; then
echo "容器未启动, 无需重启"
return
read -p "容器未启动,是否启动容器?(Y/N): " choice
case "$choice" in
Y|y)
;;
*)
echo "已取消启动"
return
;;
esac
fi
echo "正在重启容器..."
@ -13,7 +19,6 @@ restart_docker(){
docker-compose -f ./docker-compose.yml up -d
}
check_config(){
local config_dir="./conf"
# 如果配置文件不存在或者空白