Ubuntu 16.04.2 Kiosk Mode

If you want to run a PC in Kiosk mode, you probably want to run an instance of a web browser that does not allow anything else but simple browsing with only the mouse. The browser is not supposed to be canceled or quit but should indefinitely run and provide the specified web page you want to provide the kiosk for. This would entail booting the PC directly into the web browser.

Setup:

In this example we use the chromium open source chrome derivate web browser that will connect to a specified web page and will function in kiosk mode just in the way you would expect it to run. This howto is addressed to intermediate users that have a basic understanding of the linux shell, that are able edit script files and know what ~ means.

In order to achieve this goal we can create a simple Ubuntu server installation and just install the bare minimum of packages required to fulfill our task. In part I will rely on the very helpful but a bit outdated example from Oli Warner.

Installation of Ubuntu 16.04 server edition is not covered in this section but many helpful tutorials exist and can provide enough information to supply your desired kind of installation. However, after the installation, at the very least you would have to execute the following command in order to download the minimal set of packages:
sudo apt install --no-install-recommends xorg openbox

Start Script for Openbox and Chromium

Once you have a basic running Ubuntu server system, you may simply copy the following script into /home/user/startchrome.sh.
It will start openbox, which is necessary in order to display chromium full screen and, then, will start chromium browser as kiosk.
#!/bin/bash

openbox-session &

xset s 0 0
xset -dpms

xset dpms force off

while true
do
  killall chromium-browser
  rm -rf ~/.{config,cache}/chromium/

  # start browser in your web site: here, just plain old localhost
  # -test-type will ignore any warnings and 
  # --ignore-certificate-errors will allow you to kiosk any https-page without displaying certificate errors
  chromium-browser -test-type --ignore-certificate-errors --kiosk --no-first-run --incognito http://localhost/ &

  sleep 10

  while true
  do
    pgrep chromium-browse
    if [ "$?" -eq "1" ]
    then
         #here you could execute something that is supposed to happen after the browser was accidentally quit
    fi
    sleep 1
  done

  exit 0
done

Automatically Execute Script After Login

Any commands you want to execute autmatically, once you are logged in, can be added at the end of your ~/.profile. Basically you can execute the start of an XSession in combination with the Chromium-Kiosk by adding the following line:
/usr/bin/startx /etc/X11/Xsession /home/user/startchrome.sh -- :0
Now, every time you login, your script will be executed.

This gives you the advantage of controlling access to the Kiosk.

Automatically log into first terminal as user

But what if you simply want to have a dummy box that will automatically boot up your kiosk without requiring any user interaction?

Ubuntu now provides Systemd and if you want to automatically log into the console without using any graphical tools, you can copy your own terminal getty from /lib/systemd/system/getty@.service.
cp /lib/systemd/system/getty@.service /lib/systemd/system/getty@tty1.service
In the file /lib/systemd/system/getty@tty1.service you can add parameter '-a ' to the agetty command in the following line:
ExecStart=-/sbin/agetty --noclear %I $TERM
So it will look like this:
ExecStart=-/sbin/agetty -a user --noclear %I $TERM
And voilá, after the next reboot you will be automatically loggin into the first terminal with the username, and, if everything works fine, you will see your kiosk-browser popup and are done :)

Kommentare

Beliebte Posts aus diesem Blog

This and sed

What To Do When Your Ubuntu System Hangs On Reboot Or Shutdown?