Add clean_up function. Trap signals SIGHUP SIGINT SIGTERM

This commit is contained in:
Christoph 2017-06-28 01:15:07 +02:00
parent 24ba503a6f
commit b3761600fa

View File

@ -27,14 +27,20 @@ LOCK_DIR=`mktemp -d`
#-----------------------------
#---------------------------------------
clean_up() {
# Perform program exit housekeeping
rm rf $LOCK_DIR
exit $1
}
fatal(){
echo ""
echo -e " [ Fatal ] $*"
echo ""
echo -e "\tScript terminated.."
echo ""
rm -rf $LOCK_DIR
exit 1
clean_up 1
}
error (){
@ -68,6 +74,10 @@ trim() {
echo -n "$var"
}
# - The trap command allows you to execute a command when a signal
# - is received by your script.
# -
trap clean_up SIGHUP SIGINT SIGTERM
#---------------------------------------
#-----------------------------