From 9d7b7e1a9464341887b2bfb96a75683d1cfb2d18 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 6 May 2020 23:32:53 -0600 Subject: [PATCH] add func doDocker --- .vscode/numbered-bookmarks.json | 18 +++++++++++++++++- backup/backup.sh | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index 4c08963..db3a033 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -1,3 +1,19 @@ { - "bookmarks": [] + "bookmarks": [ + { + "fsPath": "$ROOTPATH$/backup/backup.sh", + "bookmarks": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 580 + ] + } + ] } \ No newline at end of file diff --git a/backup/backup.sh b/backup/backup.sh index b4fb821..35209e9 100644 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -97,6 +97,26 @@ cleanup() { fi } +doDocker() { + containerName="$( docker ps -a --format '{{ .Names }}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1 )" + + # determine action to take + if [ "$1" = "stop" ]; then + printf "%s[%s] -- [INFO] Stopping %s-mailcow container --%s\n" \ + "$cyan" "$(stamp)" "$2" "$norm" >> "$logFile" + docker-compose -f "$mcDockerCompose" stop --timeout "$dockerStopTimeout" "$2-mailcow" 2>> "$logFile" + # set result vars + dockerResultState="$( docker inspect -f '{{ .State.Running }}' $containerName )" + dockerResultExit="$( docker inspect -f '{{ .State.ExitCode }}' $containerName )" + elif [ "$1" = "start" ]; then + printf "%s[%s] -- [INFO] Starting %s-mailcow container --%s\n" \ + "$cyan" "$(stamp)" "$2" "$norm" >> "$logFile" + docker-compose -f "$mcDockerCompose" start "$2-mailcow" 2>> "$logFile" + # set result vars + dockerResultState="$( docker inspect -f '{{ .State.Running }}' $containerName )" + fi +} + # call cleanup and then exit with error report exitError() { printf "%s[%s] -- [ERROR] %s: %s --%s\n" \