summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-09-08 12:34:05 +0200
committerSimon Rettberg2016-09-08 12:34:05 +0200
commit6eea8f48ac415be6208ffb55167b67a539874ac4 (patch)
treebc320d527a2e62d8df2b2d6d07938426fc5c81d8
parent[pvs2] Renamed lock/unlock scripts (diff)
downloadtm-scripts-6eea8f48ac415be6208ffb55167b67a539874ac4.tar.gz
tm-scripts-6eea8f48ac415be6208ffb55167b67a539874ac4.tar.xz
tm-scripts-6eea8f48ac415be6208ffb55167b67a539874ac4.zip
[pvs2] Support fetching remote pvs2.ini; honor exam mode, dedicated flag
l---------remote/modules/pvs2/data/etc/systemd/system/multi-user.target.wants/pvsmgr.service1
-rw-r--r--remote/modules/pvs2/data/etc/systemd/system/pvsmgr.service12
-rwxr-xr-xremote/modules/pvs2/data/opt/openslx/bin/pvsstartup13
-rwxr-xr-xremote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr8
-rw-r--r--remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr30
5 files changed, 63 insertions, 1 deletions
diff --git a/remote/modules/pvs2/data/etc/systemd/system/multi-user.target.wants/pvsmgr.service b/remote/modules/pvs2/data/etc/systemd/system/multi-user.target.wants/pvsmgr.service
new file mode 120000
index 00000000..cab88a66
--- /dev/null
+++ b/remote/modules/pvs2/data/etc/systemd/system/multi-user.target.wants/pvsmgr.service
@@ -0,0 +1 @@
+../pvsmgr.service \ No newline at end of file
diff --git a/remote/modules/pvs2/data/etc/systemd/system/pvsmgr.service b/remote/modules/pvs2/data/etc/systemd/system/pvsmgr.service
new file mode 100644
index 00000000..281e1ab4
--- /dev/null
+++ b/remote/modules/pvs2/data/etc/systemd/system/pvsmgr.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Fetch up to date pvsmgr config
+DefaultDependencies=no
+After=tmp.target
+Wants=tmp.target
+Before=graphical.target
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-pvsmgr
+RemainAfterExit=yes
+
diff --git a/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup b/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup
index b77dcd51..dc7bd48a 100755
--- a/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup
+++ b/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup
@@ -1,7 +1,15 @@
#!/bin/ash
-# TODO UNTESTED!
timediff=5
+counter=0
+
+. /opt/openslx/config
+if [ -n "$SLX_PVS_CONFIG_URL" ]; then
+ [ -z "$UID" ] && UID="$(id -u)"
+ [ -z "$HOME" ] && HOME="$(getent passwd "$UID" | head -n 1 | awk -F ':' '{print $6}')"
+ wget -O "$HOME/.config/openslx/pvs2/pvs2.ini" "$SLX_PVS_CONFIG_URL"
+fi
+
while [ $timediff -gt 3 ]; do
start="$(date +%s)"
pvsclient "$@"
@@ -10,6 +18,9 @@ while [ $timediff -gt 3 ]; do
/opt/openslx/pvs2/kb-unlock.sh
[ "$ret" == "0" ] && break
timediff=$(( end - start ))
+ counter=$(( counter + 1 ))
+ [ $counter -gt 8 ] && break
done
+exit $ret
diff --git a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr
index 7a6c13d9..f58ce099 100755
--- a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr
+++ b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr
@@ -1,4 +1,12 @@
#!/bin/ash
openbox &
+
+. /opt/openslx/config
+if [ -n "$SLX_PVS_CONFIG_URL" ]; then
+ [ -z "$UID" ] && UID="$(id -u)"
+ [ -z "$HOME" ] && HOME="$(getent passwd "$UID" | head -n 1 | awk -F ':' '{print $6}')"
+ wget -O "$HOME/.config/openslx/pvs2/pvs2.ini" "$SLX_PVS_CONFIG_URL"
+fi
+
exec /opt/openslx/bin/pvsmgr --manager-only
diff --git a/remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr b/remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr
new file mode 100644
index 00000000..34ae61d5
--- /dev/null
+++ b/remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr
@@ -0,0 +1,30 @@
+#!/bin/ash
+
+. /opt/openslx/config
+DST="/opt/openslx/pvs2/pvs2.ini"
+
+# Try to get fresh version from server
+if [ -n "$SLX_PVS_CONFIG_URL" ]; then
+ wget -O "${DST}.new" "$SLX_PVS_CONFIG_URL"
+ [ -s "${DST}.new" ] && mv -f "${DST}.new" "${DST}"
+fi
+
+# Patch exam mode according to what our fetched config says
+if [ -n "$SLX_EXAM" ]; then
+ EMODE=True
+else
+ EMODE=False
+fi
+sed -i "/^examMode/d;/^\\[General\\]/a examMode=$EMODE" "$DST"
+
+# If this is a dedicated PVS station, make it launch right away
+if [ -n "$SLX_PVS_DEDICATED" ] && cd /opt/openslx/xsessions; then
+ for file in *.desktop; do
+ cp -f "/usr/share/xsessions/pvs2mgr.desktop" "$file"
+ done
+ # patch autologin into kdmrc
+ sed -i '/AutoLogin.*=/d;/^\[X-.*-Core\]/a AutoLoginEnable=true\nAutoLoginUser=demo\nAutoLoginAgain=true\nAutoLoginDelay=0' "/etc/kde/kdm/kdmrc"
+fi
+
+exit 0
+