From 25dc8e0ea7af9e6d8d7806d5ecf031e3bfe187c9 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 20 Oct 2021 13:34:10 +0200 Subject: [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. --- .../data/opt/openslx/scripts/systemd-system_check | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'core/modules/system-check') 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]}" -- cgit v1.2.3-55-g7522