chiark / gitweb /
hacky LP bug support
[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 if [ "$SSH_AUTH_SOCK" ]; then
22         maybe_umount "$(dirname "$SSH_AUTH_SOCK")"
23 fi
24 maybe_umount /tmp/.ICE-unix
25 maybe_umount /tmp/.X11-unix
26 maybe_umount /dev/pts
27 maybe_umount /dev
28 maybe_umount /sys
29 maybe_umount /proc