add func doDocker

This commit is contained in:
Asif Bacchus 2020-05-06 23:32:53 -06:00
parent 4fb6315643
commit 9d7b7e1a94
2 changed files with 37 additions and 1 deletions

View File

@ -1,3 +1,19 @@
{
"bookmarks": []
"bookmarks": [
{
"fsPath": "$ROOTPATH$/backup/backup.sh",
"bookmarks": [
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
580
]
}
]
}

View File

@ -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" \