From f31f6e5fca75974adb1ae8300854916512b484bb Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 4 Jan 2019 11:12:55 +0100 Subject: [kiosk*] rework and introduce kiosk mode modules changed from slxbrowser only support to modular hook structure to support additional browser, i.e. chromium NOTE: kiosk-chromium and kiosk-netpoint only make sense with the new gen --- .../data/etc/systemd/system/kiosk-mode.target | 3 + .../kiosk-mode.target.wants/graphical.target | 1 + .../system/kiosk-mode.target.wants/kiosk.service | 1 + .../data/etc/systemd/system/kiosk.service | 8 + .../kiosk-common/data/etc/xdg/openbox/rc.xml.kiosk | 345 +++++++++++++++++++++ .../opt/openslx/lightdm/autologin.d/10-kiosk-mode | 9 + .../openslx/lightdm/guest-account.d/00-iptables | 26 ++ .../data/opt/openslx/scripts/kiosk-launch | 26 ++ .../data/opt/openslx/scripts/systemd-setup_kiosk | 57 ++++ core/modules/kiosk-common/module.build | 12 + core/modules/kiosk-common/module.conf | 4 + 11 files changed, 492 insertions(+) create mode 100644 core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target create mode 120000 core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target.wants/graphical.target create mode 120000 core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target.wants/kiosk.service create mode 100644 core/modules/kiosk-common/data/etc/systemd/system/kiosk.service create mode 100644 core/modules/kiosk-common/data/etc/xdg/openbox/rc.xml.kiosk create mode 100644 core/modules/kiosk-common/data/opt/openslx/lightdm/autologin.d/10-kiosk-mode create mode 100644 core/modules/kiosk-common/data/opt/openslx/lightdm/guest-account.d/00-iptables create mode 100755 core/modules/kiosk-common/data/opt/openslx/scripts/kiosk-launch create mode 100755 core/modules/kiosk-common/data/opt/openslx/scripts/systemd-setup_kiosk create mode 100644 core/modules/kiosk-common/module.build create mode 100644 core/modules/kiosk-common/module.conf (limited to 'core/modules/kiosk-common') diff --git a/core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target b/core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target new file mode 100644 index 00000000..fb95249c --- /dev/null +++ b/core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target @@ -0,0 +1,3 @@ +[Unit] +Description=Kiosk mode + diff --git a/core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target.wants/graphical.target b/core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target.wants/graphical.target new file mode 120000 index 00000000..949b0756 --- /dev/null +++ b/core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target.wants/graphical.target @@ -0,0 +1 @@ +../graphical.target \ No newline at end of file diff --git a/core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target.wants/kiosk.service b/core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target.wants/kiosk.service new file mode 120000 index 00000000..a6e3a110 --- /dev/null +++ b/core/modules/kiosk-common/data/etc/systemd/system/kiosk-mode.target.wants/kiosk.service @@ -0,0 +1 @@ +../kiosk.service \ No newline at end of file diff --git a/core/modules/kiosk-common/data/etc/systemd/system/kiosk.service b/core/modules/kiosk-common/data/etc/systemd/system/kiosk.service new file mode 100644 index 00000000..dba49864 --- /dev/null +++ b/core/modules/kiosk-common/data/etc/systemd/system/kiosk.service @@ -0,0 +1,8 @@ +[Unit] +Description=Prepare KIOSK mode +Before=display-manager.service kdm.service lightdm.service + +[Service] +ExecStart=/opt/openslx/scripts/systemd-setup_kiosk +RemainAfterExit=true + diff --git a/core/modules/kiosk-common/data/etc/xdg/openbox/rc.xml.kiosk b/core/modules/kiosk-common/data/etc/xdg/openbox/rc.xml.kiosk new file mode 100644 index 00000000..65e09cb5 --- /dev/null +++ b/core/modules/kiosk-common/data/etc/xdg/openbox/rc.xml.kiosk @@ -0,0 +1,345 @@ + + + + + + + + 10 + 20 + + + + yes + + no + + yes + + no + + 200 + + no + + + + + Smart + +
yes
+ + Primary + + 1 + +
+ + + Orion + LC + + yes + yes + + sans + 8 + + bold + + normal + + + + sans + 8 + + bold + + normal + + + + sans + 9 + + normal + + normal + + + + sans + 9 + + normal + + normal + + + + sans + 9 + + bold + + normal + + + + sans + 9 + + bold + + normal + + + + + + + 1 + 1 + + + + 875 + + + + + yes + Nonpixel + + Center + + + + + 10 + + 10 + + + + + + + 0 + 0 + 0 + 0 + + + + TopLeft + + 0 + 0 + no + Above + + Vertical + + no + 300 + + 300 + + Middle + + + + + + + + 1 + + 500 + + 400 + + false + + + + + + + + + + + + + + + + + + + /var/lib/openbox/debian-menu.xml + menu.xml + 200 + + no + + 100 + + 400 + + yes + + yes + + + + + + + +
diff --git a/core/modules/kiosk-common/data/opt/openslx/lightdm/autologin.d/10-kiosk-mode b/core/modules/kiosk-common/data/opt/openslx/lightdm/autologin.d/10-kiosk-mode new file mode 100644 index 00000000..b740496b --- /dev/null +++ b/core/modules/kiosk-common/data/opt/openslx/lightdm/autologin.d/10-kiosk-mode @@ -0,0 +1,9 @@ +#!/bin/ash +# ^SOURCED + +# kiosk mode? +if [ -n "$SLX_BROWSER_URL" ]; then + exec /opt/openslx/scripts/kiosk-launch +fi + +true diff --git a/core/modules/kiosk-common/data/opt/openslx/lightdm/guest-account.d/00-iptables b/core/modules/kiosk-common/data/opt/openslx/lightdm/guest-account.d/00-iptables new file mode 100644 index 00000000..38e4893a --- /dev/null +++ b/core/modules/kiosk-common/data/opt/openslx/lightdm/guest-account.d/00-iptables @@ -0,0 +1,26 @@ +#!/bin/ash +# ^ SOURCED + +kiosk_rules="/opt/openslx/iptables/rules.d/90-kiosk" +cat <<-EOF > "$kiosk_rules" + #!/bin/ash + + iptables -w -A ipt-helper-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT + iptables -w -I ipt-helper-OUTPUT 1 -o br0 -d 132.230.0.0/16 -j ACCEPT + iptables -w -I ipt-helper-INPUT 1 -i br0 -d 132.230.0.0/16 -j ACCEPT + iptables -w -I ipt-helper-OUTPUT 1 -o br0 -d 10.0.0.0/8 -j ACCEPT + iptables -w -I ipt-helper-INPUT 1 -i br0 -d 10.0.0.0/8 -j ACCEPT + + iptables -P INPUT DROP + iptables -P FORWARD DROP + iptables -P OUTPUT DROP +EOF + +chmod +x "$kiosk_rules" + +# HACK: wait for iptables helper to setup the rules... +sleep 2 + +# make sure it is cleared on session close +echo "rm -f \"$kiosk_rules\"" > "/etc/X11/Xreset.d/clear-kiosk-iptables" +true diff --git a/core/modules/kiosk-common/data/opt/openslx/scripts/kiosk-launch b/core/modules/kiosk-common/data/opt/openslx/scripts/kiosk-launch new file mode 100755 index 00000000..43af3640 --- /dev/null +++ b/core/modules/kiosk-common/data/opt/openslx/scripts/kiosk-launch @@ -0,0 +1,26 @@ +#!/bin/bash +# generic kiosk mode launcher + +. /opt/openslx/config + +[ -z "$SLX_BROWSER_URL" ] && exit 1 + +# disable power management features +xset s off +xset -dpms + +# start openbox window manager +openbox --config-file "/etc/xdg/openbox/rc.xml.kiosk" & + +# move the mouse away +xdotool mousemove 20000 20000 & + +# run browser +for file in "$0".d/*; do + . "$file" || slxlog "kiosk-launch" "Failed to source '$file'." +done + +# should not come to this point as above sources should +# exec away +slxlog "kiosk-launch" "No kiosk browser configured!" +exit 1 diff --git a/core/modules/kiosk-common/data/opt/openslx/scripts/systemd-setup_kiosk b/core/modules/kiosk-common/data/opt/openslx/scripts/systemd-setup_kiosk new file mode 100755 index 00000000..a19e2bc3 --- /dev/null +++ b/core/modules/kiosk-common/data/opt/openslx/scripts/systemd-setup_kiosk @@ -0,0 +1,57 @@ +#!/bin/bash + +. /opt/openslx/config + +configure_fullscreen() { + # TODO having two variants of the rc.xml is quite bad, better to prune it with xmlstarlet? + local openbox_rc_file="/etc/xdg/openbox/rc.xml.kiosk" + local openbox_namespace="http://openbox.org/3.4/rc" + # for fullscreen functionality, use openbox + if [ ! -e "$openbox_rc_file" ]; then + echo "Could not find global openbox configuration" + return 1 + fi + local browser_node="//x:applications/x:application[@role='browser']" + local -i browser_node_count="$(xmlstarlet sel -N x="$openbox_namespace" -t -c "count($browser_node)" "$openbox_rc_file")" + if [ "$browser_node_count" -gt 1 ]; then + echo "More than one node for '$browser_node' found. Removing them all..." + xmlstarlet ed -L -N x="$openbox_namespace" -d "$browser_node" "$openbox_rc_file" + fi + # either we removed everything, or we had none to start with + if [ "$browser_node_count" -eq 0 ] ; then + local tmpname="application$RANDOM" + xmlstarlet ed -L -N x="$openbox_namespace" -s "//x:applications" -t elem -n "$tmpname" -i "//$tmpname" -t attr -n "role" -v "browser" "$openbox_rc_file" + browser_node="//x:applications/x:$tmpname" + fi + # Fullscreen or maximized depends on whether we should start an interactive session or not + # For now use SLX_BROWSER_INTERACTIVE + local state + if [ -n "$SLX_BROWSER_INTERACTIVE" ]; then + state="maximized" + xmlstarlet ed -L -N x="$openbox_namespace" -d "$browser_node/x:fullscreen" "$openbox_rc_file" + else + state="fullscreen" + xmlstarlet ed -L -N x="$openbox_namespace" -d "$browser_node/x:maximized" "$openbox_rc_file" + fi + + if ! xmlstarlet sel -Q -N x="$openbox_namespace" -t -c "$browser_node/x:$state" "$openbox_rc_file"; then + xmlstarlet ed -L -N x="$openbox_namespace" -s "$browser_node" -t elem -n "$state" -v "yes" "$openbox_rc_file" + elif [ "$(xmlstarlet sel -N x="$openbox_namespace" -t -v "$browser_node/x:$state" "$openbox_rc_file")" != "yes" ]; then + xmlstarlet ed -L -N x="$openbox_namespace" -u "$browser_node/x:$state" -v "yes" "$openbox_rc_file" + fi + xmlstarlet ed -L -N x="$openbox_namespace" -r "$browser_node" -v "application" "$openbox_rc_file" +} + +## MAIN +configure_fullscreen + +# Disable logout delay for demo user on shutdown/reboot/... +mkdir -p "/run/openslx" +touch "/run/openslx/demo-no-logout-delay" + +for file in "$0".d/*; do + # hooks for browser-related stuff + . "$file" || slxlog "kiosk-setup" "Failed to source '$file'." +done + +exit 0 diff --git a/core/modules/kiosk-common/module.build b/core/modules/kiosk-common/module.build new file mode 100644 index 00000000..a5cbb6b6 --- /dev/null +++ b/core/modules/kiosk-common/module.build @@ -0,0 +1,12 @@ +#!/bin/bash +fetch_source() { + : +} + +build() { + : +} + +post_copy() { + : +} diff --git a/core/modules/kiosk-common/module.conf b/core/modules/kiosk-common/module.conf new file mode 100644 index 00000000..8811668a --- /dev/null +++ b/core/modules/kiosk-common/module.conf @@ -0,0 +1,4 @@ +#!/bin/bash +REQUIRED_BINARIES="" +REQUIRED_LIBRARIES="" +REQUIRED_DIRECTORIES="" -- cgit v1.2.3-55-g7522