From: Michael Prokop Date: Thu, 4 Jun 2015 12:59:45 +0000 (+0200) Subject: Run code for --remove-configs before unmounting chroot X-Git-Tag: v0.71~11 X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=commitdiff_plain;h=9d9ec2d4cee334ce5b378fb880a2c58c57e4f6e7;ds=sidebyside Run code for --remove-configs before unmounting chroot Otherwise the mountpoint won't be there anymore. Also check whether the mountpoint exists before trying to delete anything. Fixes #66 @ github --- diff --git a/grml-debootstrap b/grml-debootstrap index b013ec2..a8a67dd 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -245,12 +245,6 @@ cleanup() { einfo "Removing ${STAGES}" ; rmdir "$STAGES" ; eend $? fi - if [ "$REMOVE_CONFIGS" = "yes" ] ; then - einfo "Removing configuration files from installed system as requested via --remove-configs / REMOVE_CONFIGS." - rm -rf "${MNTPOINT}"/etc/debootstrap/ - eend $? - fi - # Remove temporary mountpoint again if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then rmdir "$MNTPOINT" 2>/dev/null @@ -1566,10 +1560,27 @@ fscktool() { } # }}} +# get rid of grml-debootstrap config files {{{ +remove_configs() { + if [ "$REMOVE_CONFIGS" != "yes" ] ; then + return 0 + fi + + if ! mountpoint "${MNTPOINT}" ; then + ewarn "Target ${MNTPOINT} doesn't seem to be mounted, can't remove configuration files." ; eend 0 + return 0 + fi + + einfo "Removing configuration files from installed system as requested via --remove-configs / REMOVE_CONFIGS." + rm -rf "${MNTPOINT}"/etc/debootstrap/ + eend $? +} +# }}} + # now execute all the functions {{{ for i in prepare_vm mkfs tunefs mount_target debootstrap_system \ preparechroot execute_pre_scripts chrootscript execute_post_scripts \ - umount_chroot finalize_vm fscktool ; do + remove_configs umount_chroot finalize_vm fscktool ; do if stage "${i}" ; then if "$i" ; then stage "${i}" 'done' && rm -f "${STAGES}/${i}"