| 1 | #!/bin/bash -e |
|---|
| 2 | |
|---|
| 3 | # debirf module: xkiosk |
|---|
| 4 | # create an graphical kiosk that starts x and a browser on boot. |
|---|
| 5 | # |
|---|
| 6 | # Depends: network-dhcp module, install-runit module |
|---|
| 7 | # |
|---|
| 8 | # The debirf scripts were written by |
|---|
| 9 | # Jameson Rollins <jrollins@fifthhorseman.net> |
|---|
| 10 | # and |
|---|
| 11 | # Daniel Kahn Gillmor <dkg-debian.org@fifthhorseman.net>. |
|---|
| 12 | # |
|---|
| 13 | # They are Copyright 2007, and are all released under the GPL, |
|---|
| 14 | # version 3 or later. |
|---|
| 15 | |
|---|
| 16 | ### download needed packages |
|---|
| 17 | # could maybe pick and choose xorg packages if hardware known |
|---|
| 18 | debirf_exec apt-get install --assume-yes xorg matchbox-window-manager iceweasel |
|---|
| 19 | |
|---|
| 20 | ### properly configure X |
|---|
| 21 | # allow any user to start X (not just from command line): |
|---|
| 22 | # ("debirf_exec dpkg-reconfigure x11-common") |
|---|
| 23 | cat <<EOF > "$DEBIRF_ROOT"/etc/X11/Xwrapper.config |
|---|
| 24 | allowed_users=anybody |
|---|
| 25 | nice_value=0 |
|---|
| 26 | EOF |
|---|
| 27 | |
|---|
| 28 | # make standard xorg.conf |
|---|
| 29 | cat <<EOF > "$DEBIRF_ROOT"/etc/X11/xorg.conf |
|---|
| 30 | Section "Files" |
|---|
| 31 | EndSection |
|---|
| 32 | Section "InputDevice" |
|---|
| 33 | Identifier "Generic Keyboard" |
|---|
| 34 | Driver "kbd" |
|---|
| 35 | Option "CoreKeyboard" |
|---|
| 36 | Option "XkbRules" "xorg" |
|---|
| 37 | Option "XkbModel" "pc104" |
|---|
| 38 | Option "XkbLayout" "us" |
|---|
| 39 | EndSection |
|---|
| 40 | Section "InputDevice" |
|---|
| 41 | Identifier "Configured Mouse" |
|---|
| 42 | Driver "mouse" |
|---|
| 43 | Option "CorePointer" |
|---|
| 44 | Option "Device" "/dev/input/mice" |
|---|
| 45 | Option "Protocol" "ImPS/2" |
|---|
| 46 | Option "Emulate3Buttons" "true" |
|---|
| 47 | EndSection |
|---|
| 48 | Section "Device" |
|---|
| 49 | Identifier "Generic Video Card" |
|---|
| 50 | Driver "vesa" |
|---|
| 51 | BusID "PCI:1:0:0" |
|---|
| 52 | EndSection |
|---|
| 53 | Section "Monitor" |
|---|
| 54 | Identifier "VGA" |
|---|
| 55 | EndSection |
|---|
| 56 | Section "Screen" |
|---|
| 57 | Identifier "Default Screen" |
|---|
| 58 | Device "Generic Video Card" |
|---|
| 59 | Monitor "VGA" |
|---|
| 60 | DefaultDepth 24 |
|---|
| 61 | SubSection "Display" |
|---|
| 62 | Modes "1280x1024" "1024x768" "800x600" |
|---|
| 63 | EndSubSection |
|---|
| 64 | EndSection |
|---|
| 65 | Section "ServerLayout" |
|---|
| 66 | Identifier "Default Layout" |
|---|
| 67 | Screen "Default Screen" |
|---|
| 68 | InputDevice "Generic Keyboard" |
|---|
| 69 | InputDevice "Configured Mouse" |
|---|
| 70 | EndSection |
|---|
| 71 | EOF |
|---|
| 72 | |
|---|
| 73 | ### add guest user |
|---|
| 74 | if ! debirf_exec getent passwd guest >/dev/null 2>/dev/null ; then |
|---|
| 75 | debirf_exec adduser --disabled-password --gecos "Kiosk User,,," guest |
|---|
| 76 | fi |
|---|
| 77 | |
|---|
| 78 | ### configure runit service dir to start X session |
|---|
| 79 | RUNIT_DIR=/srv/xkiosk |
|---|
| 80 | RUNIT_DIR_DEBIRF="${DEBIRF_ROOT}/${RUNIT_DIR}" |
|---|
| 81 | |
|---|
| 82 | mkdir -p "$RUNIT_DIR_DEBIRF"/{env,log/main} |
|---|
| 83 | debirf_exec chown guest:guest "$RUNIT_DIR"/log/main |
|---|
| 84 | |
|---|
| 85 | echo guest > "$RUNIT_DIR_DEBIRF"/env/UID |
|---|
| 86 | echo guest > "$RUNIT_DIR_DEBIRF"/env/GID |
|---|
| 87 | echo /home/guest > "$RUNIT_DIR_DEBIRF"/env/HOME |
|---|
| 88 | |
|---|
| 89 | # creat run script |
|---|
| 90 | # guest users starts X |
|---|
| 91 | cat <<EOF > "$RUNIT_DIR_DEBIRF"/run |
|---|
| 92 | #!/bin/sh |
|---|
| 93 | exec 2>&1 |
|---|
| 94 | exec chpst -u guest:audio:video -e env /usr/bin/startx |
|---|
| 95 | EOF |
|---|
| 96 | debirf_exec chmod a+x "$RUNIT_DIR"/run |
|---|
| 97 | |
|---|
| 98 | # create log run script |
|---|
| 99 | cat <<EOF > "$RUNIT_DIR_DEBIRF"/log/run |
|---|
| 100 | #!/bin/sh |
|---|
| 101 | exec chpst -u guest svlogd -tt ./main |
|---|
| 102 | EOF |
|---|
| 103 | debirf_exec chmod a+x "$RUNIT_DIR"/log/run |
|---|
| 104 | |
|---|
| 105 | # link in service dir |
|---|
| 106 | debirf_exec ln -sf "$RUNIT_DIR" /var/service/ |
|---|
| 107 | |
|---|
| 108 | ### make xinitrc |
|---|
| 109 | # for guest user, loads window manager and browser |
|---|
| 110 | cat <<EOF > "$DEBIRF_ROOT"/home/guest/.xinitrc |
|---|
| 111 | #!/bin/sh |
|---|
| 112 | xsetroot -solid blue |
|---|
| 113 | matchbox-window-manager & |
|---|
| 114 | TARG=http://cmrg.fifthhorseman.net/wiki/debirf |
|---|
| 115 | if (grep -q 'browse=' </proc/cmdline) ; then |
|---|
| 116 | TARG=\$( sed 's/.*browse=\([^[:space:]]*\).*/\1/' </proc/cmdline) |
|---|
| 117 | fi |
|---|
| 118 | iceweasel \$TARG |
|---|
| 119 | EOF |
|---|
| 120 | |
|---|
| 121 | # set permissions on /home/guest, just in case |
|---|
| 122 | debirf_exec chown -R guest:guest /home/guest |
|---|