summaryrefslogblamecommitdiffstats
path: root/remote/modules/run-virt/data/opt/openslx/scripts/detect_legacy.inc
blob: f28b62de4c73df786eceee3df7c02c77463243c8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                                                                     
                                                                         









                                                             




                                                                                    
########################################################
# 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 -O "$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

if [ ! -s "$TMPDIR/$IMGUUID" ]; then
	writelog "Warning: Image.UUID file has zero bytes - triggering legacy mode."
	LEGACY=:
fi