summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSimon Rettberg2024-01-29 11:41:58 +0100
committerSimon Rettberg2024-01-29 11:44:37 +0100
commit2ab7082564bb4289b7b95bf1eb7b7a2196a2e615 (patch)
tree7a08215ed2011c103e0aeab5322c1dc6241e2b3f /core
parentUTF-8 (diff)
downloadmltk-2ab7082564bb4289b7b95bf1eb7b7a2196a2e615.tar.gz
mltk-2ab7082564bb4289b7b95bf1eb7b7a2196a2e615.tar.xz
mltk-2ab7082564bb4289b7b95bf1eb7b7a2196a2e615.zip
[system-check/hardware-stats] Loosen dependencies
For some reason, system-check is ordered before hardware-report, but I can't figure out why. system-check merely generates the warnings to display on the login screen, and hardware-report sends hw data to the boot server. I don't see anything in hardware-report actually depending on anything system-check does. There are some other minor changes, like moving the generation of the json report from hardware-report to hardware-stats, and putting the according python script into a directory named hardware-stats instead of system-check, which might imply it belongs to that module which is wrong.
Diffstat (limited to 'core')
-rw-r--r--core/modules/hardware-stats/data/etc/systemd/system/hardware-report.service5
-rw-r--r--core/modules/hardware-stats/data/etc/systemd/system/hardware-stats.service2
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_report15
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats52
-rw-r--r--core/modules/hardware-stats/module.build2
-rw-r--r--core/modules/hardware-stats/module.conf4
-rw-r--r--core/modules/system-check/data/etc/systemd/system/system-check.service1
-rwxr-xr-xcore/modules/system-check/data/opt/openslx/scripts/systemd-system_check2
8 files changed, 36 insertions, 47 deletions
diff --git a/core/modules/hardware-stats/data/etc/systemd/system/hardware-report.service b/core/modules/hardware-stats/data/etc/systemd/system/hardware-report.service
index d4649c4a..1307e9e2 100644
--- a/core/modules/hardware-stats/data/etc/systemd/system/hardware-report.service
+++ b/core/modules/hardware-stats/data/etc/systemd/system/hardware-report.service
@@ -1,11 +1,10 @@
[Unit]
Description=Send hardware information to boot server
-After=system-check.service hardware-stats.service
-Wants=system-check.service hardware-stats.service
+After=hardware-stats.service
+Wants=hardware-stats.service
[Service]
Type=oneshot
ExecStart=/opt/openslx/scripts/systemd-hardware_report
RemainAfterExit=yes
ExecStop=/opt/openslx/scripts/shutdown-system_usage_update
-
diff --git a/core/modules/hardware-stats/data/etc/systemd/system/hardware-stats.service b/core/modules/hardware-stats/data/etc/systemd/system/hardware-stats.service
index 908c0d84..386b2f62 100644
--- a/core/modules/hardware-stats/data/etc/systemd/system/hardware-stats.service
+++ b/core/modules/hardware-stats/data/etc/systemd/system/hardware-stats.service
@@ -1,6 +1,6 @@
[Unit]
Description=Gather hardware information about this machine
-Wants=tmp.target system-check.service
+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
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_report b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_report
index 464b9742..64d0f090 100755
--- a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_report
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_report
@@ -16,8 +16,9 @@ report_hardware_info() {
return 1
fi
hwreport="/run/hwreport"
- if [ ! -s "$hwreport" ]; then
- echo "Missing hwreport file: $hwreport"
+ jsonfile="/run/hwreport.json"
+ if ! [ -s "$hwreport" ] && ! [ -s "$jsonfile" ]; then
+ echo "Missing hwreport file: $hwreport AND $jsonfile"
# TODO send data without?
return 1
fi
@@ -50,14 +51,12 @@ report_hardware_info() {
# Get IP/subnet size
local primary="${SLX_BRIDGE:-br0}"
subnet="$( ip -o -f inet addr show "$primary" | awk '/scope global/ {print $4}' )"
- # Finally, new json-based reporting
- jsonfile="$( mktemp )"
- if ! python3 /opt/openslx/system-check/collect_hw_info_json.py -p > "$jsonfile"; then
- echo -n "" > "$jsonfile"
- fi
+ # just assume the uuid/mac dumped are valid here (its checked often enough :))
+ [ -s "$hwreport" ] || touch "$hwreport"
+ [ -s "$jsonfile" ] || touch "$jsonfile"
+
# Bail out if a shutdown was triggered and submitted in the meantime
[ -e /run/openslx/shutdown.mutex ] && exit 0
- # just assume the uuid/mac dumped are valid here (its checked often enough :))
# got everything, get the last infos
uptime=$(grep -oE '^[0-9]+' /proc/uptime)
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
index 7feed991..cdeb6d63 100755
--- a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
@@ -5,48 +5,41 @@
# This script gathers information about the hardware and configuration and reports it back to the server
. /opt/openslx/config
+
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
-touch "/tmp/hw-delete-list" || exit 10
-chmod 0600 "/tmp/hw-delete-list" || exit 11
-echo -n "" > "/tmp/hw-delete-list" || exit 12
+declare -rg REPORTFILE="/run/hwreport"
+declare -rg jsonfile="/run/hwreport.json"
+
+# new json-based reporting, run first in background and wait at the end of script
+# This is only supported by Sat3.11, released 12-2023, so keep creating the old format
+# too below this call, until we don't support 3.10 anymore.
+if ! python3 /opt/openslx/hardware-stats/collect_hw_info_json.py -p > "$jsonfile"; then
+ echo -n "" > "$jsonfile"
+fi &
+
+tmpmask="/tmp/hwreport-$$."
mktemp() {
local FILE=
if [ -x /bin/mktemp ]; then
- FILE=$(/bin/mktemp)
+ FILE=$( /bin/mktemp "${tmpmask}XXXXXXXX" )
fi
if [ -z "$FILE" ] && [ -x /opt/openslx/bin/mktemp ]; then
- FILE=$(/opt/openslx/bin/mktemp)
+ FILE=$( /opt/openslx/bin/mktemp "${tmpmask}XXXXXXXX" )
fi
if [ -z "$FILE" ]; then
- local FN DIR
- for DIR in "tmp" "tmp" "tmp" "run/user/$UID" "run"; do
- FN="/${DIR}/${RANDOM}-${$}-${UID}-$(date +%N)"
- [ -e "$FN" ] && continue
- touch "$FN" || continue
- chmod 0600 "$FN" || continue
- echo -n "" > "$FN" || continue
- FILE="$FN"
- break
- done
+ FILE="${tmpmask}$RANDOM$RANDOM$$"
fi
- if [ -z "$FILE" ]; then
- # Uhm...
- echo "/dev/null"
- exit 1
- fi
- echo "$FILE" >> "/tmp/hw-delete-list"
echo "$FILE"
}
-# Can't just place all temp file names in a variable since mktemp usually runs in a subshell
-cleanup() {
- local FILE=
- while read -r FILE _ || [ -n "$FILE" ]; do
- [ -f "$FILE" ] && rm -f -- "$FILE"
- done < "/tmp/hw-delete-list"
+# Run on exit
+cleanup_exit() {
+ wait
+ rm -f -- "$tmpmask"* # no space!
+ exit 0
}
slxfdisk() {
@@ -265,7 +258,6 @@ HW_MODEL=$(bashesc "$HW_MODEL")
################################################################################
# Save raw data to report file
#
-REPORTFILE="/run/hwreport"
cat > "$REPORTFILE" <<-EOF
############################### CPU #####################################
Sockets: $CPUSOCKETS
@@ -313,6 +305,4 @@ HW_CORES='${CPUCORES}'
HW_THREADS='${VCORES}'
HORST
-cleanup
-exit 0
-
+cleanup_exit
diff --git a/core/modules/hardware-stats/module.build b/core/modules/hardware-stats/module.build
index 994b515b..c9104ab7 100644
--- a/core/modules/hardware-stats/module.build
+++ b/core/modules/hardware-stats/module.build
@@ -4,7 +4,7 @@ fetch_source() {
}
build() {
- local dir="${MODULE_BUILD_DIR}/opt/openslx/system-check"
+ local dir="${MODULE_BUILD_DIR}/opt/openslx/hardware-stats"
mkdir -p "$dir"
cde "$dir"
local file
diff --git a/core/modules/hardware-stats/module.conf b/core/modules/hardware-stats/module.conf
index b37a97c7..6547c03d 100644
--- a/core/modules/hardware-stats/module.conf
+++ b/core/modules/hardware-stats/module.conf
@@ -9,6 +9,6 @@ REQUIRED_BINARIES="
"
REQUIRED_FILES="
- /opt/openslx/system-check/collect_hw_info_json.py
- /opt/openslx/system-check/dmiparser.py
+ /opt/openslx/hardware-stats/collect_hw_info_json.py
+ /opt/openslx/hardware-stats/dmiparser.py
"
diff --git a/core/modules/system-check/data/etc/systemd/system/system-check.service b/core/modules/system-check/data/etc/systemd/system/system-check.service
index a6fdb603..76887195 100644
--- a/core/modules/system-check/data/etc/systemd/system/system-check.service
+++ b/core/modules/system-check/data/etc/systemd/system/system-check.service
@@ -3,6 +3,7 @@ Description=Report system checks
Before=display-manager.service
Wants=network-online.target
After=network-online.target
+After=hardware-stats.service
[Service]
Type=oneshot
diff --git a/core/modules/system-check/data/opt/openslx/scripts/systemd-system_check b/core/modules/system-check/data/opt/openslx/scripts/systemd-system_check
index 8011498f..d03a8e52 100755
--- a/core/modules/system-check/data/opt/openslx/scripts/systemd-system_check
+++ b/core/modules/system-check/data/opt/openslx/scripts/systemd-system_check
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Kind of a generic message generation thing. Hooks in /opt/openslx/messages.d
+# Kind of a generic message generation thing. Hooks in /opt/openslx/system-check/hooks.d
# are passed the location of the lightdm warning file on execution. They can either
# ignore it (e.g. for remote logging purposes) or just append tags to that file.
# The tags are defined in /opt/openslx/system-check/tags and will be replaced