summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/run-virt/data')
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/scripts/vmchooser-xml_filter75
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/system-check/hooks.d/30-run-virt2
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc14
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc25
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc3
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_network_shares.inc17
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc5
7 files changed, 18 insertions, 123 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-xml_filter b/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-xml_filter
deleted file mode 100755
index 2d2df304..00000000
--- a/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-xml_filter
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-# Probably needs bash somewhere
-# -----------------------------------------------------------------------------
-#
-# Copyright (c) 2007..2018 bwLehrpool-Projektteam
-#
-# This program/file is free software distributed under the GPL version 2.
-# See https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
-#
-# If you have any feedback please consult https://bwlehrpool.de and
-# send your feedback to support@bwlehrpool.de.
-#
-# General information about bwLehrpool can be found at https://bwlehrpool.de
-#
-# -----------------------------------------------------------------------------
-# xmlfilter.sh
-# - This script is invoked by the vmchooser tool. It simply filters xml-
-# files (taking the path to these files in $1). You might modify it in any
-# way to match your needs, e.g. ask some database instead. You can re-
-# implement it in any other programming language too. You simply have to
-# return a list of proper xml files to be interpreted by the vmchooser
-# binary). Please check for vmchooser.sh too ...
-# -----------------------------------------------------------------------------
-
-# This script .
-#
-# currently:
-# - filter for slxgrp (which comes from /etc/machine-setup)
-#
-
-# include default directories
-. /opt/openslx/config
-
-if [ -f "${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf" ]; then
- . "${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf"
-fi
-
-function handlePersistentVM() {
- if grep --extended-regexp -q "<persistent param=\"(|.+:)$USER(|:.+)\"" "$1"; then
- # If this virtual machine is useable as persistent version for current
- # user we provide an additional persistent version.
- # TODO: This evil black magic needs to be rewritten some day (by someone who understands it)
- local originalImagePath=$(grep -io '<image_name param=.*"' "$1" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')
- local imageName=$(basename "$originalImagePath")
- eval export SLX_VM_PERSISTENT_PATH="${SLX_VM_PERSISTENT_PATH}" && \
- local imagePath="${SLX_VM_PERSISTENT_PATH}${imageName}"
- local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename "$1")"
- local vmchooserFilePath="$(dirname "$0")/vmchooser-clc"
- if [ ! -f "$vmchooserFilePath" ]; then
- vmchooserFilePath='/opt/openslx/scripts/vmchooser-clc'
- fi
- "$vmchooserFilePath" "$1" "$persistentConfigVersionFilePath" \
- --create-persistent-config "$imagePath" && \
- echo "$persistentConfigVersionFilePath"
- fi
-}
-
-for FILE in $(find -L "$1" -iname "*.xml"); do
- # filter all xmls which aren't set active
- grep -i -q "<active param=.*true.*" "$FILE" || continue
- # HACK: filter all virtualbox images, as vbox is not ready yet
- grep -i -q "<virtualmachine param=.*virtualbox.*" "$FILE" && continue
- if [ -n "${SLX_VM_POOL_FILTER}" ]; then
- # filter all xmls with pool-param not equal to vmchooser::env
- if [ $(grep "<pools param=\"${SLX_VM_POOL_FILTER}\"" "$FILE" | wc -l) -eq 1 ]; then
- handlePersistentVM "$FILE"
- echo "$FILE"
- fi
- else
- handlePersistentVM "$FILE"
- # if there is no pool set, just take all available xmls
- echo "$FILE"
- fi
-done
-
diff --git a/core/modules/run-virt/data/opt/openslx/system-check/hooks.d/30-run-virt b/core/modules/run-virt/data/opt/openslx/system-check/hooks.d/30-run-virt
index 27d85164..61cba10b 100755
--- a/core/modules/run-virt/data/opt/openslx/system-check/hooks.d/30-run-virt
+++ b/core/modules/run-virt/data/opt/openslx/system-check/hooks.d/30-run-virt
@@ -2,7 +2,7 @@
. /opt/openslx/config
. /opt/openslx/bin/slx-tools
-. /run/hwinfo
+. /run/openslx/hwinfo
if [ -n "$1" ]; then
exec >> "$1"
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
index 918a767f..2ae010b3 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
@@ -13,11 +13,11 @@
# Use: 00:FF:00 for firtual machines ;)
## Functions ##
-# Import /run/hwinfo variables
+# Import /run/openslx/hwinfo variables
import_hwinfo() {
- $(safesource "/run/hwinfo")
+ $(safesource "/run/openslx/hwinfo")
}
-# Sets the VM's hostname to the original hostname prefixed with a fixed string and its ID
+# Sets the VM's hostname to the original hostname prefixed with a fixed string and its ID
set_virt_hostname() {
declare -rg HOSTNAME="virt${VM_ID}-$(hostname)"
writelog "\tVM Hostname:\t\t$HOSTNAME"
@@ -115,10 +115,10 @@ set_virt_mac() {
# If the variables in virtualization.conf is set, "TRUE" is assigned,
# "FALSE" otherwise.
check_optical_drives() {
- # TODO This should only handle exam mode here, maybe even have one function
- # that prepares all exam mode related stuff. Then create the TRUE/FALSE
- # variables somewhere in the vmware plugin, since it's specific to that
- # plugin.
+ # TODO This should not handle exam mode here (and special cases in
+ # 100 other places), maybe have one function that prepares all exam
+ # mode related stuff. Then create the TRUE/FALSE variables somewhere
+ # in the vmware plugin, since it's specific to that plugin.
FLOPPY0="FALSE"
CDROM0="FALSE"
CDROM1="FALSE"
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
index 80403356..081c2e79 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
@@ -66,7 +66,7 @@ $BODY"
TITLE="ERROR"
fi
# Zenity should yield the nicest result
- # TODO the title is only set as the window name,
+ # Note: the title is only set as the window name,
# which cannot be seen without a window manager
zenity --error --title "$TITLE" --text "$BODY"
local RET=$?
@@ -330,14 +330,17 @@ call_post_source() {
# Helper called after sourcing the file via safesource. It just calls the
# functions in the same order they were registered.
run_post_source() {
- [ $# -ne 1 ] && writelog "'${FUNCNAME[0]}' expects one argument only! $# given." && return 1
+ if [ $# -ne 1 ]; then
+ writelog "'${FUNCNAME[0]}' expects one argument only! $# given."
+ EXIT_REASON="Interner Fehler in run_post_source" cleanexit 1
+ fi
local TASK RET
"$DEBUG" && writelog "Running post-source hooks for ${1}..."
for TASK in ${RUN_POST_SOURCE["${1}"]}; do
# sanity checks
if ! is_function "$TASK"; then
writelog "\tRegistered function '$TASK' is not a function!"
- return 1 # TODO maybe even cleanexit here as this seems very bad...
+ EXIT_REASON="Konnte safesource-hook nicht ausführen" cleanexit 1
fi
"$DEBUG" && writelog " - ${TASK}"
"${TASK}"
@@ -498,22 +501,6 @@ check_dep() {
isset ONEOF && return 1 || return 0
}
-# TODO: This is only used once in the whole script:
-# to cleanup the os string stored in the xml
-# Since the rework of this script, the os strings come from
-# the satellite server which already gives us a sanitized string
-# thus this function might not be needed anymore, as calling it on
-# new gen os strings effectively does nothing.
-# Removes any non-alphanumerical and non-hyphen chars
-# from the given parameters.
-clean_string() {
- if [ "$#" -ge 1 ]; then
- echo "$@" | tr 'A-Z' 'a-z' | tr -d -c 'a-z0-9\-'
- else
- tr 'A-Z' 'a-z' | tr -d -c 'a-z0-9\-'
- fi
-}
-
# Helper to detect given cpu flags.
# If more than one flag is given, assume that matching
# any of them is sufficient.
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc
index 92ff2186..097e9660 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc
@@ -22,6 +22,5 @@ if check_dep slxfwtool; then
reg_feature_handler "firewall" "setup_firewall"
else
writelog "Could not find 'slxfwtool' in PATH: $PATH. Netrules firewall will not work!"
- error_user "Fehler" "Keine Unterstützung von veranstaltungspezifische Firewall-Regeln!"
- # TODO handle
+ error_user "Fehler" "Keine Unterstützung für veranstaltungspezifische Firewall-Regeln!"
fi
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_network_shares.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_network_shares.inc
deleted file mode 100644
index 8809b218..00000000
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_network_shares.inc
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-# TODO this currently is not used.
-# This should be continued when we have a clear idea
-# how we will embed network shares in VMs
-set_network_shares() {
-
- # Add rw share for home dir
- HOME_SHARE_PATH="${HOME}/PERSISTENT"
- HOME_SHARE_NAME="home"
-
- # Add common share
- COMMON_SHARE_PATH="${HOME}/SHARE"
- COMMON_SHARE_NAME="share"
-}
-
-reg_feature_handler "netshares" "set_network_shares"
-
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc
index 7313ccb6..cb85f7c5 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc
@@ -6,7 +6,7 @@
## Functions ##
setup_sound() {
unset VOL
- if $(safesource "/run/hwinfo") ; then
+ if $(safesource "/run/openslx/hwinfo") ; then
# On startup, the volume of Master, PCM, Speaker, etc. will be set to 100%
# Some hardware with builtin speakers might be a bit too loud then, so you can
# define an exception table here. Array key is "Manufacturer//Model"
@@ -64,8 +64,9 @@ set_sound_alsa() {
writelog --quiet "\tSound card count: $SOUND_CARD_COUNT"
# Adjust sound volume (playback)... Random mixer names we have encountered during testing
- # TODO instead of trying to set volume blindly, why not use 'amixer scontrols' to find
+ # Instead of trying to set volume blindly, why not use 'amixer scontrols' to find
# which mixer control exists and set these only?
+ # # ^ because lazy
writelog --quiet "Setting up volume to '$VOL' via amixer..."
amixer -q -c "$SOUND_CARD_INDEX" -s <<-EOF