diff --git a/common.sh b/common.sh index d7529b6..2933947 100644 --- a/common.sh +++ b/common.sh @@ -121,12 +121,19 @@ resolve_remote_ip() { RUNNING_CONTAINERS=() stop_containers() { - [[ ${#CRITICAL_CONTAINER_NAMES[@]} -eq 0 ]] && return + + if [[ ${#CRITICAL_CONTAINER_NAMES[@]} -eq 0 ]]; then + log "No containers defined to stop" + return + fi info "Stopping containers..." RUNNING_CONTAINERS=() for c in "${CRITICAL_CONTAINER_NAMES[@]}"; do + + log "Checking container: $c" + STATUS=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \ "docker inspect -f '{{.State.Running}}' $c 2>/dev/null" || echo "false") @@ -134,12 +141,18 @@ stop_containers() { warn "Stopping $c" RUNNING_CONTAINERS+=("$c") ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" "docker stop $c" + else + log "$c already stopped" fi done } start_containers() { - [[ ${#RUNNING_CONTAINERS[@]} -eq 0 ]] && return + + if [[ ${#RUNNING_CONTAINERS[@]} -eq 0 ]]; then + log "No containers to restart" + return + fi info "Starting containers..."