From: Guido Trotter Date: Wed, 25 Feb 2009 16:05:43 +0000 (+0000) Subject: Initialize the CLEANUP array and trap in common.sh X-Git-Tag: v0.8~6 X-Git-Url: http://git.equinoxoli.org/?p=ext%2Finstance-debootstrap.git;a=commitdiff_plain;h=731ea255ce4850b59ebcecdda6b6c4acb56b7c2a Initialize the CLEANUP array and trap in common.sh All the scripts have to inizialize this and set the cleanup trap, so we're doing it for them in common.sh. Signed-off-by: Guido Trotter Reviewed-by: Olivier Tharan --- diff --git a/common.sh.in b/common.sh.in index 130201f..0ee4ef5 100644 --- a/common.sh.in +++ b/common.sh.in @@ -17,6 +17,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. +CLEANUP=( ) log_error() { echo "$@" >&2 @@ -127,6 +128,8 @@ cleanup() { fi } +trap cleanup EXIT + DEFAULT_FILE="@sysconfdir@/default/ganeti-instance-debootstrap" if [ -f "$DEFAULT_FILE" ]; then . "$DEFAULT_FILE" diff --git a/create b/create index da25b0e..5933f0b 100755 --- a/create +++ b/create @@ -21,10 +21,6 @@ set -e . common.sh -CLEANUP=( ) - -trap cleanup EXIT - if [ "$GENERATE_CACHE" = "yes" -a ! -d "$CACHE_DIR" ]; then mkdir -p "$CACHE_DIR" fi diff --git a/export b/export index 82254bc..b127754 100755 --- a/export +++ b/export @@ -21,10 +21,6 @@ set -e . common.sh -CLEANUP=( ) - -trap cleanup EXIT - # If the target device is not a real block device we'll first losetup it. # This is needed for file disks. if [ ! -b $blockdev ]; then diff --git a/import b/import index cd42430..0d95450 100755 --- a/import +++ b/import @@ -21,10 +21,6 @@ set -e . common.sh -CLEANUP=( ) - -trap cleanup EXIT - # If the target device is not a real block device we'll first losetup it. # This is needed for file disks. if [ ! -b $blockdev ]; then diff --git a/rename b/rename index a49d2fa..652d6b7 100755 --- a/rename +++ b/rename @@ -21,10 +21,6 @@ set -e . common.sh -CLEANUP=( ) - -trap cleanup EXIT - TMPDIR=`mktemp -d` || exit 1 CLEANUP+=("rmdir $TMPDIR")