summaryrefslogtreecommitdiffstats
path: root/remote/modules/run-virt/data/opt/openslx/scripts/detect_legacy.inc
blob: 4c3a2f2bfac5d0215c2d86a633519c4735c2f877 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
########################################################
# Include: Detect, whether runvirt runs in legacy mode #
########################################################

# Legacy mode: As runvirt has been before.
# New mode: uuid in xml _and_ vmx given via http.

# First, let's try to extract an imguuid from xmlfile:
IMGUUID=$(grep -io '<uuid param=.*"' "${xmlfile}" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')

# Temporary directory for run-virt related stuff
TMPDIR=$(mktemp -d -p /tmp/virt)

# Then get a template (vmx) file via http/wget:
wget --output-document="$TMPDIR/$IMGUUID" "${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID}"

writelog "IMGUUID: -$IMGUUID- --- TMPDIR: ${TMPDIR}"

if [ -n "$IMGUUID" ] && [ -n "$TMPDIR/$IMGUUID" ]; then
	LEGACY=		# no legacy; both strings set
	writelog "Current (non-legacy) mode detected."
else
	LEGACY=:	# legacy: One or both strings not set
	writelog "Legacy mode detected."
fi