From c03eecc1d30f227035d75ba27c0541014c5568f1 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 25 Oct 2018 04:22:57 -0600 Subject: [PATCH] added check for container stop AND exit code in fcn operateDocker stop --- root/scripts/backup.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/root/scripts/backup.sh b/root/scripts/backup.sh index 7e599ee..359458a 100644 --- a/root/scripts/backup.sh +++ b/root/scripts/backup.sh @@ -221,8 +221,12 @@ if [ "$1" = "stop" ]; then >> "$logFile" docker-compose stop --timeout ${dockerStopTimeout} ${2}-mailcow \ 2>> "$logFile" - # verify - dockerResult=$(docker inspect -f '{{ .State.ExitCode }}' ${COMPOSE_PROJECT_NAME}_${2}-mailcow_1) + # verify container stopped (should return true) + dockerResultStop1=$(docker inspect -f '{{ .State.Running }}' \ + ${COMPOSE_PROJECT_NAME}_${2}-mailcow_1) + # verify clean stop (exit code 0) + dockerResultStop2=$(docker inspect -f '{{ .State.ExitCode }}' \ + ${COMPOSE_PROJECT_NAME}_${2}-mailcow_1) elif [ "$1" = "start" ]; then echo -e "${op}${stamp} Starting ${2}-mailcow container...${normal}" \ >> "$logFile"