summaryrefslogtreecommitdiffstats
path: root/core/includes/cleanup.inc
blob: 9716c84121990803196ad582b145dc6d4028a358 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -----------------------------------------------------------------------------
#
# 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
#
# -----------------------------------------------------------------------------

__init () {
	# run 'cleanexit' when CTRL-c is pressed, an abrupt program termination or exit happens
	trap cleanexit SIGINT SIGTERM
}

# main cleaner function
cleanexit() {
	trap '' SIGINT SIGTERM	# from now on, ignore INT and TERM
	unset_quiet		# needed to get trap functioning correctly
	pwarning "SIGINT/SIGTERM triggered - cleaning up ..."
	# unmount and remove the temporary chroot stuff
	pinfo "Calling chroot_cleanup_mounts ..."
	chroot_cleanup_mounts
	# TODO vmware etc/vmware/config stuff here, if it is still needed
	exit 1			# perhaps a better exit code?
}