From ebb08909c987e9f859eeced9fd0f58173df5d208 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 11 Mar 2014 17:01:11 +0100 Subject: [cleanup.inc] added traps for SIGINT and SIGTERM Upon SIGINT and SIGTERM, cleanexit is called. At the moment, checks for mounts done by chroot and tries to umount them. TODO: make the cleanup modular instead of writing the stuff directly inside cleanexit. A-la 'cleanup.d' for example. --- remote/includes/cleanup.inc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 remote/includes/cleanup.inc diff --git a/remote/includes/cleanup.inc b/remote/includes/cleanup.inc new file mode 100644 index 00000000..144d7fd9 --- /dev/null +++ b/remote/includes/cleanup.inc @@ -0,0 +1,29 @@ +# ----------------------------------------------------------------------------- +# +# Copyright (c) 2014 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# +# Trapped cleanup functions +# +# ----------------------------------------------------------------------------- + +# run 'cleanexit' when CTRL-c is pressed, an abrupt program termination or exit happens +trap cleanexit SIGINT SIGTERM + +# main cleaner function +cleanexit() { + pinfo "SIGINT/SIGTERM triggered - cleaning up ..." + # unmount and remove the temporary chroot stuff + chroot_cleanup_mounts + + # TODO vmware etc/vmware/config stuff here, if it is still needed + +} -- cgit v1.2.3-55-g7522