summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remote/includes/chroot.inc14
1 files changed, 9 insertions, 5 deletions
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
}