Initialize the CLEANUP array and trap in common.sh
authorGuido Trotter <ultrotter@google.com>
Wed, 25 Feb 2009 16:05:43 +0000 (16:05 +0000)
committerGuido Trotter <ultrotter@google.com>
Sat, 3 Oct 2009 22:38:53 +0000 (23:38 +0100)
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 <ultrotter@google.com>
Reviewed-by: Olivier Tharan <olive@google.com>

common.sh.in
create
export
import
rename

index 130201f..0ee4ef5 100644 (file)
@@ -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 (executable)
--- 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 (executable)
--- 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 (executable)
--- 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 (executable)
--- a/rename
+++ b/rename
@@ -21,10 +21,6 @@ set -e
 
 . common.sh
 
-CLEANUP=( )
-
-trap cleanup EXIT
-
 TMPDIR=`mktemp -d` || exit 1
 CLEANUP+=("rmdir $TMPDIR")