fix(cleanup): prevent doDocker error loop

- if doDocker throws an error, cleanup is called which again calls doDocker
- resolve this loop by passing a variable from cleanup
This commit is contained in:
Asif Bacchus 2022-07-12 12:47:52 -06:00
parent bd36035a9f
commit 5382dd26d9
1 changed files with 3 additions and 3 deletions

View File

@ -98,14 +98,14 @@ cleanup() {
printf "%s[%s] -- [INFO] POSTFIX container is running --%s\n" \
"$cyan" "$(stamp)" "$norm" >>"$logFile"
else
exitError 102 'Could not start POSTFIX container.'
exitError 102 'Could not start POSTFIX container.' 'final'
fi
doDocker start dovecot
if [ "$dockerResultState" = "true" ]; then
printf "%s[%s] -- [INFO] DOVECOT container is running --%s\n" \
"$cyan" "$(stamp)" "$norm" >>"$logFile"
else
exitError 102 'Could not start DOVECOT container.'
exitError 102 'Could not start DOVECOT container.' 'final'
fi
}
@ -133,7 +133,7 @@ doDocker() {
exitError() {
printf "%s[%s] -- [ERROR] %s: %s --%s\n" \
"$err" "$(stamp)" "$1" "$2" "$norm" >>"$logFile"
cleanup
if [ ! "$3" = "final" ]; then cleanup; fi
# note script completion with error
printf "%s[%s] --- %s execution completed with error ---%s\n" \
"$err" "$(stamp)" "$scriptName" "$norm" >>"$logFile"