Initialize the CLEANUP array and trap in common.sh
[ext/instance-debootstrap.git] / common.sh.in
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"