]> git.wh0rd.org - home.git/blob - .bin/umount-tree
add umount-tree helper
[home.git] / .bin / umount-tree
1 #!/bin/bash
2
3 root=$1
4 if [[ -z $1 ]] ; then
5 echo "Usage: $0 <root>"
6 exit 1
7 fi
8
9 mounts=$(mount | grep " on ${root%/}/" | awk '{print $3}' | tac)
10 if [[ -z ${mounts} ]] ; then
11 echo "No mounts found ..."
12 echo
13 mount
14 exit 0
15 fi
16
17 echo "Unmounting: "
18 printf '\t%s\n' ${mounts}
19
20 printf "OK? [y/N] "
21 read v
22 [[ ${v} == "y" ]] && sudo umount -v ${mounts}