Compare commits

...

3 Commits

Author SHA1 Message Date
Asif Bacchus
b371e18ab0 'containerName' instead of 'rname' for consistency 2019-09-10 15:23:45 -06:00
Asif Bacchus
fb8091ecce
Merge pull request #1 from hockeymikey/master
Ensure non-exactly named services are found
2019-09-09 16:45:55 -06:00
hockeymikey
25c6b407a6
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.
2019-09-07 12:33:54 -05:00

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
containerName="$(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) $containerName)
# 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) $containerName)
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
containerName="$(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) $containerName)
fi fi
} }
@ -257,7 +260,7 @@ fi
# store the logfile in the same directory as this script using the script's name # store the logfile in the same directory as this script using the script's name
# with the extension .log # with the extension .log
scriptPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" scriptPath="$( cd "$( dicontainerName "${BASH_SOURCE[0]}" )" && pwd )"
scriptName="$( basename ${0} )" scriptName="$( basename ${0} )"
logFile="$scriptPath/${scriptName%.*}.log" logFile="$scriptPath/${scriptName%.*}.log"