define containerName once

This commit is contained in:
Asif Bacchus 2019-09-10 17:22:43 -06:00
parent bbbdf38dcc
commit a26bb36f17
2 changed files with 19 additions and 39 deletions

View File

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

View File

@ -225,28 +225,24 @@ function cleanup {
### operate docker containers
function operateDocker {
# determine action to take
if [ "$1" = "stop" ]; then
containerName="$(docker ps --format '{{ .Names }}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)"
# 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 \
2>> "$logFile"
# verify container stopped (should return true)
dockerResultState=$(docker inspect -f '{{ .State.Running }}' \
$containerName)
dockerResultState="$(docker inspect -f '{{ .State.Running }}' $containerName)"
# verify clean stop (exit code 0)
dockerResultExit=$(docker inspect -f '{{ .State.ExitCode }}' \
$containerName)
dockerResultExit="$(docker inspect -f '{{ .State.ExitCode }}' $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 }}' \
$containerName)
dockerResultState="$(docker inspect -f '{{ .State.Running }}' $containerName)"
fi
}