summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Rößler2014-04-04 17:55:17 +0200
committerChristian Rößler2014-04-04 17:55:17 +0200
commit3bc908c72c4eb3403adfce776d46e119679801be (patch)
treec1d8eb572baaa202cacda87c57ab958076b19344
parent[cleanup.inc] Better trapping - trap me once, don't trap me twice (Please test!) (diff)
downloadtm-scripts-3bc908c72c4eb3403adfce776d46e119679801be.tar.gz
tm-scripts-3bc908c72c4eb3403adfce776d46e119679801be.tar.xz
tm-scripts-3bc908c72c4eb3403adfce776d46e119679801be.zip
[chroot.inc] Check whether anything chroot-related is mounted before trying to unmount
-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
}