Fixes to get Diablo version into Extras
[easy-deb-chroot] / diablo / easy-deb-chroot / src / usr / bin / debbie
1 #!/bin/sh
2 # Chroots to Debian and runs a shell, or any command-line as non-root.
3
4 # By Alan M Bruce (qole), Benson Mitchell and Thomas Perl
5 #
6 # GPL licensed; keep code free!
7
8 if [ "`whoami`" = "root" ] ; then
9   echo "please don't run me as root!"
10   exit 9
11 fi
12
13 #Pull in the config, if possible...
14 [ -f /home/user/.chroot ] && . /home/user/.chroot
15
16 # This comes from the config file... 
17 # If not, fall back on $USER, then 'user'
18 [ "x$DEBUSER" != x ] || DEBUSER=$USER
19 [ "x$DEBUSER" != x ] || DEBUSER=user
20 #DEBUSER=$USER
21
22 CHROOTUSER=$DEBUSER
23
24 #If display's not given, go to primary display. If it's set, let's not
25 #mangle it to allow convenient use of USB VGA out, or multiple Xomaps.
26 [ "x$DISPLAY" != x ] || export DISPLAY=:0.0
27
28 #This enables long-hold-to-right-click in all GTK+ apps.
29 #Maybe we'd be better to add libgtkstylus.so anyway, but for now, we'll
30 #just leave it if they've got any non-empty GTK_MODULES 
31 [ "x$GTK_MODULES" != x ] || export GTK_MODULES=libgtkstylus.so
32
33 #Note use of su below, so no Debian-side script req'd to drop privileges.
34 #With no args, use a shell; su will get the right one, with no -c
35 #With args, just run them as $DEBUSER.
36
37 if [ $# = 0 ] ; then
38   echo Starting Debian shell... >/dev/stderr
39   sudo /sbin/debian su $DEBUSER
40 else
41   # Workaround to allow "debbie" to be used as login shell
42   if [ "$1" == "-c" ]; then
43     shift
44   fi
45   echo Starting Debian $* >/dev/stderr
46   sudo /sbin/debian su $DEBUSER -c "$*"
47 fi