diff options
author | Simon Rettberg | 2019-05-17 12:30:24 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-05-17 12:30:24 +0200 |
commit | e384d068e1f101087b85e97c35ef1d434cc7790a (patch) | |
tree | bc8130eed93bc8eee730fa3431f7fc8e70ddea25 /core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt | |
parent | [screen-standby] Remove forgotten interfering module (diff) | |
download | mltk-e384d068e1f101087b85e97c35ef1d434cc7790a.tar.gz mltk-e384d068e1f101087b85e97c35ef1d434cc7790a.tar.xz mltk-e384d068e1f101087b85e97c35ef1d434cc7790a.zip |
[run-virt] Add hook system, remove legacy code
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt')
-rwxr-xr-x | core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt b/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt index d8f7d6ba..4a4b8f16 100755 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt @@ -19,16 +19,39 @@ # tools and then include the specific plugin which configures the speci- # fied virtualization tool. ################################################################################ -SELF=$(readlink -f "$0") +SELF="$( readlink -f "${BASH_SOURCE[0]}" )" +if [ -z "$SELF" ] || ! [ -f "$SELF" ]; then + SELF="$( readlink -f "$0" )" +fi +if [ -z "$SELF" ] || ! [ -f "$SELF" ]; then + slxlog "run-virt" "Cannot find SELF" + exit 1 +fi +readonly SELF + +# Useless without this +. /opt/openslx/config + +# Debug mode? +if [ "x$1" = "x--debug" ]; then + shift + DEBUG=true +elif [ "$SLX_DEBUG_MODE" = "ON" ] || grep -qE '\bdebug\b' "/proc/cmdline"; then + DEBUG=true +else + DEBUG=false +fi # This script expects the path to the xml file describing the VM to be started declare -rg XML_FILE="$1" -# A path to the logfile can be given as second argument +# A path to the logfile can be given as second argument (will be set later if empty) declare -g LOGFILE="$2" # Functions needed by vmchooser-run_virt (writelog(), cleanexit(), safesource()) -declare -rg RUN_VIRT_INCLUDE_DIR="$(dirname $SELF)/run-virt-includes" +BASEDIR="$( dirname "${SELF}" )" +RUN_VIRT_INCLUDE_DIR="${BASEDIR}/run-virt-includes" +readonly BASEDIR RUN_VIRT_INCLUDE_DIR if ! source "${RUN_VIRT_INCLUDE_DIR}/vmchooser_runvirt_functions.inc"; then slxlog "run-virt" "Could not source ${RUN_VIRT_INCLUDE_DIR}/vmchooser_runvirt_functions.inc" exit 1 |