chiark / gitweb /
my-debmirror: drop d-i images
[bin.git] / chroot-teardown
1 #! /bin/sh
2 set +e # intentional
3
4 ROOT="${1:-/chroot/sid}"
5
6 is_mountpoint () {
7         grep -q "^[^ ]* $1 " /proc/mounts
8 }
9
10 maybe_umount () {
11         if is_mountpoint "$ROOT/${1#/}"; then
12                 sudo umount "$ROOT/${1#/}"
13         fi
14 }
15
16 maybe_umount /home/cjwatson/src
17 maybe_umount /home/cjwatson/.keychain
18 if [ "$GPG_AGENT_INFO" ]; then
19         maybe_umount "$(dirname "$GPG_AGENT_INFO")"
20 fi
21 maybe_umount /home/cjwatson/.ssh/control
22 if [ "$SSH_AUTH_SOCK" ]; then
23         maybe_umount "$(dirname "$SSH_AUTH_SOCK")"
24 fi
25 maybe_umount /tmp/.ICE-unix
26 maybe_umount /tmp/.X11-unix
27 maybe_umount /dev/pts
28 maybe_umount /dev
29 maybe_umount /sys
30 maybe_umount /proc