stop postfix and dovecot and error check

This commit is contained in:
Asif Bacchus 2018-10-20 04:30:25 -06:00
parent a72a8ac450
commit 5076cebc85

View File

@ -455,12 +455,34 @@ fi
cd "$mailcowPath" cd "$mailcowPath"
### Stop postfix and dovecot so mailflow is stopped until backup is completed ### Stop postfix and dovecot so mailflow is stopped until backup is completed
echo -e "${op}${stamp} Stopping postfix and dovecot containers now..." \ ## Stop postfix-mailcow container
"${normal}" >> "$logFile" echo -e "${op}${stamp} Stopping postfix-mailcow container...${normal}" \
docker-compose stop --timeout ${dockerStopTimeout} 2>> "$logFile" >> "$logFile"
# docker-compose always returns an error code of 0, so there is no point in docker-compose stop --timeout ${dockerStopTimeout} postfix-mailcow >> "$logFile"
# error checking # verify stop was successful
echo -e "${op}${stamp} ...done (verify in docker logs)${normal}" >> "$logFile" dockerResult=$(docker inspect -f '{{ .State.ExitCode }}' ${COMPOSE_PROJECT_NAME}_postfix-mailcow_1
if [ "$dockerResult" -eq 0 ]; then
echo -e "${info}${stamp} -- [INFO] Postfix container stopped --${normal}" \
>> "$logFile"
else
exitError+=('101')
cleanup
quit
fi
## Stop dovecot-mailcow container
echo -e "${op}${stamp} Stopping dovecot-mailcow container...${normal}" \
>> "$logFile"
docker-compose stop --timeout ${dockerStopTimeout} dovecot-mailcow >> "$logFile"
# verify stop was successful
dockerResult=$(docker inspect -f '{{ .State.ExitCode }}' ${COMPOSE_PROJECT_NAME}_dovecot-mailcow_1
if [ "$dockerResult" -eq 0 ]; then
echo -e "${info}${stamp} -- [INFO] Dovecot container stopped --${normal}" \
>> "$logFile"
else
exitError+=('102')
cleanup
quit
fi
### Dump SQL ### Dump SQL