summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d
diff options
context:
space:
mode:
authorJonathan Bauer2018-12-12 14:27:04 +0100
committerJonathan Bauer2018-12-12 14:27:04 +0100
commit227dc993f09592b57320130a0d6231fc2b60550b (patch)
tree4dc9057f7d5be4d02c28197725a39c7cd4ba2d9b /core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d
parent[vmchooser] respect new urls params from resource_urls.conf (diff)
downloadmltk-227dc993f09592b57320130a0d6231fc2b60550b.tar.gz
mltk-227dc993f09592b57320130a0d6231fc2b60550b.tar.xz
mltk-227dc993f09592b57320130a0d6231fc2b60550b.zip
[run-virt] rework resource management
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d')
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc32
1 files changed, 2 insertions, 30 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc
index 5729373a..10786257 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc
@@ -2,34 +2,6 @@
# Include: Setup virtual floppy for drive b: #
##############################################
## Functions ##
-# download the given resource for this lecture
-# and makes it accessible globally through a
-# variable of the same name. Given name will be
-# put to lower case before wget'ing so its safe
-# to use upper case variables...
-load_dmsd_resource() {
- [ $# -eq 0 ] && writelog "Missing argument for resource." && return
- while [ $# -gt 0 ]; do
- local RESOURCE="$1"
- declare -g ${RESOURCE}="${TMPDIR}/${RESOURCE}"
- local RESOURCE_URL="${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID}/$(echo $1 | awk '{print tolower($0)}')"
- shift
- echo "DOWNLOAD to ${!RESOURCE}"
- if ! wget -T 6 -O "${!RESOURCE}" "${RESOURCE_URL}" 2> /dev/null >&2; then
- writelog "Downloading runscript from '${RESOURCE_URL}' failed."
- continue
- fi
- if [ ! -s "${!RESOURCE}" ]; then
- # zero bytes, log and ignore
- writelog "Downloaded resource from '${RESOURCE_URL}' has zero bytes."
- unset "${RESOURCE}"
- else
- # there is stuff in it, make it readonly
- readonly "${RESOURCE}"
- fi
- done
- return 0
-}
setup_virtual_floppy() {
declare -rg SLX_FLOPPY_IMG="${TMPDIR}/floppy.img"
declare -rg TMPHOME="${HOME}"
@@ -88,7 +60,7 @@ setup_virtual_floppy() {
# openslx.exe expects network shares line in the following format:
# <path> <letter> <shortcut> <username> <password>
# which is coincidentally the one we received from dmsd :)
- if [ -f "$NETSHARES" ] || load_dmsd_resource NETSHARES; then
+ if [ -f "$NETSHARES" ] || download_file "$url_lecture_netshares" "$NETSHARES"; then
if [ -s "${NETSHARES}" ]; then
# try to detect if we are running windows and replace '/' with '\'
# in an attempt to fix an improperly given samba path
@@ -107,7 +79,7 @@ setup_virtual_floppy() {
# Check downloaded runscript and handle options like
# extension, visibility flag, ...
# options are 'key=value' pairs separated with ';'
- if [ -f "$RUNSCRIPT" ] || load_dmsd_resource RUNSCRIPT; then
+ if [ -f "$RUNSCRIPT" ] || download_file "$url_lecture_runscript" "$RUNSCRIPT"; then
if [ -s "$RUNSCRIPT" ]; then
IFS=$'\n'
for OPT in $(head -n 1 "$RUNSCRIPT" | tr ";" "\n"); do