}
function cleanup_abort {
- scottyinfo "No cleanup_abort function was defined."
-}
-
-function _cleanup_abort {
scottyerror "Caught exit signal! Cleaning up..."
- cleanup_abort
+ cleanup ABORT
if [ $(jobs -p) ]; then
scottyerror TERMinating remaining child processes...
kill $(jobs -p)
fi
+
deleteLock
+
exit
}
}
function cleanup_normal {
- scottyinfo "No cleanup_normal function was defined."
+ cleanup
+ deleteLock
}
function printhelp {
exit 0
fi
- trap _cleanup_abort EXIT
+ trap cleanup_abort EXIT
prepare
scottysync
- cleanup_normal
- trap deleteLock EXIT
+ trap cleanup_normal EXIT
exit 0
}
function prepare {
echo "prepare"
+ sleep 5
}
-function cleanup_normal {
- echo "cleanup"
-}
-
-function cleanup_abort {
- echo "cleanup_abort"
+function cleanup {
+ [ -z "$1" ] && echo "normal cleanup" || echo "abort cleanup"
}
backmeupscotty $@