trap calls dedicated func

This commit is contained in:
Asif Bacchus 2019-06-18 22:30:22 -06:00
parent 91f0cdfa8e
commit 1144eb6ae6

View File

@ -16,7 +16,7 @@ magenta=$(tput setaf 5)
### trap
trap cleanup 1 2 3 6
trap trapExit 1 2 3 6
### functions
@ -129,6 +129,16 @@ stamp () {
(date +%F" "%T)
}
trapExit () {
printf "${err}[%s] -- [ERROR] 99: Caught signal --${norm}\n" \
"$(stamp)" >> "$logFile"
cleanup
# note script completion with error
printf "${err}[%s] --- %s execution was terminated via signal ---${norm}\n" \
"$(stamp)" "$scriptName" >> "$logFile"
exit "$1"
}
### end of functions
@ -664,6 +674,7 @@ exit 0
# 1: parameter error
# 2: not run as root
# 3: borg not installed
# 99: TERM signal trapped
# 100: could not start seafile service
# 101: could not start seahub service
# 102: could not stop seafile service