From 055dba2152e6e5050b3081c477cb19ef693d3c09 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sat, 20 Oct 2018 05:23:43 -0600 Subject: [PATCH] created function operateDocker for container start and stop --- root/scripts/backup.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/root/scripts/backup.sh b/root/scripts/backup.sh index 3209830..a6b3b2a 100644 --- a/root/scripts/backup.sh +++ b/root/scripts/backup.sh @@ -179,6 +179,23 @@ function cleanup { fi } +### operate docker containers +function operateDocker { +# determine action to take +if [ "$1" = "stop" ]; then + echo -e "${op}${stamp} Stopping ${2}-mailcow container...${normal}" \ + >> "$logFile" + docker-compose stop --timeout ${dockerStopTimeout} ${2}-mailcow \ + >> "$logFile" + dockerResult=$(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" + docker-compose start ${2}-mailcow >> "$logFile" + dockerResult=$(docker inspect -f '{{ .State.Running }}' ${COMPOSE_PROJECT_NAME}_${2}-mailcow_1) +fi +} + ### End of Functions ###