+++ /dev/null
-#!/bin/sh
-#Close a mounted chroot; this means killing all the chroot apps and unmounting the bound directories.
-
-# By Alan M Bruce (qole)
-#
-# GPL licensed; keep code free!
-
-if [ "`whoami`" != "root" ] ; then
- echo "please run me as root!"
- exit 9
-fi
-
-#Try to get the chroot location from the first parameter
-CHROOT=$1
-
-#Try to get the chroot location from the config file...
-if [ "x$CHROOT" = x ] ; then
- #Pull in the config, if possible...
- [ -f /home/user/.chroot ] && . /home/user/.chroot
- #Still not set? Set to default
- [ "x$CHROOT" != x ] || CHROOT=/debian
-fi
-
-# Strip off a trailing slash
-LASTCHAR=`echo $CHROOT | cut -c ${#CHROOT}`
-if [ "$LASTCHAR" = "/" ] ; then
- echo "..stripping trailing slash..." >/dev/stderr
- CHROOT=`echo $CHROOT | cut -c 0-$((${#CHROOT}-1))`
-fi
-
-#Abort if chroot not mounted.
-if [ ! -f "$CHROOT/var/lock/qmount-complete" ] ; then
- echo "Nothing to do; chroot not mounted!"
- exit 1
-fi
-
-echo "Closing the chroot..."
-
-# Fremantle's fuser command is broken.
-# We can either use Debian's one instead (as gfuser),
-# or we can use the workaround: "cd /proc" first.
-
-echo "...closing chroot apps..."
-
-TEST1=`mount | grep " $CHROOT "`
-if [ "x$TEST1" != "x" ] ; then
- if [ -f "/bin/gfuser" ] ; then
- gfuser -m "$CHROOT" -k
- else
- cd /proc
- fuser -m "$CHROOT" -k
- fi
-else
- if [ -f "/bin/gfuser" ] ; then
- gfuser "$CHROOT" -k
- else
- cd /proc
- fuser "$CHROOT" -k
- fi
-fi
-
-echo "..Unmounting bound dirs..."
-
-#Any external mounts
-
-umount -fl $CHROOT/home/user/MyDocs
-umount -fl $CHROOT/dev/pts
-umount -fl $CHROOT/dev/shm
-
-MNTD=`cat /proc/mounts | grep " $CHROOT/" | awk '{print $2}'`
-for MDRV in $MNTD ; do
- echo "unmounting $MDRV"
- umount -l "$MDRV"
-done
-
-if [ -f "$CHROOT/var/lock/qmount-complete" ] ; then
- rm "$CHROOT/var/lock/qmount-complete"
-fi
-
-if [ -f "$CHROOT/var/lock/chroot-complete" ] ; then
- rm "$CHROOT/var/lock/chroot-complete"
-fi
-
-/sbin/qumount $CHROOT
-
-echo "chroot closed."
-exit 0
\ No newline at end of file