diff options
author | Simon Rettberg | 2019-07-09 17:11:35 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-07-09 17:11:35 +0200 |
commit | 08349fb2fd1a79861996df893cb07b152dded777 (patch) | |
tree | a1a26b8df8f42a9e1cb1273060bf3eb93a486456 /core/modules/run-virt/data/opt/openslx/scripts | |
parent | [xorg] Remove unneeded package (diff) | |
download | mltk-08349fb2fd1a79861996df893cb07b152dded777.tar.gz mltk-08349fb2fd1a79861996df893cb07b152dded777.tar.xz mltk-08349fb2fd1a79861996df893cb07b152dded777.zip |
[run-virt] Get rid of wrapper and handle directly in run-virt
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/scripts')
l---------[-rwxr-xr-x] | core/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt | 65 |
1 files changed, 1 insertions, 64 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt b/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt index 307b6872..1c989e10 100755..120000 --- a/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt +++ b/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt @@ -1,64 +1 @@ -#!/bin/bash -# Wrapper script to handle the real vmchooser-run_virt -launch_runvirt() { - if [ $# -ne 1 ]; then - # we except 1 arg only! This case is weird, so lets just not do weird things... - log "Runvirt (wrapper) expects 1 argument! $# given: $@" - return 1 - fi - - local RUNVIRT_SCRIPT="/opt/openslx/vmchooser/vmchooser-run_virt" - if [ ! -s "${RUNVIRT_SCRIPT}" ]; then - log "Missing/empty main run-virt script expected at '${RUNVIRT_SCRIPT}'!" - return 1 - fi - if ! bash -n "${RUNVIRT_SCRIPT}"; then - log "Syntax error in '${RUNVIRT_SCRIPT}'!" - return 1 - fi - - # start the main runvirt script - "${RUNVIRT_SCRIPT}" "$1" "${LOGFILE}" & - local RUNVIRT_PID="$!" - usleep 50000 - # from now on, check if the LOGFILE still exists before writing to it - # if its not, runvirt deleted it and handles the logfile on its own - if ! kill -0 "${RUNVIRT_PID}"; then - [ -f "${LOGFILE}" ] && log "Failed to start main runvirt script. Seems that it exited early?." - return 1 - fi - wait "${RUNVIRT_PID}" - # script exited here, check for exit code and send logfile to sat if appropriate - local RUNVIRT_RET="$?" - if [ ${RUNVIRT_RET} -ne 0 ]; then - if [ ${RUNVIRT_RET} -eq 141 ]; then - # 141 happens on alt + print screen + k or upon automatic logout via systemd - # just sleep here to avoid these annoying (and misleading) slxlogs.... - sleep 3 - fi - [ -f "${LOGFILE}" ] && log "Runvirt failed with '${RUNVIRT_RET}'." - return 1 - fi - return 0 -} -# Log helper -log() { - echo "$(date +%Y-%m-%d-%H-%M-%S): ## WRAPPER ## $@" >> "${LOGFILE}" -} - -## Main part -# logfile is now managed by this wrapper and given as argument to runvirt -declare -rg LOGFILE="/var/log/openslx/run-virt.$(whoami).$$.log" -if ! touch "${LOGFILE}"; then - # this should practically never happen, log it just in case - slxlog "run-virt-wrapper" "Failed to create '${LOGFILE}'." - # fallback: runvirt will try to handle it itself -fi -log "Launching runvirt with arguments '$@'..." -if ! launch_runvirt $@; then - [ -f "${LOGFILE}" ] && slxlog "run-virt-wrapper" "Failed to launch runvirt!" "${LOGFILE}" - exit 1 -fi -log "Runvirt exited as expected." -exit 0 - +../vmchooser/vmchooser-run_virt
\ No newline at end of file |