2 #Close a mounted chroot; this means killing all the chroot apps and unmounting the bound directories.
4 # By Alan M Bruce (qole)
6 # GPL licensed; keep code free!
8 if [ "`whoami`" != "root" ] ; then
9 echo "please run me as root!"
13 #Try to get the chroot location from the first parameter
16 #Try to get the chroot location from the config file...
17 if [ "x$CHROOT" = x ] ; then
18 #Pull in the config, if possible...
19 [ -f /home/user/.chroot ] && . /home/user/.chroot
20 #Still not set? Set to default
21 [ "x$CHROOT" != x ] || CHROOT=/debian
24 #Abort if chroot not mounted.
25 if [ ! -f "$CHROOT/var/lock/qmount-complete" ] ; then
26 echo "Nothing to do; chroot not mounted!"
30 echo "Closing the chroot..."
32 # Fremantle's fuser command is broken.
33 # Using Debian's one instead.
35 echo "...closing chroot apps..."
37 TEST1=`mount | grep " $CHROOT "`
38 if [ "x$TEST1" != "x" ] ; then
39 if [ -f "/bin/gfuser" ] ; then
40 gfuser -m "$CHROOT" -k
45 if [ -f "/bin/gfuser" ] ; then
52 echo "..Unmounting bound dirs..."
56 umount -fl $CHROOT/home/user/MyDocs
57 umount -fl $CHROOT/dev/pts
58 umount -fl $CHROOT/dev/shm
60 MNTD=`cat /proc/mounts | grep " $CHROOT/" | awk '{print $2}'`
61 for MDRV in $MNTD ; do
62 echo "unmounting $MDRV"
66 if [ -f "$CHROOT/var/lock/qmount-complete" ] ; then
67 rm "$CHROOT/var/lock/qmount-complete"
70 if [ -f "$CHROOT/var/lock/chroot-complete" ] ; then
71 rm "$CHROOT/var/lock/chroot-complete"