Compare commits
3 Commits
3ddc2c5d4a
...
b371e18ab0
Author | SHA1 | Date | |
---|---|---|---|
|
b371e18ab0 | ||
|
fb8091ecce | ||
|
25c6b407a6 |
@ -230,23 +230,26 @@ function cleanup {
|
||||
function operateDocker {
|
||||
# determine action to take
|
||||
if [ "$1" = "stop" ]; then
|
||||
containerName="$(docker ps --format '{{.Names}}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)"
|
||||
|
||||
echo -e "${op}[$(stamp)] Stopping ${2}-mailcow container...${normal}" \
|
||||
>> "$logFile"
|
||||
docker-compose stop --timeout ${dockerStopTimeout} ${2}-mailcow \
|
||||
2>> "$logFile"
|
||||
# verify container stopped (should return true)
|
||||
dockerResultState=$(docker inspect -f '{{ .State.Running }}' \
|
||||
${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)
|
||||
$containerName)
|
||||
# verify clean stop (exit code 0)
|
||||
dockerResultExit=$(docker inspect -f '{{ .State.ExitCode }}' \
|
||||
${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)
|
||||
$containerName)
|
||||
elif [ "$1" = "start" ]; then
|
||||
echo -e "${op}[$(stamp)] Starting ${2}-mailcow container...${normal}" \
|
||||
>> "$logFile"
|
||||
docker-compose start ${2}-mailcow 2>> "$logFile"
|
||||
# verify
|
||||
containerName="$(docker ps --format '{{.Names}}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)"
|
||||
dockerResultState=$(docker inspect -f '{{ .State.Running }}' \
|
||||
${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)
|
||||
$containerName)
|
||||
fi
|
||||
}
|
||||
|
||||
@ -257,7 +260,7 @@ fi
|
||||
|
||||
# store the logfile in the same directory as this script using the script's name
|
||||
# with the extension .log
|
||||
scriptPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
scriptPath="$( cd "$( dicontainerName "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
scriptName="$( basename ${0} )"
|
||||
logFile="$scriptPath/${scriptName%.*}.log"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user