# Sets up (if necessary) and chroots into a different environment.
# Expects root privileges, does not drop them.
-# By Alan M Bruce (qole) with help from Benson Mitchell
+# By Alan M Bruce (qole) with help from Benson Mitchell and Thomas Perl
#
# GPL licensed; keep code free!
if [ "$MOUNTSUCCESS" = "0" ] ; then
#Make the tablet's devices available to the chroot
- echo .
+ echo . >/dev/stderr
mount -o bind /dev "$CHROOT/dev"
mount -o bind /proc "$CHROOT/proc"
#Gentoo wiki says this will make X work
- echo ..
+ echo .. >/dev/stderr
mount -t devpts none "$CHROOT/dev/pts"
mount -o bind /tmp "$CHROOT/tmp"
mount -o bind /var/tmp "$CHROOT/var/tmp"
#Any external devices
- echo ...
+ echo ... >/dev/stderr
MNTD=`cat /proc/mounts | grep ' /media/' | awk '{print $2}'`
for MDRV in $MNTD ; do
done
#Mount the user's home dir
- echo ....
+ echo .... >/dev/stderr
#mount -o bind /home/user "$CHROOT/home/user"
# Do it the Fremantle way.
if [ "x$CHRLABEL" = "x" ] ; then
CHRLABEL=chroot
fi
-echo -ne "\033]0;$CHRLABEL\007"
+echo -ne "\033]0;$CHRLABEL\007" >/dev/stderr
export PS1="[\u@$CHRLABEL: \w]"
#Actually chroot
-echo "Everything set up, running chroot..."
+echo "Everything set up, running chroot..." >/dev/stderr
chroot $CHROOT "$@"
#All done, reset.
# Sets up (if necessary) and chroots into a different environment.
# Expects root privileges, does not drop them.
-# By Alan M Bruce (qole) with help from Benson Mitchell
+# By Alan M Bruce (qole) with help from Benson Mitchell and Thomas Perl
#
# GPL licensed; keep code free!
IMGFILE=$1
MNTPT=$2
-echo qmount $IMGFILE $MNTPT
+# echo qmount $IMGFILE $MNTPT
#Ensure that we have an image or partition to mount
if [ ! -f "$IMGFILE" ] && [ ! -b "$IMGFILE" ] ; then
MSG1=`printf "ERROR!\n\nThe image specified ($IMGFILE) does not exist or is neither\na regular nor a block special file.\n\nFirst parameter must be an image file or partition"`
if [ ! -f "/usr/bin/gxmessage" ] ; then
- echo $MSG1
+ echo $MSG1 >/dev/stderr
else
gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "EZ-CHROOT ERROR" "$MSG1"
fi
if [ "x$MNTPT" = "x" ] || [ "x`echo $MNTPT | grep '/'`" = "x" ] ; then
MSG1=`printf "ERROR!\n\nNo chroot directory specified!\n\nSecond parameter must be chroot dir (eg. /debian)"`
if [ ! -f "/usr/bin/gxmessage" ] ; then
- echo $MSG1
+ echo $MSG1 >/dev/stderr
else
gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "EZ-CHROOT ERROR" "$MSG1"
fi
#Check to see if already mounted
if [ -f "$MNTPT/var/lock/qmount-complete" ] ; then
- echo "$MNTPT has a qmount already!"
+ echo "$MNTPT has a qmount already!" >/dev/stderr
MTDIMGFILE=`cat $MNTPT/var/lock/qmount-complete`
if [ "$IMGFILE" != "$MTDIMGFILE" ] ; then
- echo $MTDIMGFILE already mounted here!
+ echo $MTDIMGFILE already mounted here! >/dev/stderr
MSG1=`printf "Mount problem!\n\n$MTDIMGFILE already mounted on $MNTPT"`
if [ ! -f "/usr/bin/gxmessage" ] ; then
- echo $MSG1
+ echo $MSG1 >/dev/stderr
else
gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "EZ-CHROOT ERROR" "$MSG1"
fi
# echo Unmounting...
# closechroot $MNTPT
else
- echo $MTDIMGFILE already mounted on $MNTPT...
+ echo $MTDIMGFILE already mounted on $MNTPT... >/dev/stderr
exit 1
fi
fi
if [ -f "$IMGFILE" ] ; then
LOOP=loop,
- echo "using image file: $IMGFILE"
+ echo "using image file: $IMGFILE" >/dev/stderr
if [ "x$IMGFS" = x ] ; then
IMGFS=`echo $IMGFILE | awk -F '.' '{print $NF}'`
- echo "fs type is $IMGFS"
+ echo "fs type is $IMGFS" >/dev/stderr
fi
else
LOOP=
- echo "using device: $IMGFILE"
+ echo "using device: $IMGFILE" >/dev/stderr
PARTINFO="`blkid -s TYPE $IMGFILE`"
if [ "x$IMGFS" = x ] ; then
IMGFS=`echo $PARTINFO | awk '{print $NF}' | awk -F '=' '{print $NF}' | sed s/\"//g`
modprobe mbcache
if [ "$IMGFS" != "ext3" ] && [ "$IMGFS" != "ext2" ] ; then
- echo "Don't know $IMGFS: Using ext2 file system"
+ echo "Don't know $IMGFS: Using ext2 file system" >/dev/stderr
IMGFS=ext2
fi
if [ "$LOOP" = "loop," ] ; then
#echo "mounting $IMGFILE on the turbo-loop ;)"
- echo "mounting $IMGFILE on the slow Fremantle-loop ;)"
+ echo "mounting $IMGFILE on the slow Fremantle-loop ;)" >/dev/stderr
#insmod /lib/modules/2.6.21-omap1/dm-mod.ko 2>/dev/null
#insmod /lib/modules/2.6.21-omap1/dm-loop.ko 2>/dev/null
#NEXTLOOP=`ls -l /dev/dm-* 2>/dev/null | tail -1 | awk '{print $NF}' | awk -F '-' '{print $NF+1}'`
if [ "$?" != 0 ] ; then
MSG1=`printf "Mount failure!\n\n$IMGFILE failed to mount on loop$NEXTLOOP\n\n$DMLOMSG\n$MNTMSG"`
if [ ! -f "/usr/bin/gxmessage" ] ; then
- echo $MSG1
+ echo $MSG1 >/dev/stderr
else
gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "EZ-CHROOT ERROR" "$MSG1"
fi
exit 2
fi
- echo ...$IMGFILE mounted on loop$NEXTLOOP
+ echo ...$IMGFILE mounted on loop$NEXTLOOP >/dev/stderr
else
- echo "mounting device: $IMGFILE"
+ echo "mounting device: $IMGFILE" >/dev/stderr
if ! mount -t "$IMGFS" "$IMGFILE" "$MNTPT" -o ${LOOP}noatime ; then
MSG1=`printf "Mount failure!\n\n$IMGFILE failed to mount on $MNTPT"`
if [ ! -f "/usr/bin/gxmessage" ] ; then
- echo $MSG1
+ echo $MSG1 >/dev/stderr
else
gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "EZ-CHROOT ERROR" "$MSG1"
fi
fi
else
- echo "Not mounting any filesystem, chroot is $MNTPT"
+ echo "Not mounting any filesystem, chroot is $MNTPT" >/dev/stderr
fi
#All set up. Set flag for next time...
MNTPT=$CHROOT
#Still not set? FAIL
if [ "x$MNTPT" != x ] ; then
- echo "No mountpoint to unmount!"
+ echo "No mountpoint to unmount!" >/dev/stderr
exit 8
fi
fi
TEST1=`mount | grep " $MNTPT "`
if [ "x$TEST1" != "x" ] ; then
- echo "..Unmounting $MNTPT..."
+ echo "..Unmounting $MNTPT..." >/dev/stderr
umount -ld "$MNTPT"
TEST2=`mount | grep " $MNTPT "`
if [ "x$TEST2" != "x" ] ; then
- echo "...$MNTPT didn't unmount!"
+ echo "...$MNTPT didn't unmount!" >/dev/stderr
exit 8
fi
else
- echo "$MNTPT is not mounted; Check for trailing slashes."
+ echo "$MNTPT is not mounted; Check for trailing slashes." >/dev/stderr
fi
if [ ! "x`grep device-mapper /proc/misc`" = "x" ] ; then
LOOPDEV=`echo $TEST1 | cut -f1 -d' '`
while [ "x`echo $LOOPDEV | grep dm-`" != "x" ] ; do
LOOPNO=`echo $LOOPDEV | awk -F '-' '{print $NF}'`
- echo "..Unmounting turbo loop ($LOOPNO)..."
+ echo "..Unmounting turbo loop ($LOOPNO)..." >/dev/stderr
dmlosetup -d /dev/loop$LOOPNO
if [ "$?" != 0 ] || [ "x`dmsetup status | grep loop$LOOPNO`" != "x" ] ; then
- echo "Waiting for apps to terminate, will try again."
+ echo "Waiting for apps to terminate, will try again." >/dev/stderr
sleep 5
dmlosetup -d /dev/loop$LOOPNO
if [ "$?" != 0 ] ; then
- echo "Can't unmount turbo-loop! Try dmlosetup -d /dev/loop$LOOPNO manually."
+ echo "Can't unmount turbo-loop! Try dmlosetup -d /dev/loop$LOOPNO manually." >/dev/stderr
exit 9
fi
fi
done
fi
-echo "successful unmount..."
-exit 0
\ No newline at end of file
+echo "successful unmount..." >/dev/stderr
+exit 0
+++ /dev/null
-[Desktop Entry]
-Encoding=UTF-8
-Name=Set CPU to On-Demand mode
-GenericName=CPU On-Demand mode
-Exec=sudo /sbin/cpu-ondemand
-Icon=qgn_list_cp_memory
-X-Osso-Type=application/x-executable
-X-HildonDesk-ShowInToolbar=true
-Terminal=false
-Type=Application
-StartupNotify=true
\ No newline at end of file
+++ /dev/null
-[Desktop Entry]
-Encoding=UTF-8
-Name=Set CPU to Performance mode
-GenericName=CPU Performance mode
-Exec=sudo /sbin/cpu-perform
-Icon=qgn_list_cp_memory
-X-Osso-Type=application/x-executable
-X-HildonDesk-ShowInToolbar=true
-Terminal=false
-Type=Application
-StartupNotify=true
\ No newline at end of file
# Expects root privileges, does not drop them.
# Look to /usr/bin/debbie for a friendly wrapper.
-# By Alan M Bruce (qole) with help from Benson Mitchell
+# By Alan M Bruce (qole) with help from Benson Mitchell and Thomas Perl
#
# GPL licensed; keep code free!
. /home/user/.chroot
else
- echo "No ~/.chroot file."
+ echo "No ~/.chroot file." >/dev/stderr
fi
#This comes from the config file... If not, fall back on '/debian'
if [ "x$CHROOT" = "x" ] ; then
CHROOT=/debian
- echo "No chroot dir specified; using $CHROOT"
+ echo "No chroot dir specified; using $CHROOT" >/dev/stderr
else
- echo "Chroot dir specified: $CHROOT"
+ echo "Chroot dir specified: $CHROOT" >/dev/stderr
fi
#This comes from the config. If not, search for debian*.img.ext2
if [ "x$IMGFILE" = "x" ] ; then
- echo "No image file or partition specified."
+ echo "No image file or partition specified." >/dev/stderr
IMGMMC="`ls -1 /home/user/MyDocs/debian*.img* /media/mmc1/debian*.img* | head -1`"
if [ "x$IMGMMC" != x ] ; then
IMGFILE="$IMGMMC"
else
MSG1=`printf "ERROR!\n\nYou have no debian.img.ext2 file on your memory cards.\n\nPlease use the Debian Image Installer in Extras."`
if [ ! -f "/usr/bin/gxmessage" ] ; then
- echo $MSG1
+ echo $MSG1 >/dev/stderr
else
gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "MISSING DISK IMAGE" "$MSG1"
fi
exit 9
fi
else
- echo "$IMGFILE specified in ~/.chroot"
+ echo "$IMGFILE specified in ~/.chroot" >/dev/stderr
fi
#
#!/bin/sh
# Chroots to Debian and runs a shell, or any command-line as non-root.
-# By Alan M Bruce (qole) and Benson Mitchell
+# By Alan M Bruce (qole), Benson Mitchell and Thomas Perl
#
# GPL licensed; keep code free!
[ -f /home/user/.chroot ] && . /home/user/.chroot
#This comes from the config file... If not, fall back on 'user'
-[ "x$DEBUSER" != x ] || DEBUSER=user
+#[ "x$DEBUSER" != x ] || DEBUSER=user
+DEBUSER=$USER
CHROOTUSER=$DEBUSER
#With args, just run them as $DEBUSER.
if [ $# = 0 ] ; then
- echo Starting Debian shell...
+ echo Starting Debian shell... >/dev/stderr
sudo /sbin/debian su $DEBUSER
else
- echo Starting Debian $1
+ # Workaround to allow "debbie" to be used as login shell
+ if [ "$1" == "-c" ]; then
+ shift
+ fi
+ echo Starting Debian $* >/dev/stderr
sudo /sbin/debian su $DEBUSER -c "$*"
fi