3dac113cd30ef8c6225cb250494250c271f2b5bb
[easy-deb-chroot] / diablo / easy-deb-chroot / src / sbin / debian~
1 #!/bin/sh
2 # Sets up (if necessary) for chroot into a Debian environment.
3 # Expects root privileges, does not drop them. 
4 # Look to /usr/bin/debbie for a friendly wrapper.
5
6 # By Alan M Bruce (qole) with help from Benson Mitchell
7 #
8 # GPL licensed; keep code free!
9
10 if [ "`whoami`" != "root" ] ; then
11   echo "please run me as root!"
12   exit 9
13 fi
14
15 #Pull in the config, if possible...
16 if [ -f "/home/user/.chroot" ] ; then
17
18 . /home/user/.chroot
19
20 else
21   echo "No ~/.chroot file." >/dev/stderr
22 fi
23
24 #This comes from the config file... If not, fall back on '/debian'
25 if [ "x$CHROOT" = "x" ] ; then
26   CHROOT=/debian
27   echo "No chroot dir specified; using $CHROOT" >/dev/stderr
28 else
29   echo "Chroot dir specified: $CHROOT" >/dev/stderr
30 fi
31
32 #This comes from the config. If not, search for debian*.img.ext2
33 if [ "x$IMGFILE" = "x" ] ; then
34   echo "No image file or partition specified." >/dev/stderr
35   IMGMMC="`ls -1 /media/mmc?/debian*.img* | head -1`"
36   if [ "x$IMGMMC" != x ] ; then
37     IMGFILE="$IMGMMC"
38   else
39     MSG1=`printf "ERROR!\n\nYou have no debian.img.ext2 file on your memory cards.\n\nPlease use the Debian Image Installer in Extras."`
40     if [ ! -f "/usr/bin/gxmessage" ] ; then
41       echo $MSG1 >/dev/stderr
42     else
43       gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "MISSING DISK IMAGE" "$MSG1"
44     fi
45     exit 9
46   fi
47 else
48   echo "$IMGFILE specified in ~/.chroot" >/dev/stderr
49 fi
50
51 #
52 #Make the temp dir bigger for OpenOffice etc.
53 #
54 #This comes from the config file... 
55 #If not, fall back to a 6MB /tmp dir
56 #
57
58 [ "x$TMPSIZE" != x ] || TMPSIZE=6M
59 mount -o remount,size=$TMPSIZE /tmp
60
61 #Messy hack to make tap-and-hold work with GTK apps.
62 export GTK_MODULES=libgtkstylus.so
63
64 #Some OpenOffice environment variables
65 export SAL_USE_VCLPLUGIN="gtk"
66 export OOO_FORCE_DESKTOP="gnome"
67 export SAL_NOOPENGL="true"
68 export OOO_DISABLE_RECOVERY="true"
69 export SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION="true"
70 #export SAL_DISABLE_CUPS="true"
71
72 qchroot $IMGFILE $CHROOT "$@"