Ensure non-exactly named services are found

My naming scheme for my mailcown was like -mailcow_1_k8bdj9op so the script never found them. This ensures they do.
This commit is contained in:
hockeymikey 2019-09-07 12:33:54 -05:00 committed by GitHub
parent 3ddc2c5d4a
commit 25c6b407a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -230,23 +230,26 @@ function cleanup {
function operateDocker { function operateDocker {
# determine action to take # determine action to take
if [ "$1" = "stop" ]; then if [ "$1" = "stop" ]; then
rName="$(docker ps --format '{{.Names}}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)"
echo -e "${op}[$(stamp)] Stopping ${2}-mailcow container...${normal}" \ echo -e "${op}[$(stamp)] Stopping ${2}-mailcow container...${normal}" \
>> "$logFile" >> "$logFile"
docker-compose stop --timeout ${dockerStopTimeout} ${2}-mailcow \ docker-compose stop --timeout ${dockerStopTimeout} ${2}-mailcow \
2>> "$logFile" 2>> "$logFile"
# verify container stopped (should return true) # verify container stopped (should return true)
dockerResultState=$(docker inspect -f '{{ .State.Running }}' \ dockerResultState=$(docker inspect -f '{{ .State.Running }}' \
${COMPOSE_PROJECT_NAME}_${2}-mailcow_1) $rName)
# verify clean stop (exit code 0) # verify clean stop (exit code 0)
dockerResultExit=$(docker inspect -f '{{ .State.ExitCode }}' \ dockerResultExit=$(docker inspect -f '{{ .State.ExitCode }}' \
${COMPOSE_PROJECT_NAME}_${2}-mailcow_1) $rName)
elif [ "$1" = "start" ]; then elif [ "$1" = "start" ]; then
echo -e "${op}[$(stamp)] Starting ${2}-mailcow container...${normal}" \ echo -e "${op}[$(stamp)] Starting ${2}-mailcow container...${normal}" \
>> "$logFile" >> "$logFile"
docker-compose start ${2}-mailcow 2>> "$logFile" docker-compose start ${2}-mailcow 2>> "$logFile"
# verify # verify
rName="$(docker ps --format '{{.Names}}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)"
dockerResultState=$(docker inspect -f '{{ .State.Running }}' \ dockerResultState=$(docker inspect -f '{{ .State.Running }}' \
${COMPOSE_PROJECT_NAME}_${2}-mailcow_1) $rName)
fi fi
} }