This follows straight on from today’s other article on [building a kiosk computer with Ubuntu and Chrome from scratch. In my mind that’s the perfect setup: low fat and speedy… But we don’t always get it right first time. You might have already been battling with a full Ubuntu install and not have the time to strip it down.
This tutorial assumes you’re starting with an Ubuntu desktop, all installed with working network and graphics. While we’re in graphical-land, you might as well go and install Chrome.
I have tested this in a clean 14.04 install but be careful. Back up any important data before you commit.
sudo apt update
sudo apt install --no-install-recommends openbox pulseaudio
sudo usermod -a -G audio $USER
sudo install -b -m 755 /dev/stdin /opt/kiosk.sh << EOF
# !/bin/bash
xset -dpms
xset s off
openbox-session &
start-pulseaudio-x11
while true; do
rm -rf ~/.{config,cache}/google-chrome/
google-chrome --kiosk --no-first-run 'https://thepcspy.com'
done
EOF
sudo install -b -m 644 /dev/stdin /etc/init/kiosk.conf << EOF
start on (filesystem and stopped udevtrigger)
stop on runlevel [06]
emits starting-x
respawn
exec sudo -u $USER startx /etc/X11/Xsession /opt/kiosk.sh --
EOF
sudo dpkg-reconfigure x11-common # select Anybody
echo manual | sudo tee /etc/init/lightdm.override # disable desktop
sudo reboot
This should boot you into a browser looking at my home page (use sudoedit /opt/kiosk.sh
to change that), but broadly speaking, we’re done.
If you ever need to get back into the desktop should be able to Control+Alt+F1 to get to a terminal, log in and then run:
sudo stop kiosk # if it's running
sudo start lightdm
If you run both at the same time (which should be possible but some people seem to be struggling), lightdm will probably start on VT8 (Control+Alt+F8 to switch).
Why wouldn’t I always do it this way?
I’ll freely admit that I’ve done farts longer than it took to run the above. Starting from an Ubuntu Desktop base does do a lot of the work for us, however it is demonstrably flabbier:
- The Server result was 1.6GB, using 117MB RAM with 38 processes.
- The Desktop result is 3.7GB, using 294MB RAM with 80 processes!
Yeah, the Desktop is still loading a number of udisks mount helpers, PulseAudio, GVFS, Deja Dup, Bluetooth daemons, volume controls, Ubuntu 1, CUPS the printer server and all the various Network and Modem Manager things a traditional desktop needs.
This is the reason you base your production model off Ubuntu Server (or even Ubuntu Minimal).
And remember that you aren’t done yet. There’s a big list of boring jobs to do before it’s Martini O’Clock
Just remember that everything I said about physical and network security last time applies doubly here. Ubuntu-proper ships a ton of software on its 1GB image and quite a lot more of that will be running, even after we’ve disabled the desktop. You’re going to want to spend time stripping some of that out and putting in place any security you need to stop people getting in.
Just be careful and conscientious about how you deploy software.