From a3870d7f226126e5b85d5149069d5a846c5ce17f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 8 Sep 2016 11:15:56 +0200 Subject: Formatting --- .../pvs2/data/opt/openslx/vmchooser/sessionstart.d/50-PVSclient | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'remote/modules/pvs2/data') 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..0b13b39b 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 @@ -19,8 +19,8 @@ if [ -n "${PVSMGR_SESSION_CMD}" ]; then 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 & + pvsstartup --auto & else - pvsstartup & + pvsstartup & fi exit 0 -- cgit v1.2.3-55-g7522 From 6fdaaf6b54f187f6961d1fc36cb5c76ed8d22879 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 8 Sep 2016 11:30:51 +0200 Subject: [pvs2] Renamed lock/unlock scripts --- remote/modules/pvs2/data/opt/openslx/bin/pvsstartup | 4 ++-- remote/modules/pvs2/module.build | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'remote/modules/pvs2/data') diff --git a/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup b/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup index def24a81..b77dcd51 100755 --- a/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup +++ b/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup @@ -4,10 +4,10 @@ timediff=5 while [ $timediff -gt 3 ]; do start="$(date +%s)" - pvsclient $@ + pvsclient "$@" ret=$? end="$(date +%s)" - /opt/openslx/pvs2/unlock.sh + /opt/openslx/pvs2/kb-unlock.sh [ "$ret" == "0" ] && break timediff=$(( end - start )) done diff --git a/remote/modules/pvs2/module.build b/remote/modules/pvs2/module.build index 70b88350..970c3c00 100644 --- a/remote/modules/pvs2/module.build +++ b/remote/modules/pvs2/module.build @@ -26,9 +26,9 @@ build() { # copy external scripts under 'sample_configuration' mkdir -p "${MODULE_BUILD_DIR}/opt/openslx/pvs2/" if [ -d "${SRCDIR}/sample_configuration" ]; then - cp ${SRCDIR}/sample_configuration/*.sh "${MODULE_BUILD_DIR}/opt/openslx/pvs2/" \ + cp "${SRCDIR}/sample_configuration"/{kb-lock,kb-unlock,lockDesktop,switchToManager,switchBack}.sh "${MODULE_BUILD_DIR}/opt/openslx/pvs2/" \ || perror "Could not copy external scripts to '${MODULE_BUILD_DIR}/opt/openslx/pvs2/'!" - chmod +x ${MODULE_BUILD_DIR}/opt/openslx/pvs2/*.sh \ + chmod +x "${MODULE_BUILD_DIR}/opt/openslx/pvs2"/*.sh \ || perror "Could not set executable bit for external scripts." fi -- cgit v1.2.3-55-g7522 From 6eea8f48ac415be6208ffb55167b67a539874ac4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 8 Sep 2016 12:34:05 +0200 Subject: [pvs2] Support fetching remote pvs2.ini; honor exam mode, dedicated flag --- .../system/multi-user.target.wants/pvsmgr.service | 1 + .../pvs2/data/etc/systemd/system/pvsmgr.service | 12 +++++++++ .../modules/pvs2/data/opt/openslx/bin/pvsstartup | 13 +++++++++- .../pvs2/data/opt/openslx/scripts/setup-pvsmgr | 8 ++++++ .../pvs2/data/opt/openslx/scripts/systemd-pvsmgr | 30 ++++++++++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 120000 remote/modules/pvs2/data/etc/systemd/system/multi-user.target.wants/pvsmgr.service create mode 100644 remote/modules/pvs2/data/etc/systemd/system/pvsmgr.service create mode 100644 remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr (limited to 'remote/modules/pvs2/data') 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 + -- cgit v1.2.3-55-g7522 From c3a8cb57f19b390ac3437866aa17cf4e413e7145 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 8 Sep 2016 18:02:50 +0200 Subject: [pvs2] +x in scripts is helpful... --- remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr (limited to 'remote/modules/pvs2/data') diff --git a/remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr b/remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr old mode 100644 new mode 100755 -- cgit v1.2.3-55-g7522 From 6c1cbb8e124a2a98b3144b822c6979ab171e2fd3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 9 Sep 2016 15:37:39 +0200 Subject: [pvs2] Add iptables-helper file so pvs still works when a lecture uses firewalling --- remote/modules/pvs2/data/opt/openslx/iptables/rules.d/10-pvs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 remote/modules/pvs2/data/opt/openslx/iptables/rules.d/10-pvs (limited to 'remote/modules/pvs2/data') 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 -- cgit v1.2.3-55-g7522 From 7b171ef04afab139b3243894ff195ce8a58f9341 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 4 Oct 2016 14:31:18 +0200 Subject: [pvs2] Implement hybrid mode where the manager is running on the second virtual desktop --- .../pvs2/data/opt/openslx/scripts/setup-pvsmgr | 8 +------ .../openslx/vmchooser/sessionstart.d/50-PVSclient | 26 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 9 deletions(-) (limited to 'remote/modules/pvs2/data') diff --git a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr index f58ce099..f39e03aa 100755 --- a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr +++ b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr @@ -2,11 +2,5 @@ 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 "$@" -exec /opt/openslx/bin/pvsmgr --manager-only 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 0b13b39b..a2d56049 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,32 @@ 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 + +. /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 + # If the ENV var PVS has been set by vmchooser start pvsclient -if [ -n "$PVS_AUTO_CONNECT" -a "$PVS_AUTO_CONNECT" == "TRUE" ]; then +if [ "$PVS_AUTO_CONNECT" == "TRUE" ]; then pvsstartup --auto & else pvsstartup & 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 --manager-only & + for i in 250 250 500 500 1000; do + usleep $(( i * 1000 )) || sleep 1 + wmctrl -r "$wt" -t 1 + done + } & +fi + exit 0 -- cgit v1.2.3-55-g7522 From 786df0669f73375d4bf5703c422e910839b7717f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 10 Oct 2016 19:37:42 +0200 Subject: [pvs2] Use command line option for config file location; use new client side exam mode config --- remote/modules/pvs2/data/opt/openslx/bin/pvsstartup | 9 ++++----- .../pvs2/data/opt/openslx/scripts/setup-pvsmgr | 9 +++++++++ .../pvs2/data/opt/openslx/scripts/systemd-pvsmgr | 10 +--------- .../openslx/vmchooser/sessionstart.d/50-PVSclient | 21 ++++++++++++++++----- 4 files changed, 30 insertions(+), 19 deletions(-) (limited to 'remote/modules/pvs2/data') diff --git a/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup b/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup index dc7bd48a..16a01708 100755 --- a/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup +++ b/remote/modules/pvs2/data/opt/openslx/bin/pvsstartup @@ -4,15 +4,14 @@ 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" +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/kb-unlock.sh diff --git a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr index f39e03aa..be44e87e 100755 --- a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr +++ b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr @@ -1,5 +1,14 @@ #!/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 5 -O "${DST}.new" "$SLX_PVS_CONFIG_URL" + [ -s "${DST}.new" ] && mv -f "${DST}.new" "${DST}" +fi + openbox & exec /opt/openslx/bin/pvsmgr "$@" diff --git a/remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr b/remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr index 34ae61d5..1a56e8d0 100755 --- a/remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr +++ b/remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr @@ -5,18 +5,10 @@ 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" + wget -T 10 -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 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 a2d56049..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 @@ -18,18 +18,29 @@ if [ -n "${PVSMGR_SESSION_CMD}" ]; then [ "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}')" - wget -O "$HOME/.config/openslx/pvs2/pvs2.ini" "$SLX_PVS_CONFIG_URL" + 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 [ "$PVS_AUTO_CONNECT" == "TRUE" ]; then - pvsstartup --auto & + pvsstartup "$PVSCONFIG" --auto & else - pvsstartup & + pvsstartup "$PVSCONFIG" & fi # Finally, handle hybrid mode where the pvsmgr is launched on the second desktop @@ -37,8 +48,8 @@ fi if [ "$SESSION_TYPE" == "VSESSION" ]; then { wt="PVS2-Manager" - pvsmgr --manager-only & - for i in 250 250 500 500 1000; do + 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 -- cgit v1.2.3-55-g7522 From a0ddd91d14a371ec692fa711c9e40cb6590e24f7 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 10 Oct 2016 19:55:27 +0200 Subject: [pvs2] Let's try this.... --- remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'remote/modules/pvs2/data') diff --git a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr index be44e87e..aaaf85d2 100755 --- a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr +++ b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr @@ -1,15 +1,16 @@ #!/bin/ash . /opt/openslx/config -DST="/opt/openslx/pvs2/pvs2.ini" # Try to get fresh version from server +CONF= if [ -n "$SLX_PVS_CONFIG_URL" ]; then - wget -T 5 -O "${DST}.new" "$SLX_PVS_CONFIG_URL" - [ -s "${DST}.new" ] && mv -f "${DST}.new" "${DST}" + DST="$(mktemp)" + wget -T 5 -O "${DST}" "$SLX_PVS_CONFIG_URL" + [ -s "${DST}" ] && CONF="--config=${DST}" fi openbox & -exec /opt/openslx/bin/pvsmgr "$@" +exec /opt/openslx/bin/pvsmgr "$CONF" "$@" -- cgit v1.2.3-55-g7522 From 49b0840fe6f510e88d53894675784a6813cf910e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 11 Oct 2016 18:07:40 +0200 Subject: [pvs2] Ship own lock script that will minimize and maximize vmware to release its mouse/keyboard grab --- .../pvs2/data/opt/openslx/pvs2/lockDesktop.sh | 25 ++++++++++++++++++++++ remote/modules/pvs2/module.build | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 remote/modules/pvs2/data/opt/openslx/pvs2/lockDesktop.sh (limited to 'remote/modules/pvs2/data') 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/module.build b/remote/modules/pvs2/module.build index 970c3c00..607b6d5f 100644 --- a/remote/modules/pvs2/module.build +++ b/remote/modules/pvs2/module.build @@ -26,7 +26,8 @@ build() { # copy external scripts under 'sample_configuration' mkdir -p "${MODULE_BUILD_DIR}/opt/openslx/pvs2/" if [ -d "${SRCDIR}/sample_configuration" ]; then - cp "${SRCDIR}/sample_configuration"/{kb-lock,kb-unlock,lockDesktop,switchToManager,switchBack}.sh "${MODULE_BUILD_DIR}/opt/openslx/pvs2/" \ + # Do not copy lockDesktop.sh - we ship a modified one + cp "${SRCDIR}/sample_configuration"/{kb-lock,kb-unlock,switchToManager,switchBack}.sh "${MODULE_BUILD_DIR}/opt/openslx/pvs2/" \ || perror "Could not copy external scripts to '${MODULE_BUILD_DIR}/opt/openslx/pvs2/'!" chmod +x "${MODULE_BUILD_DIR}/opt/openslx/pvs2"/*.sh \ || perror "Could not set executable bit for external scripts." -- cgit v1.2.3-55-g7522 From f5fe048ba2069514b3e395869ff7b30c3f7bb013 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 31 Oct 2016 16:44:48 +0100 Subject: [pvs2] Restart pvsmgr on exit-code != 0 --- .../modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'remote/modules/pvs2/data') diff --git a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr index aaaf85d2..5531518a 100755 --- a/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr +++ b/remote/modules/pvs2/data/opt/openslx/scripts/setup-pvsmgr @@ -12,5 +12,19 @@ fi openbox & -exec /opt/openslx/bin/pvsmgr "$CONF" "$@" +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 -- cgit v1.2.3-55-g7522