1

I've created an ubuntu server kiosk based on some guide that I've found and I'm trying to stop the kiosk before the shutdown. The kiosk is being started automatically or manually with the command sudo start kiosk and can be stopped when running sudo stop kiosk.

The kiosk code will re-open the browser if it was closed. The result is that I can't shutdown the server because it keeps creating new browser sessions.

I tried to set a before shutdown scripts which simply runs sudo stop kiosk but it still doesn't seems to work.

What I've done is as follows:

  1. created a stop_kiosk.sh file in /etc/init.d directory.
  2. symlinked the file to /etc/rc0.d/K00StopKiosk
  3. symlinked the file to /etc/rc6.d/K00StopKiosk

However, it closes the browser instance, and immediately opens a new browser instance. All of the other sessions are being closed and I can't keep interacting with the server, just with the browser. I have to manually shutdown the pc (using virtualbox here so I simply quit virtualbox).

If I manually run sudo stop kiosk before the shut down, it will properly stop the kiosk, close the browser and terminate openbox, xorg etc. Then I can shutdown safely and easily with no problems.

The kiosk files are as follows:

/opt/kiosk.sh:

#!/bin/bash

xset -dpms
xset s off
openbox-session &

while true; do 
    rm -rf ~/.{config,cache}/google-chrome/
    google-chrome --disable-translate \
                  --disable infobars \ 
                  --disable-suggestions-service \ 
                  --disable-save-password-bubble \
    --no-first-run 'http://google.com'
done

/etc/init/kiosk.conf:

start on (filesystem and stopped udevtrigger)
stop on runlevel [06]

console output
emits starting-x

respawn

exec sudo -u user startx /etc/X11/Xsession /opt/kiosk.sh --
  • 1
    What is the URL for "some guide that I've found"? It must be setting things up this way on purpose, so knowing what it does is likely to be important. – Azhrei Jun 11 '15 at 21:51
  • @Azhrei Here it is: thepcspy.com/read/building-a-kiosk-computer-ubuntu-1404-chrome Not sure it will help you our, the files I showed here are what the guide shows. – kfirba Jun 11 '15 at 21:59
1

You're using /opt/kiosk.sh as your session file for startx. Because that script has an infinite loop coded into it, your script is going to reopen the browser every time it's killed.

Instead of using while true it may be better to perform a check to see whether that service is shutting down. Unfortunately, I'm not familiar enough with upstart to know what test condition would determine when the system is shutting down. Something like this new while loop might suffice (this replaces the one in the kiosk.sh script):

while [[ $(status kiosk) != */stopping* ]]

That loop waits for the status kiosk command to return a string containing "/stopping" and terminates the loop when it does.

I hope someone with more experience in upstart can correct my implementation. :)

  • It doesn't seem to work. Actually, I'm just unsure what kind of status is returned when I do sudo shutdown 0. I tried to figure out what status is being returned, but I simply couldn't. Any idea? – kfirba Jun 12 '15 at 6:34
  • What benefit would more experience with systemd bring, when both question and answer are clearly upstart? On that note, consider your answer and the notion of hand-rolling your own restarts in the light of upstart's respawn stanza. – JdeBP Jun 12 '15 at 22:35
  • Ah, my mistake. I looked at Mint17 (the VM I had available) and I saw systemd; clearly Mint17 is recent enough to have it but Ubuntu 14 is not. I agree that it would be nice if his Guide were better integrated into upstart, but I was trying not to modify his guide too much. In any case, it looks like status works the same way in both. – Azhrei Jun 13 '15 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.