Add clean_up function. Trap signals SIGHUP SIGINT SIGTERM
This commit is contained in:
parent
24ba503a6f
commit
b3761600fa
14
check_vpn.sh
14
check_vpn.sh
@ -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
|
||||
|
||||
#---------------------------------------
|
||||
#-----------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user