created function operateDocker for container start and stop

This commit is contained in:
Asif Bacchus 2018-10-20 05:23:43 -06:00
parent 912f8c274a
commit 055dba2152

View File

@ -179,6 +179,23 @@ function cleanup {
fi
}
### operate docker containers
function operateDocker {
# 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 \
>> "$logFile"
dockerResult=$(docker inspect -f '{{ .State.ExitCode }}' ${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)
elif [ "$1" = "start" ]; then
echo -e "${op}${stamp} Starting ${2}-mailcow container...${normal}" \
>> "$logFile"
docker-compose start ${2}-mailcow >> "$logFile"
dockerResult=$(docker inspect -f '{{ .State.Running }}' ${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)
fi
}
### End of Functions ###