]> git.wh0rd.org - home.git/blob - .bin/umount-tree
ignore more stuff
[home.git] / .bin / umount-tree
1 #!/bin/bash
2
3 if [[ -z $1 ]] ; then
4 echo "Usage: $0 <root>"
5 exit 1
6 fi
7
8 while [[ $# -gt 0 ]] ; do
9
10 root=$1
11 shift
12
13 mounts=$(gawk -v p="${root%/}" '$2 ~ "^"p { print $2 }' /proc/mounts | tac)
14 if [[ -z ${mounts} ]] ; then
15 echo "No mounts found ..."
16 echo
17 mount
18 continue
19 fi
20
21 echo "Unmounting: "
22 printf '\t%s\n' ${mounts}
23
24 printf "OK? [y/N] "
25 read v
26 [[ ${v} == "y" ]] && sudo umount -v ${mounts}
27
28 done