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:
- created a 
stop_kiosk.shfile in/etc/init.ddirectory. - symlinked the file to 
/etc/rc0.d/K00StopKiosk - 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 --