From 1144eb6ae64f3c3a7c8e666ee34395c86d9ed9ad Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Tue, 18 Jun 2019 22:30:22 -0600 Subject: [PATCH] trap calls dedicated func --- seafbackup.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/seafbackup.sh b/seafbackup.sh index cbb75ed..75852ce 100755 --- a/seafbackup.sh +++ b/seafbackup.sh @@ -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