summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSimon Rettberg2024-01-29 12:28:01 +0100
committerSimon Rettberg2024-01-29 12:28:01 +0100
commitb41f05f8bfdd0cb232d70dd0f4f6820cbfa3af91 (patch)
tree5c086468b8b69f59f031117834ffa01bf354f4d6 /core
parentRename hardware-stats service to gather-hw-info (diff)
downloadmltk-b41f05f8bfdd0cb232d70dd0f4f6820cbfa3af91.tar.gz
mltk-b41f05f8bfdd0cb232d70dd0f4f6820cbfa3af91.tar.xz
mltk-b41f05f8bfdd0cb232d70dd0f4f6820cbfa3af91.zip
[run-virt] Split mounting of /tmp/virt into own service
Diffstat (limited to 'core')
-rw-r--r--core/modules/hardware-stats/data/etc/systemd/system/gather-hw-info.service3
-rw-r--r--core/modules/run-virt/data/etc/systemd/system/run-virt-env.service2
-rw-r--r--core/modules/run-virt/data/etc/systemd/system/run-virt-tmpdir.service9
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env31
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_tmpdir38
5 files changed, 51 insertions, 32 deletions
diff --git a/core/modules/hardware-stats/data/etc/systemd/system/gather-hw-info.service b/core/modules/hardware-stats/data/etc/systemd/system/gather-hw-info.service
index 4d782252..1d7d1ff8 100644
--- a/core/modules/hardware-stats/data/etc/systemd/system/gather-hw-info.service
+++ b/core/modules/hardware-stats/data/etc/systemd/system/gather-hw-info.service
@@ -3,7 +3,8 @@ Description=Gather hardware information about this machine
Wants=tmp.target
After=tmp.target
# Because we might mount something to /tmp/virt there, which we use for ID44 calculation
-After=run-virt-env.service
+After=run-virt-tmpdir.service
+DefaultDependencies=no
[Service]
Type=oneshot
diff --git a/core/modules/run-virt/data/etc/systemd/system/run-virt-env.service b/core/modules/run-virt/data/etc/systemd/system/run-virt-env.service
index 2c602076..285fffb4 100644
--- a/core/modules/run-virt/data/etc/systemd/system/run-virt-env.service
+++ b/core/modules/run-virt/data/etc/systemd/system/run-virt-env.service
@@ -3,6 +3,8 @@ Description=Sets up the virtualization environment
Before=graphical.target system-check.service
After=systemd-tmpfiles-setup.service bridge-additional-nics.service
Wants=systemd-tmpfiles-setup.service system-check.service bridge-additional-nics.service
+Wants=run-virt-tmpdir.service
+After=run-virt-tmpdir.service
DefaultDependencies=no
[Service]
diff --git a/core/modules/run-virt/data/etc/systemd/system/run-virt-tmpdir.service b/core/modules/run-virt/data/etc/systemd/system/run-virt-tmpdir.service
new file mode 100644
index 00000000..0b2fecfc
--- /dev/null
+++ b/core/modules/run-virt/data/etc/systemd/system/run-virt-tmpdir.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Sets up /tmp/virt virtualization scratch space
+After=tmp.target network.target
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/opt/openslx/scripts/systemd-run_virt_tmpdir
diff --git a/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env b/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env
index c3fc378e..04c1aff5 100755
--- a/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env
+++ b/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env
@@ -41,37 +41,6 @@ for DIR in /tmp/virt /var/log/samba /run/samba; do
fi
done
-# check if a fallback share is set as SLX_VM_TMP_SOURCE
-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
- [ "x$TRY" = "xSTOP" ] && 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 --delete "mount-vm-tmp-fail" "Mounting of '${SLX_VM_TMP_SOURCE}' failed." "$LOG"
- else
- slxlog "mount-vm-tmp-fail" "Mounting of '${SLX_VM_TMP_SOURCE}' failed."
- rm -f -- "$LOG"
- fi
- fi
-fi
-
-chmod a+rwxt /tmp/virt
-
################################################################################
echo "Determine host's hardware configuration"
################################################################################
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"