summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_tmpdir
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_tmpdir')
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_tmpdir38
1 files changed, 38 insertions, 0 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_tmpdir b/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_tmpdir
new file mode 100755
index 00000000..e5fb324a
--- /dev/null
+++ b/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_tmpdir
@@ -0,0 +1,38 @@
+#!/bin/ash
+
+mkdir -p "/tmp/virt"
+
+. /opt/openslx/config
+
+# check if a fallback share is set as SLX_VM_TMP_SOURCE
+RET=0
+if [ -n "${SLX_VM_TMP_SOURCE}" ]; then
+ LOG=$(mktemp)
+ # use SLX_VM_TMP_TYPE and SLX_VM_TMP_OPTS, if set
+ for TRY in 1 2 3 STOP; do
+ [ "$TRY" = "STOP" ] && break
+ if [ -n "${SLX_VM_TMP_TYPE}" ] && [ -n "${SLX_VM_TMP_OPTS}" ]; then
+ mount -t "${SLX_VM_TMP_TYPE}" -o "${SLX_VM_TMP_OPTS}" "${SLX_VM_TMP_SOURCE}" /tmp/virt
+ elif [ -n "${SLX_VM_TMP_TYPE}" ]; then
+ mount -t "${SLX_VM_TMP_TYPE}" "${SLX_VM_TMP_SOURCE}" /tmp/virt
+ elif [ -n "${SLX_VM_TMP_OPTS}" ]; then
+ mount -o "${SLX_VM_TMP_OPTS}" "${SLX_VM_TMP_SOURCE}" /tmp/virt
+ else
+ mount "${SLX_VM_TMP_SOURCE}" /tmp/virt
+ fi
+ RET=$?
+ [ "$RET" = "0" ] && break
+ sleep $TRY
+ done > "$LOG" 2>&1
+ if [ "$RET" -ne "0" ]; then
+ if [ -s "$LOG" ]; then
+ slxlog --sync --delete "mount-vm-tmp-fail" "Mounting of '${SLX_VM_TMP_SOURCE}' failed." "$LOG"
+ else
+ slxlog --sync "mount-vm-tmp-fail" "Mounting of '${SLX_VM_TMP_SOURCE}' failed."
+ rm -f -- "$LOG"
+ fi
+ fi
+fi
+
+chmod a+rwxt /tmp/virt
+exit "$RET"