summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
diff options
context:
space:
mode:
authorSimon Rettberg2019-07-10 16:16:41 +0200
committerSimon Rettberg2019-07-10 16:16:41 +0200
commit23dc3416970c1825eff72599e807f08501fcad0a (patch)
tree1fe329fac0074f761e641d49a00f64e586942653 /core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
parent[run-virt] improve signal traps handling (diff)
downloadmltk-23dc3416970c1825eff72599e807f08501fcad0a.tar.gz
mltk-23dc3416970c1825eff72599e807f08501fcad0a.tar.xz
mltk-23dc3416970c1825eff72599e807f08501fcad0a.zip
[run-virt] Tweak init and handling of some constants; add documentation
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt')
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt23
1 files changed, 14 insertions, 9 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 aef4ba79..9d7020ed 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
@@ -29,17 +29,22 @@ if [ -z "$SELF" ] || ! [ -f "$SELF" ]; then
fi
readonly SELF
-# Useless without this
-. /opt/openslx/config
-. /opt/openslx/bin/slx-tools
-
# Global variables needed for the core functionality
-declare -rg VMCHOOSER_DIR="/opt/openslx/vmchooser"
+declare -rg VMCHOOSER_DIR="$( dirname "$SELF" )"
declare -rg VMCHOOSER_CONF_DIR="$VMCHOOSER_DIR/config"
declare -rg USER="$(whoami)"
declare -rg TMPDIR="/tmp/virt/${USER}/$$"
declare -rg CONFDIR="${TMPDIR}/metadata"
+if ! [ -d "$VMCHOOSER_DIR" ]; then
+ slxlog "run-virt" "$SELF is not in a directory!?"
+ exit 1
+fi
+
+# Useless without this
+. /opt/openslx/config
+. /opt/openslx/bin/slx-tools
+
# Debug mode?
if [ "x$1" = "x--debug" ]; then
shift
@@ -49,6 +54,7 @@ elif [ "$SLX_DEBUG_MODE" = "ON" ] || grep -qE '\bdebug\b' "/proc/cmdline"; then
else
DEBUG=false
fi
+readonly DEBUG
# Check for existence of plugin
if [ "x$1" = "x--query" ]; then
@@ -73,15 +79,14 @@ declare -rg XML_FILE="$1"
# A path to the logfile can be given as second argument
declare -g LOGFILE="$2"
if [ -z "$LOGFILE" ] || ! touch "$LOGFILE" || ! [ -f "$LOGFILE" ]; then
- LOGFILE="/var/log/openslx/run-virt.$(whoami).$$.log"
+ LOGFILE="/var/log/openslx/run-virt.${USER}.$$.log"
touch "$LOGFILE" || LOGFILE="$(mktemp)"
fi
+readonly LOGFILE
main() {
# Functions needed by vmchooser-run_virt (writelog(), cleanexit(), safesource())
- BASEDIR="$( dirname "${SELF}" )"
- RUN_VIRT_INCLUDE_DIR="${BASEDIR}/run-virt-includes"
- readonly BASEDIR RUN_VIRT_INCLUDE_DIR
+ declare -rg RUN_VIRT_INCLUDE_DIR="${VMCHOOSER_DIR}/run-virt-includes"
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