summaryrefslogtreecommitdiffstats
path: root/remote/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
diff options
context:
space:
mode:
Diffstat (limited to 'remote/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt')
-rwxr-xr-xremote/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt116
1 files changed, 116 insertions, 0 deletions
diff --git a/remote/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt b/remote/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
new file mode 100755
index 00000000..10943c51
--- /dev/null
+++ b/remote/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
@@ -0,0 +1,116 @@
+#!/bin/bash
+# Full bash required
+# -----------------------------------------------------------------------------
+# Copyright (c) 2007..2010 - RZ Uni FR
+# Copyright (c) 2007..2013 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# run-virt.sh
+# - This is the generic wrapper for the several virtualization solutions.
+# The idea is to setup a set of variables used by at least two different
+# tools and then include the specific plugin which configures the speci-
+# fied virtualization tool.
+################################################################################
+
+RUNVIRTINCLUDEDIR=/opt/openslx/vmchooser/run-virt-includes
+xmlfile="$1"
+
+# Functions needed by vmchooser-run_virt (writelog(), cleanexit(), rv_clean_string())
+if ! source "${RUNVIRTINCLUDEDIR}/vmchooser_runvirt_functions.inc"; then
+ slxlog "run-virt" "Could not source ${RUNVIRTINCLUDEDIR}/vmchooser_runvirt_functions.inc"
+ exit 1
+fi
+
+trap 'trap "" SIGINT SIGTERM; cleanexit' SIGINT SIGTERM
+# Define default dirs / get configs
+source "${RUNVIRTINCLUDEDIR}/set_runvirt_variables.inc"
+# Function to detect whether we can use the new way (vmx via http) or the old way (legacy):
+source "${RUNVIRTINCLUDEDIR}/detect_legacy.inc" # This yields LEGACY, IMGUUID, IMGVMX
+
+if [ "$LEGACY" ]; then
+
+ # No longer supported - yay
+
+ error_user "Legacy Mode" "
+Die gewählte VM ist eine 'Legacy VM', für die unvollständige
+Metadaten auf dem bwLehrpool-Server hinterlegt sind. Diese
+werden nicht mehr unterstützt. Um diese VM weiterhin nutzen
+zu können, muss sie mittels der bwLehrpool-Suite heruntergeladen,
+einmal gebootet, und wieder hochgeladen werden.
+(Bei der Gelegenheit könnten z.B. auch gleich anfallende Updates
+eingespielt werden.)
+"
+ cleanexit 1
+
+ # End legacy warning
+fi
+
+# Proper meta data received - proceed normally
+
+# check for important files used (filecheck()) - vestigial?
+# This include does not currently work. TODO.
+# source ${RUNVIRTINCLUDEDIR}/check_runvirt_needed_files.inc && filecheck
+
+# Read needed variables from XML file
+source ${RUNVIRTINCLUDEDIR}/get_xml_file_variables.inc
+
+# Helper that looks for virtualizer-specific include, show error to user if not found
+source "${RUNVIRTINCLUDEDIR}/setup_vm_hypervisor.inc"
+
+# For scanning for certain usb classes
+source "${RUNVIRTINCLUDEDIR}/usb_detector.inc"
+
+# Firewall
+source "${RUNVIRTINCLUDEDIR}/setup_firewall.inc" || writelog "Could not source setup_firewall"
+setup_firewall || writelog "Could not run setup_firewall"
+
+# Sound setup
+source ${RUNVIRTINCLUDEDIR}/setup_sound.inc
+
+# Declaration of hardware relatedt variables
+source ${RUNVIRTINCLUDEDIR}/set_runvirt_hardware_variables.inc
+
+# Start printer daemon
+source ${RUNVIRTINCLUDEDIR}/setup_printer_lpd.inc
+
+# Setup virtual floppy b: for windows guests with config.xml, openslx.exe etc.
+source ${RUNVIRTINCLUDEDIR}/setup_virtual_floppy.inc
+
+# Try to use dnbd3 to access the image, nfs/cifs fallback
+source ${RUNVIRTINCLUDEDIR}/setup_image_access.inc
+
+# Window manager required for handling of popups etc.
+source ${RUNVIRTINCLUDEDIR}/start_windowmanager.inc
+
+# Source run-virt.include of virtualizer
+setup_vm_commandline
+
+# It should have set this variable if all went well
+if [ -z "${VIRTCMD}" ]; then
+ error_user "Fehler beim Starten der VM-Sitzung" "
+Das Start-Script für den Virtualisierer $xmlvirt hat kein Kommando
+zum Starten der Sitzung definiert. Kann Sitzung nicht initialisieren."
+ slxlog "virt-plugin-error" "run-virt.include for $xmlvirt did not set VIRTCMD"
+ cleanexit 1
+fi
+
+writelog "VM command: eval ${VIRTCMD} ${VIRTCMDOPTS}"
+# This will start the VM
+eval ${VIRTCMD} ${VIRTCMDOPTS}
+
+writelog "Virtualizer exited. Bye."
+
+# Postrun for commands after virtualization finishes
+if [ -n "${POSTRUN}" ]; then
+ eval ${POSTRUN} >/dev/null 2>&1
+fi
+
+cleanexit 0
+