]> git.wh0rd.org - home.git/blame - .bin/umount-tree
chroot: start bind mounting /run
[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
066558c0
MF
8prompt=true
9case $1 in
10-y) prompt=false; shift;;
11esac
12
b0a31048
MF
13while [[ $# -gt 0 ]] ; do
14
15root=$1
16shift
17
18mounts=$(gawk -v p="${root%/}" '$2 ~ "^"p { print $2 }' /proc/mounts | tac)
aaf997b4
MF
19if [[ -z ${mounts} ]] ; then
20 echo "No mounts found ..."
21 echo
22 mount
b0a31048 23 continue
aaf997b4
MF
24fi
25
26echo "Unmounting: "
27printf '\t%s\n' ${mounts}
28
066558c0
MF
29if ${prompt} ; then
30 printf "OK? [y/N] "
31 read v
32else
33 v=y
34fi
aaf997b4 35[[ ${v} == "y" ]] && sudo umount -v ${mounts}
b0a31048
MF
36
37done