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 --- .../pvs2/data/opt/openslx/scripts/setup-pvsmgr | 8 ++++++ .../pvs2/data/opt/openslx/scripts/systemd-pvsmgr | 30 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 remote/modules/pvs2/data/opt/openslx/scripts/systemd-pvsmgr (limited to 'remote/modules/pvs2/data/opt/openslx/scripts') 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/opt/openslx/scripts') 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 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/opt/openslx/scripts') 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/opt/openslx/scripts') 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/opt/openslx/scripts') 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 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/opt/openslx/scripts') 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