summaryrefslogtreecommitdiffstats
path: root/remote/modules/pvs2/data/opt/openslx
diff options
context:
space:
mode:
Diffstat (limited to 'remote/modules/pvs2/data/opt/openslx')
-rwxr-xr-xremote/modules/pvs2/data/opt/openslx/bin/pvsstartup16
-rwxr-xr-xremote/modules/pvs2/data/opt/openslx/iptables/rules.d/10-pvs11
-rwxr-xr-xremote/modules/pvs2/data/opt/openslx/pvs2/lockDesktop.sh25
-rwxr-xr-xremote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr28
-rwxr-xr-xremote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr22
-rwxr-xr-xremote/modules/pvs2/data/opt/openslx/vmchooser/sessionstart.d/50-PVSclient41
6 files changed, 135 insertions, 8 deletions
diff --git a/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup b/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup
index def24a81..16a01708 100755
--- a/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup
+++ b/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup
@@ -1,15 +1,25 @@
#!/bin/ash
-# TODO UNTESTED!
timediff=5
+counter=0
+
+. /opt/openslx/config
+EXAM=
+if [ -n "$SLX_EXAM" ]; then
+ EXAM="--exam-mode"
+fi
+
while [ $timediff -gt 3 ]; do
start="$(date +%s)"
- pvsclient $@
+ pvsclient $EXAM "$@"
ret=$?
end="$(date +%s)"
- /opt/openslx/pvs2/unlock.sh
+ /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/iptables/rules.d/10-pvs b/remote/modules/pvs2/data/opt/openslx/iptables/rules.d/10-pvs
new file mode 100755
index 00000000..a24491fa
--- /dev/null
+++ b/remote/modules/pvs2/data/opt/openslx/iptables/rules.d/10-pvs
@@ -0,0 +1,11 @@
+#!/bin/ash
+
+# Allow PVS ports
+# Control connection - server and client perspective
+iptables -I ipt-helper-INPUT 1 -i br0 -p tcp --dport 5194 -j ACCEPT
+iptables -I ipt-helper-OUTPUT 1 -o br0 -p tcp --dport 5194 -j ACCEPT
+# UDP discovery - server and client perspective
+iptables -I ipt-helper-INPUT 1 -i br0 -p udp --dport 3492 -j ACCEPT
+iptables -I ipt-helper-OUTPUT 1 -o br0 -p udp --dport 3492 -j ACCEPT
+# VNC connection - incoming (client) only - small range as we use -autoport
+iptables -I ipt-helper-INPUT 1 -i br0 -p tcp --dport 54112:54122 -j ACCEPT
diff --git a/remote/modules/pvs2/data/opt/openslx/pvs2/lockDesktop.sh b/remote/modules/pvs2/data/opt/openslx/pvs2/lockDesktop.sh
new file mode 100755
index 00000000..c9cfc421
--- /dev/null
+++ b/remote/modules/pvs2/data/opt/openslx/pvs2/lockDesktop.sh
@@ -0,0 +1,25 @@
+#!/bin/ash
+
+# Problem: While any application (e.g. VMware) is holding the mouse and
+# keyboard grab, xscreensaver couldn't grab them, so it will ignore the
+# locking request. Without the keyboard grab, all input would still go
+# to the vmware window below the black screen, which is, you know, bad,
+# since you cannot enter your password to unlock the workstation again.
+
+# So we minimize vmware, lock the screen, and then restore vmware.
+# TODO: Add other virtualizers (vbox, kvm) later if needed.
+WINDOWS=$(xdotool search --class vmplayer)
+for window in $WINDOWS; do
+ xdotool windowminimize $window
+done
+# move mouse pointer to the center of the screen to avoid some problems with ghost clicks
+xdotool mousemove --polar 0 0 --sync
+
+# now actually lock
+xscreensaver-command --lock
+
+# above lock call is blocking, so now xscreensaver should be active - let's restore vmware
+for window in $WINDOWS; do
+ xdotool windowmap $window
+done
+
diff --git a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr
index 7a6c13d9..5531518a 100755
--- a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr
+++ b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr
@@ -1,4 +1,30 @@
#!/bin/ash
+. /opt/openslx/config
+
+# Try to get fresh version from server
+CONF=
+if [ -n "$SLX_PVS_CONFIG_URL" ]; then
+ DST="$(mktemp)"
+ wget -T 5 -O "${DST}" "$SLX_PVS_CONFIG_URL"
+ [ -s "${DST}" ] && CONF="--config=${DST}"
+fi
+
openbox &
-exec /opt/openslx/bin/pvsmgr --manager-only
+
+timediff=5
+counter=0
+
+while [ $timediff -gt 3 ]; do
+ start="$(date +%s)"
+ /opt/openslx/bin/pvsmgr "$CONF" "$@"
+ ret=$?
+ [ "$ret" == "0" ] && break
+ end="$(date +%s)"
+ timediff=$(( end - start ))
+ counter=$(( counter + 1 ))
+ [ $counter -gt 8 ] && break
+done
+
+exit $ret
+
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 100755
index 00000000..1a56e8d0
--- /dev/null
+++ b/remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr
@@ -0,0 +1,22 @@
+#!/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 -T 10 -O "${DST}.new" "$SLX_PVS_CONFIG_URL"
+ [ -s "${DST}.new" ] && mv -f "${DST}.new" "${DST}"
+fi
+
+# 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
+
diff --git a/remote/modules/pvs2/data/opt/openslx/vmchooser/sessionstart.d/50-PVSclient b/remote/modules/pvs2/data/opt/openslx/vmchooser/sessionstart.d/50-PVSclient
index 86f26a17..5ff03227 100755
--- a/remote/modules/pvs2/data/opt/openslx/vmchooser/sessionstart.d/50-PVSclient
+++ b/remote/modules/pvs2/data/opt/openslx/vmchooser/sessionstart.d/50-PVSclient
@@ -1,6 +1,6 @@
#!/bin/ash
-# SESSION_TYPE can be either 'VSESSION' or 'XSESSION' - currently not evaluated
+# SESSION_TYPE can be either 'VSESSION' or 'XSESSION'
# detect session command of the PVS-Manager session by looking at the xsession file
PVSMGR_SESSION_CMD=
@@ -17,10 +17,43 @@ if [ -n "${PVSMGR_SESSION_CMD}" ]; then
# do not start pvsclient if we are running the pvs manager session
[ "x${SESSION_CMD}" == "x${PVSMGR_SESSION_CMD}" ] && exit 0
fi
+
+# Download fresh copy of config file if possible
+. /opt/openslx/config
+PVSCONFIG=
+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}')"
+ mkdir -p "$HOME/.tmp"
+ if wget -T 5 -O "$HOME/.tmp/pvs2.ini.tmp" "$SLX_PVS_CONFIG_URL"; then
+ mv -f "$HOME/.tmp/pvs2.ini.tmp" "$HOME/.tmp/pvs2.ini"
+ fi
+ if ! [ -s "$HOME/.tmp/pvs2.ini" ] && [ -s "/opt/openslx/pvs2/pvs2.ini" ]; then
+ cp -f "/opt/openslx/pvs2/pvs2.ini" "$HOME/.tmp/pvs2.ini"
+ fi
+ if [ -s "$HOME/.tmp/pvs2.ini" ]; then
+ PVSCONFIG="--config=$HOME/.tmp/pvs2.ini"
+ fi
+fi
+
# If the ENV var PVS has been set by vmchooser start pvsclient
-if [ -n "$PVS_AUTO_CONNECT" -a "$PVS_AUTO_CONNECT" == "TRUE" ]; then
- pvsstartup --auto &
+if [ "$PVS_AUTO_CONNECT" == "TRUE" ]; then
+ pvsstartup "$PVSCONFIG" --auto &
else
- pvsstartup &
+ pvsstartup "$PVSCONFIG" &
fi
+
+# Finally, handle hybrid mode where the pvsmgr is launched on the second desktop
+# alongside the actual vm. (make sure this is a VSESSION!)
+if [ "$SESSION_TYPE" == "VSESSION" ]; then
+ {
+ wt="PVS2-Manager"
+ pvsmgr "$PVSCONFIG" --manager-only &
+ for i in 100 100 200 200 200 300 500 500 1000; do
+ usleep $(( i * 1000 )) || sleep 1
+ wmctrl -r "$wt" -t 1
+ done
+ } &
+fi
+
exit 0