From 3bc908c72c4eb3403adfce776d46e119679801be Mon Sep 17 00:00:00 2001 From: Christian Rößler Date: Fri, 4 Apr 2014 17:55:17 +0200 Subject: [chroot.inc] Check whether anything chroot-related is mounted before trying to unmount --- remote/includes/chroot.inc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'remote/includes') diff --git a/remote/includes/chroot.inc b/remote/includes/chroot.inc index 48ad39d3..2e0eabfe 100644 --- a/remote/includes/chroot.inc +++ b/remote/includes/chroot.inc @@ -202,9 +202,13 @@ chroot_umount() { # Helper to cleanup the temporary mounts chroot_cleanup_mounts() { - for DIR in $CHROOT_BINDMOUNTS; do - chroot_umount "${CHROOT_MOUNTDIR}/${DIR}" - done - chroot_umount "${CHROOT_MOUNTDIR}" - chroot_umount "${CHROOT_BINDDIR}" + if [[ "$(mount | grep -c $CHROOT_TEMPDIR)" -gt 0 ]]; then # No point in unmounting then... + for DIR in $CHROOT_BINDMOUNTS; do + chroot_umount "${CHROOT_MOUNTDIR}/${DIR}" + done + chroot_umount "${CHROOT_MOUNTDIR}" + chroot_umount "${CHROOT_BINDDIR}" + else + pinfo "Nothing chroot-related is mounted - exiting." + fi } -- cgit v1.2.3-55-g7522