View Single Post
pichlo's Avatar
Posts: 6,453 | Thanked: 20,983 times | Joined on Sep 2012 @ UK
#2911
Well, as I said, I later realized that I did not need to edit that much but that was only on editing my third script when I found out about using 'none'. I started off by using IMGFILE=/path/to/my/chroot/dir and leaving CHROOT alone. That required editing qmount to add a case for a directory which I later reverted.

However, valdur55's post did not cure the "Nothing to do" problem, I had to edit closechroot thus:
Code:
pp900-a:/sbin# diff closechroot closechroot.old
--- closechroot
+++ closechroot.old
@@ -29,7 +29,7 @@
 fi
 
 #Abort if chroot not mounted.
-if [ "$IMGFILE" != "none" ] && [ ! -f "$CHROOT/var/lock/qmount-complete" ] ; then
+if [ ! -f "$CHROOT/var/lock/qmount-complete" ] ; then
   echo "Nothing to do; chroot not mounted!"
   exit 1
 fi
@@ -58,11 +58,22 @@
 
 echo "...closing chroot apps..."
 
-if [ -f "/bin/gfuser" ] ; then
-  gfuser "$CHROOT" -k
+TEST1=`mount | grep " $CHROOT "`
+MAPPER=`mount | grep "/dev/mapper"`
+if [ "x$TEST1" != "x" ] && [ "x$MAPPER" == "x" ] ; then
+  if [ -f "/bin/gfuser" ] ; then
+    gfuser -m "$CHROOT" -k
+  else
+    cd /proc
+    fuser -m "$CHROOT" -k
+  fi
 else
-  cd /proc
-  fuser "$CHROOT" -k
+  if [ -f "/bin/gfuser" ] ; then
+    gfuser "$CHROOT" -k
+  else
+    cd /proc
+    fuser "$CHROOT" -k
+  fi
 fi
 
 echo "..Unmounting bound dirs..."
@@ -87,9 +98,7 @@
   rm "$CHROOT/var/lock/chroot-complete"
 fi
 
-if [ "$IMGFILE" != "none" ] ; then
-  /sbin/qumount $CHROOT
-fi
+/sbin/qumount $CHROOT
 
 echo "chroot closed."
 exit 0
\ No newline at end of file
pp900-a:/sbin#
Basically, adding a test for $IMGFILE!=none in two places and removing -m in the call to fuser as it was causing aforementioned issues.

I have also edited qchroot to alter some mounts but that is just my preference and I am not suggesting that it should be in any way taken seriously. I just did not think ED needed to know about my entire /home tree (which would include ED recursively). Mounting user's home dir ought to be enough for everybody
Code:
pp900-a:/sbin# diff qchroot qchroot.old 
--- qchroot
+++ qchroot.old
@@ -76,10 +76,10 @@
 
   #Mount the user's home dir
   echo .... >/dev/stderr
-  mount -o bind /home/user "$CHROOT/home/user"
+  #mount -o bind /home/user "$CHROOT/home/user"
 
   # Do it the Fremantle way.
-  #mount /dev/mmcblk0p2 "$CHROOT/home"
+  mount /dev/mmcblk0p2 "$CHROOT/home"
   mount /dev/mmcblk0p1 "$CHROOT/home/user/MyDocs"
   
   #Make DBus work
pp900-a:/sbin#
 

The Following 2 Users Say Thank You to pichlo For This Useful Post: