summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2021-10-20 13:34:10 +0200
committerSimon Rettberg2021-10-20 13:34:10 +0200
commit25dc8e0ea7af9e6d8d7806d5ecf031e3bfe187c9 (patch)
tree8e94228c54b9fdd55e0b36a579ddb702872e5195
parent[german] Yet another locale tool to call (diff)
downloadmltk-25dc8e0ea7af9e6d8d7806d5ecf031e3bfe187c9.tar.gz
mltk-25dc8e0ea7af9e6d8d7806d5ecf031e3bfe187c9.tar.xz
mltk-25dc8e0ea7af9e6d8d7806d5ecf031e3bfe187c9.zip
[system-check/hardware-stats] Refactor report stats gather split stuff
Reporting to server is now a separate service, as it slows down system-check for no reason via hooks.d. Also add a couple comments and simplifications to system-check main script. We now redirect to the tags file within the main script instead of letting each hook individually open the tags file and write to it concurrently, which seems like a bad idea in retrospect.
-rw-r--r--core/modules/hardware-stats/data/etc/systemd/system/hardware-report.service11
-rw-r--r--core/modules/hardware-stats/data/etc/systemd/system/hardware-stats.service3
l---------core/modules/hardware-stats/data/etc/systemd/system/multi-user.target.wants/hardware-report.service1
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_report (renamed from core/modules/hardware-stats/data/opt/openslx/system-check/hooks.d/50-hardware-report)0
-rwxr-xr-xcore/modules/system-check/data/opt/openslx/scripts/systemd-system_check24
5 files changed, 26 insertions, 13 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
new file mode 100644
index 00000000..d4649c4a
--- /dev/null
+++ b/core/modules/hardware-stats/data/etc/systemd/system/hardware-report.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Send hardware information to boot server
+After=system-check.service hardware-stats.service
+Wants=system-check.service 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 f23f3384..8106af74 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,5 +1,5 @@
[Unit]
-Description=Gather statistics about this machine and send to boot server
+Description=Gather hardware information about this machine
After=tmp.target mount-vm-store.service network.target run-virt-env.service
Wants=tmp.target system-check.service
Before=system-check.service
@@ -8,5 +8,4 @@ Before=system-check.service
Type=oneshot
ExecStart=/opt/openslx/scripts/systemd-hardware_stats
RemainAfterExit=yes
-ExecStop=/opt/openslx/scripts/shutdown-system_usage_update
diff --git a/core/modules/hardware-stats/data/etc/systemd/system/multi-user.target.wants/hardware-report.service b/core/modules/hardware-stats/data/etc/systemd/system/multi-user.target.wants/hardware-report.service
new file mode 120000
index 00000000..d9610279
--- /dev/null
+++ b/core/modules/hardware-stats/data/etc/systemd/system/multi-user.target.wants/hardware-report.service
@@ -0,0 +1 @@
+../hardware-report.service \ No newline at end of file
diff --git a/core/modules/hardware-stats/data/opt/openslx/system-check/hooks.d/50-hardware-report b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_report
index 09d8efc9..09d8efc9 100755
--- a/core/modules/hardware-stats/data/opt/openslx/system-check/hooks.d/50-hardware-report
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_report
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 fd6809d6..8011498f 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
@@ -10,11 +10,11 @@
declare -rg root_dir="/opt/openslx/system-check"
generate_messages() {
- local lang f hook_dir lang_dir
+ local lang f hook_dir lang_dir dm_warning_tmp dm_warning_file
hook_dir="${root_dir}/hooks.d"
lang_dir=
- # determine lang
+ # determine lang. Ignore current environment to make sure we use the system setting
for f in "/etc/default/locale" "/etc/environment"; do
lang="$( unset LANG; . "$f" &> /dev/null; [ -n "$LANG" ] && echo "${LANG:0:2}" || echo "${LANGUAGE}" )"
if [ -d "${root_dir}/lang/${lang}" ]; then
@@ -24,24 +24,26 @@ generate_messages() {
done
[ -z "$lang_dir" ] && lang_dir="${root_dir}/lang/en"
- local dm_warning_file="$( \
+ # Determine which file to put final messages into
+ dm_warning_file="$( \
awk -F'=' '$1 == "greeter-message-file" {print $2}' \
- /etc/lightdm/qt-lightdm-greeter.conf)"
+ /etc/lightdm/qt-lightdm-greeter.conf /etc/lightdm/qt-lightdm-greeter.conf.d/* \
+ | tail -n 1)"
[ -z "$dm_warning_file" ] && dm_warning_file="/run/hw-warnings.log"
- local dm_warning_tmp="$(mktemp)"
+ dm_warning_tmp="$(mktemp)"
+ # Run hooks that will generate all the warnings
if [ ! -d "$hook_dir" ]; then
echo "Missing '$hook_dir' - dev failure?"
return 1
fi
for file in "$hook_dir"/*; do
+ [ -s "$file" ] || continue
[ -x "$file" ] || continue
- (
- "$file" "$dm_warning_tmp"
- ) &
- done
+ "$file" &
+ done > "$dm_warning_tmp"
wait
- # post-process, dm_warning_file contains just tags now
+ # post-process, dm_warning_tmp contains just tags now
# check in /opt/openslx/messages/{lang,tags}
local blacklist="${root_dir}/blacklist"
local color do_contact
@@ -50,7 +52,7 @@ generate_messages() {
IFS='|' tag_with_params=($tag)
IFS="$old_IFS"
# blacklisted?
- grep -q "${tag_with_params[0]}" "$blacklist" && continue
+ grep -qFx "${tag_with_params[0]}" "$blacklist" && continue
# "meta" info?
[ -s "${root_dir}/tags/${tag_with_params[0]}" ] && \
. "${root_dir}/tags/${tag_with_params[0]}"