]> git.wh0rd.org - home.git/commitdiff
add umount-tree helper
authorMike Frysinger <vapier@gentoo.org>
Tue, 14 Feb 2012 21:22:35 +0000 (16:22 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 28 Apr 2012 19:36:43 +0000 (15:36 -0400)
.bin/umount-tree [new file with mode: 0755]

diff --git a/.bin/umount-tree b/.bin/umount-tree
new file mode 100755 (executable)
index 0000000..bcf866f
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+root=$1
+if [[ -z $1 ]] ; then
+       echo "Usage: $0 <root>"
+       exit 1
+fi
+
+mounts=$(mount | grep " on ${root%/}/" | awk '{print $3}' | tac)
+if [[ -z ${mounts} ]] ; then
+       echo "No mounts found ..."
+       echo
+       mount
+       exit 0
+fi
+
+echo "Unmounting: "
+printf '\t%s\n' ${mounts}
+
+printf "OK? [y/N] "
+read v
+[[ ${v} == "y" ]] && sudo umount -v ${mounts}