#!/bin/bash disable_kiosko(){ if [ -f '/tmp/kiosk.mode' ]; then echo " [ LliureX Kiosko ] : Stopping Service" service lightdm stop sleep 4 rm /tmp/kiosk.mode fi echo " [ LliureX Kiosko ] : Disabling user" deluser kiosk || true echo " [ LliureX Kiosko ] : Removing configuration files" rm -f /etc/lightdm/lightdm.conf.d/12-autologin.conf /usr/share/xsessions/kiosk.desktop || true rm -f /opt/kiosk.sh rm -f /usr/sbin/disable-lliurex-kiosk zero-center set-non-configured lliurex-zero-installer-kiosko service lightdm restart return 0 } enable_kiosko(){ echo " [ LliureX Kiosko ] : Installing needed packages" zero-installer install chromium-browser zero-installer install compiz zero-installer install feh test_depends=`type -fp chromium-browser` if [ "x$test_depends" == "x" ]; then echo Something is going wrong, chromium-browser appears not installed fi if [ -f /etc/lightdm/lightdm.conf ]; then test_autologin=`grep autologin-user /etc/lightdm/lightdm.conf|wc -l` if [ "x$test_autologin" != "x0" ]; then echo "[ Lliurex Kiosko] : Remove default /etc/lightdm/lightdm.conf (backup done into /etc/lightdm/lightdm.backup_kiosk" mv /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.backup_kiosk fi fi echo " [ LliureX Kiosko ] : Creating kiosk user" adduser kiosk --disabled-password --gecos kiosk,'','','' passwd kiosk << _EOF kiosk kiosk _EOF echo " [ LliureX Kiosko ] : Copying files" cp /usr/share/lliurex-kiosko/kiosk.desktop /usr/share/xsessions/ mkdir -p /etc/lightdm/lightdm.conf.d cp /usr/share/lliurex-kiosko/kiosk-autologin.conf /etc/lightdm/lightdm.conf.d/12-autologin.conf echo " [ LliureX Kiosko ] : Setting $1 as initial webpage" sed -e "s/www.cece.gva.es/$1/g" /usr/share/lliurex-kiosko/kiosk.sh > /opt/kiosk.sh chmod +x /opt/kiosk.sh ln -s /usr/sbin/lliurex-kiosk /usr/sbin/disable-lliurex-kiosk zero-center set-configured lliurex-zero-installer-kiosko echo " [ LliureX Kiosko ] : Finishing" echo "********************************************************" echo "** Kiosk mode enabled ! **" echo "* **" echo "* It's needed reboot the machine or display manager! **" echo "* # sudo service lightdm restart **" echo "* **" echo "** To disable kiosk-mode execute as root: **" echo "** # /usr/sbin/disable-lliurex-kiosk **" echo "** **" echo "********************************************************" return 0 } show_usage(){ echo "$0 --enable|-e [URL]: Enable kiosk mode" echo "$0 --disable|-d : Disable kiosk mode" echo "$0 --help|-? : Show this help" } if [[ $0 =~ disable ]]; then disable_kiosko exit $? fi if [ $# -lt 1 ]; then show_usage fi if [ "$(id -u)" != "0" ]; then echo "This script must be run as root" 1>&2 exit 1 fi case $1 in --disable| -d) disable_kiosko exit $? ;; --enable| -e) if [ -z "$2" ]; then show_usage exit 1 else enable_kiosko $2 exit $? fi ;; --help| -?) show_usage exit 1 ;; *) echo " [ LliureX Kiosko ] : Unknown action" ;; esac exit 0