Index: src/scripts/common.sh |
diff --git a/src/scripts/common.sh b/src/scripts/common.sh |
index c5ae10413238823a0ce78a38a855839bc14455e9..f0e139504e5069d1e9ef3dc837ab63d7ac779773 100644 |
--- a/src/scripts/common.sh |
+++ b/src/scripts/common.sh |
@@ -337,3 +337,18 @@ function sudo_clobber() { |
function sudo_append() { |
sudo tee -a "$1" > /dev/null |
} |
+ |
+# Unmounts a directory, if the unmount fails, warn, and then lazily unmount. |
+# |
+# $1 - The path to unmount. |
+function safe_umount { |
+ path=${1:?} |
+ shift |
+ |
+ if ! sudo umount -d "${path}"; then |
+ warn "Failed to unmount ${path}" |
+ warn "Doing a lazy unmount" |
+ |
+ sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}" |
+ fi |
+} |