grml2iso: drop $WRKDIR if it did not exist before execution
[grml2usb.git] / grml2iso
index c323e1e..23b693d 100755 (executable)
--- a/grml2iso
+++ b/grml2iso
@@ -6,7 +6,9 @@
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2 or any later version.
 ################################################################################
-# TODO: support isolinux as bootloader on the ISO
+# TODO:
+# * support isolinux as bootloader on the ISO
+# * support setting grml2usb options (e.g. --bootoptions=...)
 ################################################################################
 
 # define function getfilesize before "set -e" {{{
@@ -76,6 +78,7 @@
 # }}}
 
 # create necessary stuff under WRKDIR {{{
+  [ -d "$WRKDIR" ] && WRKDIR_EXISTED='true' || WRKDIR_EXISTED='false'
   rm -rf "$WRKDIR/cddir" "$WRKDIR/grub_tmp"
   mkdir -p "$WRKDIR/cddir" "$WRKDIR/grub_tmp"
 # }}}}
   cd "$ORIG_DIR"
   sync
   rm -rf "$WRKDIR/cddir" "$WRKDIR/grub_tmp"
+  [[ $WRKDIR_EXISTED = 'false' ]] && rmdir "$WRKDIR"
   echo "Generated $ISOFILE"
 # }}}