From 83d9ebc9b7684a05325cd3e912d729883c4fb16a Mon Sep 17 00:00:00 2001
From: Jonathan Bauer
Date: Fri, 5 Jun 2015 16:45:17 +0200
Subject: [safe-mode/firefox] e-klausur demo modules
---
.../data/opt/openslx/scripts/firefox-session | 6 +
.../data/usr/share/xsessions/firefox.desktop | 6 +
remote/modules/firefox/module.build | 15 +
remote/modules/firefox/module.conf | 6 +
remote/modules/firefox/module.conf.ubuntu | 2 +
remote/modules/openbox/data/etc/xdg/openbox/rc.xml | 756 +++++++++++++++++++++
.../openbox/data/etc/xdg/openbox/rc.xml.safe | 426 ++++++++++++
.../system/basic.target.wants/safe-mode.service | 1 +
.../data/etc/systemd/system/safe-mode.service | 6 +
.../openslx/iptables/rules.d/00-internal-network | 13 +
.../data/opt/openslx/scripts/systemd-safe_mode | 59 ++
remote/modules/safe-mode/module.build | 12 +
remote/modules/safe-mode/module.conf | 3 +
13 files changed, 1311 insertions(+)
create mode 100755 remote/modules/firefox/data/opt/openslx/scripts/firefox-session
create mode 100755 remote/modules/firefox/data/usr/share/xsessions/firefox.desktop
create mode 100644 remote/modules/firefox/module.build
create mode 100644 remote/modules/firefox/module.conf
create mode 100644 remote/modules/firefox/module.conf.ubuntu
create mode 100644 remote/modules/openbox/data/etc/xdg/openbox/rc.xml
create mode 100644 remote/modules/openbox/data/etc/xdg/openbox/rc.xml.safe
create mode 120000 remote/modules/safe-mode/data/etc/systemd/system/basic.target.wants/safe-mode.service
create mode 100644 remote/modules/safe-mode/data/etc/systemd/system/safe-mode.service
create mode 100755 remote/modules/safe-mode/data/opt/openslx/iptables/rules.d/00-internal-network
create mode 100755 remote/modules/safe-mode/data/opt/openslx/scripts/systemd-safe_mode
create mode 100644 remote/modules/safe-mode/module.build
create mode 100644 remote/modules/safe-mode/module.conf
(limited to 'remote/modules')
diff --git a/remote/modules/firefox/data/opt/openslx/scripts/firefox-session b/remote/modules/firefox/data/opt/openslx/scripts/firefox-session
new file mode 100755
index 00000000..1c8d5590
--- /dev/null
+++ b/remote/modules/firefox/data/opt/openslx/scripts/firefox-session
@@ -0,0 +1,6 @@
+#!/bin/ash
+
+. /opt/openslx/config
+
+openbox &
+exec /usr/bin/firefox --new-window "$SLX_BROWSER_START_URL" -fullscreen
diff --git a/remote/modules/firefox/data/usr/share/xsessions/firefox.desktop b/remote/modules/firefox/data/usr/share/xsessions/firefox.desktop
new file mode 100755
index 00000000..c639f9ae
--- /dev/null
+++ b/remote/modules/firefox/data/usr/share/xsessions/firefox.desktop
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=Firefox
+Exec=/opt/openslx/scripts/firefox-session
+Icon=
+Type=Application
diff --git a/remote/modules/firefox/module.build b/remote/modules/firefox/module.build
new file mode 100644
index 00000000..bd2e4624
--- /dev/null
+++ b/remote/modules/firefox/module.build
@@ -0,0 +1,15 @@
+fetch_source() {
+ :
+}
+
+build() {
+ COPYLIST="list_dpkg_output"
+ [ -e "$COPYLIST" ] && rm "$COPYLIST"
+
+ list_packet_files >> "$COPYLIST"
+ tarcopy "$(cat "$COPYLIST" | sort -u)" "${MODULE_BUILD_DIR}"
+}
+
+post_copy() {
+ :
+}
diff --git a/remote/modules/firefox/module.conf b/remote/modules/firefox/module.conf
new file mode 100644
index 00000000..0718324f
--- /dev/null
+++ b/remote/modules/firefox/module.conf
@@ -0,0 +1,6 @@
+REQUIRED_BINARIES="
+ firefox
+"
+REQUIRED_DIRECTORIES="
+ /
+"
diff --git a/remote/modules/firefox/module.conf.ubuntu b/remote/modules/firefox/module.conf.ubuntu
new file mode 100644
index 00000000..45f7e899
--- /dev/null
+++ b/remote/modules/firefox/module.conf.ubuntu
@@ -0,0 +1,2 @@
+REQUIRED_INSTALLED_PACKAGES="firefox"
+REQUIRED_CONTENT_PACKAGES="firefox"
diff --git a/remote/modules/openbox/data/etc/xdg/openbox/rc.xml b/remote/modules/openbox/data/etc/xdg/openbox/rc.xml
new file mode 100644
index 00000000..6498a7ff
--- /dev/null
+++ b/remote/modules/openbox/data/etc/xdg/openbox/rc.xml
@@ -0,0 +1,756 @@
+
+
+
+
+
+
+
+ 10
+ 20
+
+
+
+ yes
+
+ no
+
+ yes
+
+ no
+
+ 200
+
+ no
+
+
+
+
+ Smart
+
+ yes
+
+ Primary
+
+ 1
+
+
+
+
+ Clearlooks
+ NLIMC
+
+ 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
+
+
+
+
+
+
+ 4
+ 1
+
+
+
+ 875
+
+
+
+
+ yes
+ Nonpixel
+
+ Center
+
+
+
+
+ 10
+
+ 10
+
+
+
+
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ TopLeft
+
+ 0
+ 0
+ no
+ Above
+
+ Vertical
+
+ no
+ 300
+
+ 300
+
+ Middle
+
+
+
+
+ C-g
+
+
+
+ leftno
+
+
+ rightno
+
+
+ upno
+
+
+ downno
+
+
+ leftno
+
+
+ rightno
+
+
+ upno
+
+
+ downno
+
+
+ 1
+
+
+ 2
+
+
+ 3
+
+
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ gnome-screenshot -w
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ yesyes
+
+
+
+
+
+
+
+
+
+
+
+ right
+
+
+
+
+ left
+
+
+
+
+ up
+
+
+
+
+ down
+
+
+
+
+
+
+
+ true
+ Konqueror
+
+ kfmclient openProfile filemanagement
+
+
+
+
+ gnome-screenshot
+
+
+
+
+ 1
+
+ 500
+
+ 400
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ previous
+
+
+ next
+
+
+ previous
+
+
+ next
+
+
+ previous
+
+
+ next
+
+
+
+
+
+
+
+
+
+
+
+
+
+ no
+
+
+
+
+
+
+
+
+
+
+ yes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ top
+
+
+
+
+
+ left
+
+
+
+
+
+ right
+
+
+
+
+
+ bottom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ vertical
+
+
+ horizontal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ previous
+
+
+ next
+
+
+
+ previous
+
+
+ next
+
+
+ previous
+
+
+ next
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ previous
+
+
+ next
+
+
+ previous
+
+
+ next
+
+
+
+
+
+
+
+
+
+yes
+
+
+
+
diff --git a/remote/modules/openbox/data/etc/xdg/openbox/rc.xml.safe b/remote/modules/openbox/data/etc/xdg/openbox/rc.xml.safe
new file mode 100644
index 00000000..fb392461
--- /dev/null
+++ b/remote/modules/openbox/data/etc/xdg/openbox/rc.xml.safe
@@ -0,0 +1,426 @@
+
+
+
+
+
+
+
+ 10
+ 20
+
+
+
+ yes
+
+ no
+
+ yes
+
+ no
+
+ 200
+
+ no
+
+
+
+
+ Smart
+
+ yes
+
+ Primary
+
+ 1
+
+
+
+
+ Clearlooks
+ NLIMC
+
+ 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
+
+
+
+
+ C-g
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ yesyes
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+ 500
+
+ 400
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+yes
+no
+
+
+
+
diff --git a/remote/modules/safe-mode/data/etc/systemd/system/basic.target.wants/safe-mode.service b/remote/modules/safe-mode/data/etc/systemd/system/basic.target.wants/safe-mode.service
new file mode 120000
index 00000000..c063e1a0
--- /dev/null
+++ b/remote/modules/safe-mode/data/etc/systemd/system/basic.target.wants/safe-mode.service
@@ -0,0 +1 @@
+../safe-mode.service
\ No newline at end of file
diff --git a/remote/modules/safe-mode/data/etc/systemd/system/safe-mode.service b/remote/modules/safe-mode/data/etc/systemd/system/safe-mode.service
new file mode 100644
index 00000000..ba11c034
--- /dev/null
+++ b/remote/modules/safe-mode/data/etc/systemd/system/safe-mode.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=Sets up safe mode (local network, no tty switch, no openbox menu)
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-safe_mode
diff --git a/remote/modules/safe-mode/data/opt/openslx/iptables/rules.d/00-internal-network b/remote/modules/safe-mode/data/opt/openslx/iptables/rules.d/00-internal-network
new file mode 100755
index 00000000..1f29500b
--- /dev/null
+++ b/remote/modules/safe-mode/data/opt/openslx/iptables/rules.d/00-internal-network
@@ -0,0 +1,13 @@
+#!/bin/ash
+
+# identify subnet of br0's ip adress
+. /opt/openslx/config
+[ -z "$SLX_PXE_CLIENT_IP" ] && echo "No client IP found in '/opt/openslx/config'." && exit 1
+
+# lets build the subnet string
+SLX_LOCAL_SUBNET="$(echo "${SLX_PXE_CLIENT_IP}" | awk -F "." '{print $1"."$2".0.0/16"}')"
+[ -z "${SLX_LOCAL_SUBNET}" ] && echo "No ip range to allow. Exiting..." && exit 1
+# now create the iptables rule for openslx-iptables stuff
+# first as a temp file, then we move it to the real destination
+iptables -A INPUT -i br0 -p tcp -s "${SLX_LOCAL_SUBNET}" -j ACCEPT
+iptables -A INPUT -i br0 -p tcp -j REJECT
diff --git a/remote/modules/safe-mode/data/opt/openslx/scripts/systemd-safe_mode b/remote/modules/safe-mode/data/opt/openslx/scripts/systemd-safe_mode
new file mode 100755
index 00000000..6e66b35d
--- /dev/null
+++ b/remote/modules/safe-mode/data/opt/openslx/scripts/systemd-safe_mode
@@ -0,0 +1,59 @@
+#!/bin/ash
+
+disable_tty_switch() {
+ cat < /etc/X11/xorg.conf.d/50-no-tty.conf
+Section "ServerFlags"
+ Option "DontVTSwitch" "true"
+EndSection
+EOF
+}
+
+disable_openbox_menu() {
+ [ ! -e "/etc/xdg/openbox/rc.xml.safe" ] && \
+ echo "No rc.xml.safe template found." && return 1
+ cp "/etc/xdg/openbox/rc.xml" "/root/rc.xml.unsafe"
+ cp "/etc/xdg/openbox/rc.xml.safe" "/etc/xdg/openbox/rc.xml"
+}
+
+disable_magic_keys() {
+ echo 0 > /proc/sys/kernel/sysrq
+}
+
+disable_cron_idleaction() {
+ rm /opt/openslx/scripts/idleaction-cron_script \
+ /opt/openslx/scripts/idleaction-scheduled_poweroff \
+ /opt/openslx/scripts/idleaction-scheduled_reboot
+}
+
+disable_systemd_auto_vt() {
+ sed -i 's/.*NAutoVTs=.*/NAutoVTs=0/g' "/etc/systemd/logind.conf"
+ systemctl restart systemd-logind
+}
+
+set_default_session() {
+ [ ! -e "/usr/share/xsessions/firefox.desktop" ] && \
+ echo "No firefox session found." && return 1
+ # we have it, copy it over default session
+ cp "/usr/share/xsessions/firefox.desktop" "/opt/openslx/xsessions/default.desktop"
+}
+
+no_autologin_delay() {
+ [ ! -e "/etc/kde4/kdm/kdmrc" ] && \
+ echo "Could not find '/etc/kde4/kdm/kdmrc'." && return 1
+ sed -i 's/^AutoLoginDelay=.*/AutoLoginDelay=0/g' "/etc/kde4/kdm/kdmrc"
+}
+
+
+. /opt/openslx/config
+
+[ -z "$SLX_BROWSER_START_URL" ] && \
+ echo "Not running in E-Klausur mode!" && \
+ exit 1
+
+disable_tty_switch
+disable_openbox_menu
+disable_magic_keys
+disable_cron_idleaction
+disable_systemd_auto_vt
+no_autologin_delay
+set_default_session
diff --git a/remote/modules/safe-mode/module.build b/remote/modules/safe-mode/module.build
new file mode 100644
index 00000000..86b1fd00
--- /dev/null
+++ b/remote/modules/safe-mode/module.build
@@ -0,0 +1,12 @@
+# fake module simply copying its data/ files
+fetch_source() {
+ :
+}
+
+build() {
+ :
+}
+
+post_copy() {
+ :
+}
diff --git a/remote/modules/safe-mode/module.conf b/remote/modules/safe-mode/module.conf
new file mode 100644
index 00000000..0cd03752
--- /dev/null
+++ b/remote/modules/safe-mode/module.conf
@@ -0,0 +1,3 @@
+REQUIRED_BINARIES=""
+REQUIRED_LIBRARIES=""
+REQUIRED_DIRECTORIES=""
--
cgit v1.2.3-55-g7522