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