add func doDocker
This commit is contained in:
@@ -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" \
|
||||
|
||||
Reference in New Issue
Block a user