Tuesday, October 5, 2010

Setting up an Internet Kiosk With Opera and Ubuntu

* Home
o Computing
+ Setting up an Internet Kiosk With Opera and Ubuntu

At work we have a few machines set up in the cafe for casual Internet usage. They really do need to be used for the Internet only so we wanted to set them up in ‘kiosk mode’.

I had done this before on a Mac using Saft for Safari, but the machines I had available for this project were PCs.

It turns out that making a Windows based kiosk (without buying specialist software) is quite hard as it’s difficult or impossible to disable all of the shortcuts that will drop a user out into the main operating system.

The best solution I could come up with was to use the Opera browser along with Ubuntu Linux, here’s how I did it.
Installing Ubuntu

1. First install Ubuntu. This is as easy as downloading and burning an ISO from the Ubuntu website and then booting the computer from the CD that you’ve created.
2. During the installation you will be asked to create a user; I called mine ‘administrator’. This is the default privileged user on the system so make the password secure!
3. When the installation is complete, log in as your administrator user and set up the networking however you like.
4. Install any pending updates.
5.

Open a terminal and get the software lists up to date:
sudo apt-get update
6.

Install any additional bits of software that you might need on the machines, e.g.:
sudo apt-get install openssh-server vim

Creating the Kiosk Account

Now you can create the student account (or whatever you want to call it) that your kiosk will run under.

1. Load up System → Administration → Users and Groups and add a new user called ‘student’.
2. From the drop down profile list choose ‘unprivileged’.
3. In the privileges tab tick ‘connect to wireless and ethernet networks’ and ‘use audio devices’, those should be the only two things ticked.

Setting up the System

1. To make the student user log in automatically choose that option in System → Administration → Login Screen.
2. Go to www.opera.com with Firefox (which should be installed by default) and download Opera. It should be a .deb file which you can then open with the package manager and install.
3. Download the Adobe Flash plugin from the Adobe website and install that, again this will be a .deb file.
4. For Java open up Ubuntu’s software manager and search for ‘Sun Java 6.0 Plugin’, you can then install that from inside the package manager itself.

Note that you can’t currently install Adobe Shockwave or Microsoft Silverlight in Opera on Ubuntu so your kiosk users will just have to do without those!
Auto Boot

If you want to boot the machine automatically on a schedule this will need to be done in the BIOS, it is not a Linux thing! Older BIOSs may not have options for scheduled boots but newer ones should.

If you don’t have the option you may also be able to plug the machine into a timer plug and set the BIOS to wake after a power cut which will achieve the same thing.
Auto Shut Down

Shutting down automatically is possible by using a cron job:

1.

Add the following line to /etc/crontab:

30 22 * * * /root/shutdown.sh

The 30 22 there is equivalent to 22:30 i.e. 10.30pm, so adjust to whatever time you want.
2.

Create the file /root/shutdown.sh which should contain the following:

#!/bin/bash
shutdown -h now

3.

Make sure the file is executable:
chmod 755 shutdown.sh

Setting Up the Student User’s Environment

1. Log out and log back in as the student user.
2.

Set up the power options by opening System → Preferences → Power Management.

Set the system sleep time to never and turn off the screen after an hour, spin down hard drives when possible. In the power button options make it shut down when the power button is pressed.
3. Turn off the screen saver.
4.

Open up the keyboard shortcuts in System → Preferences → Keyboard Shortcuts and set all of the options to disabled.

The only one that you might want to enable is ‘hide all normal windows and set focus to the desktop’ as an emergency get out of Opera combination, but if you do so set it to something obscure to stop anyone finding it out (like shift-ctrl-windows-alt-0 or something).
5. If you’re letting people use sound then you may want to open up the volume properties and set it to something comfortable since the user won’t have access to it beyond the Flash controls on Youtube etc.

Setting Up Opera

1. If you have run Opera previously then clear out all the preferences by deleting ~/.opera.
2.

Open up Opera and set up the environment how you would like it. For me this included:
* Set the home page URL and tick to start with the home page
* Turn off the password manager completely.
* Disable notification sounds.
* Set the cache to empty on program exit (technically redundant).
* Set the proxy address.
* Open opera:config and set the ‘Go Home Time Out’ to 600 (10 minutes). This is the length of idle time before open tabs are closed and the home page is displayed.
* Show the ‘Main Bar’ tool bar and remove any buttons you don’t want such as Open and Save.
* Set the History to 0 pages.
* Disable mouse gestures.
* Open the side bar and remove any panels that you don’t want such as widgets and bookmarks.
3. Close Opera.
4.

~/.opera now contains the preferences that you have just set up. We will copy these preferences to a control folder:
cp -rf ~/.opera ~/.opera_control

Each time Opera launches, these control preferences will be copied over any existing preferences via the script below. This will ensure that there’s always a clean environment on every boot.

Opera Launcher Script

The last thing to do is to make a script to launch Opera called launch_opera.sh which should contain the following:
#!/bin/bash

rm -rf ~/.opera
cp -rf ./.opera_control ./.opera

opera --kioskmode --kioskwindows --kioskbuttons --kioskresetstation --nomail --nomaillinks --nosave --nodownload --resetonexit --noexit --nocontextmenu --nomenu --noprint --nokeys

All the flags that are used there are described on this page, you can pick whichever ones you want.

Finally set the script as a startup item by going into System → Preferences → Startup Applications
Opera Command Line Arguments

These are the ones that I used:

kioskmode
start in kiosk mode
kioskwindows
allow tabs in kiosk mode
kioskbuttons
allow address bar and buttons in kiosk mode
kioskresetstation
go back to home page on idle time out
nomail
no built in mail/nntp client
nomaillinks
no clicking of mailto: links
nosave
no saving files
nodownload
no downloading files
resetonexit
clear cache on exit (technically redundant)
noexit
no quitting the application
nocontextmenu
disable right click
nomenu
no access to main menu
noprint
no printing
nokeys
disable all shortcuts

Conclusion

You can test your setup by re-booting the machine. It should start up, automatically log in the student user and then automatically launch Opera in kiosk mode.

You should not be able to press any key combination to get out of Opera to the desktop other than the one mentioned at the start.

Note that you can still get to a terminal with ctrl-alt-Fx but the user would not be able to log in and would just be looking at a prompt.