X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=blobdiff_plain;f=grml-debootstrap;h=7a71239a898cd74029455c6f3586fc75793e83ef;hp=ffcb6aa2eefe8cbe34aec3c9c85cb4013a4a60f0;hb=ccba9a85a1ad2e6aa405987195c1230e8a28c783;hpb=8a4a3c89471607c4603550ecba326b2799cf137e diff --git a/grml-debootstrap b/grml-debootstrap index ffcb6aa..7a71239 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -1338,6 +1338,26 @@ execute_scripts() { } # }}} +try_umount() { + local tries=$1 + local mountpoint="$2" + + for (( try=1; try<=tries; try++ )); do + if [[ ${try} -eq ${tries} ]]; then + # Last time, show errors this time + umount "${mountpoint}" && return 0 + else + # Not last time, hide errors until fatal + if umount "${mountpoint}" 2>/dev/null ; then + return 0 + else + sleep 1 + fi + fi + done + return 1 # Tried enough +} + # execute chroot-script {{{ chrootscript() { if ! [ -r "$MNTPOINT/bin/chroot-script" ] ; then @@ -1355,7 +1375,7 @@ chrootscript() { else chroot "$MNTPOINT" /bin/chroot-script ; RC=$? fi - umount "$MNTPOINT"/dev + try_umount 3 "$MNTPOINT"/dev eend $RC fi