diff options
Diffstat (limited to 'remote/modules')
6 files changed, 103 insertions, 6 deletions
diff --git a/remote/modules/hardware-stats/data/etc/systemd/system/hardware-stats.service b/remote/modules/hardware-stats/data/etc/systemd/system/hardware-stats.service index c28e75a5..ca31c695 100644 --- a/remote/modules/hardware-stats/data/etc/systemd/system/hardware-stats.service +++ b/remote/modules/hardware-stats/data/etc/systemd/system/hardware-stats.service @@ -1,7 +1,7 @@ [Unit] Description=Gather statistics about this machine and send to boot server DefaultDependencies=no -After=tmp.target multi-user.target +After=tmp.target Wants=tmp.target [Service] diff --git a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats index 0331cada..eee38a7b 100755 --- a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats +++ b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats @@ -8,6 +8,20 @@ export LANG=C export LC_ALL=C +mktemp() { + /bin/mktemp && return 0 + /opt/openslx/bin/mktemp && return 0 + 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 "$FN" + return 0 + done +} + if [ -z "$SLX_REMOTE_LOG" ]; then echo "No remote log url given, will not report" exit 1 @@ -25,8 +39,6 @@ if [ "${#BOOTIF}" -ne "20" ]; then fi MAC=${BOOTIF:3} -which dmidecode || sleep 5 - # 2) Get machine UUID, with fallback to MAC address if it fails for some reason UUID=$(dmidecode -s system-uuid) if [ "${#UUID}" -ne "36" ]; then @@ -100,12 +112,14 @@ done ID44=$(( $ID44 / 1058576 )) # we'd rather underreport # 9) check smart values +FDISK=$(mktemp) +fdisk -l > "$FDISK" BADSECTORS=0 if which smartctl; then ALLSMART=$(mktemp) FILE=$(mktemp) [ -z "$FILE" ] && FILE="/tmp/smartctl.$$.$RANDOM.$RANDOM" - for dev in $(fdisk -l | grep -o '^Disk /dev/\S*:' | cut -c 6-); do + for dev in $(cat "$FDISK" | grep -o '^Disk /dev/\S*:' | cut -c 6-); do dev=${dev:0:-1} smartctl -i -H -A -f "brief" "$dev" > "$FILE" || continue echo "NEXTHDD=$dev" >> "$ALLSMART" @@ -151,7 +165,6 @@ fi # n) Dump raw data to a file DATAFILE=$(mktemp) -[ -z "$DATAFILE" ] && DATAFILE="/root/power-stats.$$" cat > "$DATAFILE" <<-EOF ############################### CPU ##################################### Sockets: $(grep '^physical id' /proc/cpuinfo | sort -u | wc -l) @@ -159,7 +172,7 @@ Real cores: $CPUCORES Virtual cores: $(grep '^processor' /proc/cpuinfo | sort -u | wc -l) ######################## Partition tables ############################### EOF -fdisk -l >> "$DATAFILE" +cat "$FDISK" >> "$DATAFILE" cat >> "$DATAFILE" <<-EOF ############################ PCI ID ##################################### EOF @@ -181,10 +194,15 @@ EOF [ -n "$ALLSMART" ] && rm -f -- "$ALLSMART" # Put some info in local file for later use +HDDCOUNT=0 +for size in $(cat "$FDISK" | grep -E '^Disk /dev.*[0-9]{11,} bytes' | grep -o -E '[0-9]{11,}'); do + [ "$size" -gt 50000000000 ] && HDDCOUNT=$(( HDDCOUNT + 1 )) +done cat > "/run/hwinfo" <<HORST HW_KVM='${VT}' HW_ID44='${ID44}' HW_MBRAM='${RAM}' +HW_HDDCOUNT='${HDDCOUNT}' HORST # Fire away diff --git a/remote/modules/kdm-theme-bwlp/data/etc/systemd/system/kdm-hwinfo-warnings.service b/remote/modules/kdm-theme-bwlp/data/etc/systemd/system/kdm-hwinfo-warnings.service new file mode 100644 index 00000000..b8139a97 --- /dev/null +++ b/remote/modules/kdm-theme-bwlp/data/etc/systemd/system/kdm-hwinfo-warnings.service @@ -0,0 +1,9 @@ +[Unit] +Description=Patch warnings into KDM theme +After=hardware-stats.service +Before=kdm.service + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-kdm_hwinfo_warnings +RemainAfterExit=yes diff --git a/remote/modules/kdm-theme-bwlp/data/etc/systemd/system/multi-user.target.wants/kdm-hwinfo-warnings.service b/remote/modules/kdm-theme-bwlp/data/etc/systemd/system/multi-user.target.wants/kdm-hwinfo-warnings.service new file mode 120000 index 00000000..e6de5e15 --- /dev/null +++ b/remote/modules/kdm-theme-bwlp/data/etc/systemd/system/multi-user.target.wants/kdm-hwinfo-warnings.service @@ -0,0 +1 @@ +../kdm-hwinfo-warnings.service
\ No newline at end of file diff --git a/remote/modules/kdm-theme-bwlp/data/opt/openslx/scripts/systemd-kdm_hwinfo_warnings b/remote/modules/kdm-theme-bwlp/data/opt/openslx/scripts/systemd-kdm_hwinfo_warnings new file mode 100755 index 00000000..877a8c73 --- /dev/null +++ b/remote/modules/kdm-theme-bwlp/data/opt/openslx/scripts/systemd-kdm_hwinfo_warnings @@ -0,0 +1,61 @@ +#!/bin/ash + +patch_kdm_theme() { + local THEME_FILE="/usr/share/desktop/themes/kdm/bwlehrpool/theme.xml" + [ -s "$THEME_FILE" ] || return 0 + local TMP=$(mktemp) + [ -z "$TMP" ] && TMP="/tmp/kdm-$$-$(whoami)-$?-$!-tmp" + sed '/INFO_START_MARKER/,/INFO_END_MARKER/{//!d};/INFO_START_MARKER/a REPLACE_MARKER' "$THEME_FILE" > "$TMP" + local DATA= + build_replacement_xml + awk -v r="$DATA" '{gsub(/REPLACE_MARKER/,r)}1' "$TMP" > "$THEME_FILE" +} + +build_replacement_xml() { + local TEMPLATE=' +<item type="label"> + <normal color="_COLOR_" font="Sans 11"/> + <text>_TEXT_</text> +</item>' + . "/run/hwinfo" + local CONTACT_RZ= + # Warning: add_replace_xml doesn't escape <>& (XML), and also doesn't escape , and & (sed), so e.g. < should be written as \< + if [ "$HW_KVM" = "DISABLED" ]; then + add_replace_xml "ff0000" "64Bit-Gast-Support (VT-x oder AMD-V) ist im BIOS deaktiviert. 64Bit VMs können nicht gestartet werden." + CONTACT_RZ=jau + elif [ "$HW_KVM" = "UNSUPPORTED" ]; then + add_replace_xml "000000" "CPU hat keinen 64Bit-Gast-Support (VT-x oder AMD-V). 64Bit VMs können nicht gestartet werden." + fi + if [ -n "$HW_MBRAM" ] && [ "$HW_MBRAM" -lt 3400 ]; then + local GB=$(( ( HW_MBRAM + 300 ) / 1024 )) + add_replace_xml "000000" "Dieser PC hat wenig RAM (${GB}GB). Die Leistung von VM-Sitzungen wird nicht optimal sein." + fi + if [ "$HW_ID44" = "0" ]; then + add_replace_xml "000000" "Keine ID44-Partition gefunden. VMs bekommen wenig RAM zugewiesen." + if [ "$HW_HDDCOUNT" = "0" ]; then + add_replace_xml "000000" " * Keine Festplatte erkannt; eine Festplatte wird empfohlen, wenn Sie VMs nutzen wollen" + elif [ -n "$HW_HDDCOUNT" ]; then + CONTACT_RZ=klar + fi + if [ -n "$HW_MBRAM" ] && [ "$HW_MBRAM" -lt 4500 ]; then + add_replace_xml "ff0000" " * Da der PC wenig RAM hat, ist die Einrichtung einer ID44-Partition dringend zu empfehlen" + fi + elif [ -n "$HW_ID44" ] && [ "$HW_ID44" -lt 10000 ]; then + add_replace_xml "000000" "Die ID44-Partition ist sehr klein. VM-Sitzungen könnten nach einiger Zeit aus Speichermangel abstürzen." + CONTACT_RZ=fjeden + fi + if [ -n "$CONTACT_RZ" ]; then + add_replace_xml "000000" " -- " + add_replace_xml "000000" " -- Wenden Sie sich ggf. an den bwLehrpool-Support Ihres Rechenzentrums -- " + fi +} + +add_replace_xml() { + [ -z "$DATA" ] && DATA=$(echo "$TEMPLATE" | sed "s,_COLOR_,#000000,;s,_TEXT_,Hinweise für den Admin/Hardware-Betreuer:,") + DATA="$DATA $(echo "$TEMPLATE" | sed "s,_COLOR_,#$1,;s,_TEXT_,$2,")" +} + + + +patch_kdm_theme + diff --git a/remote/modules/kdm-theme-bwlp/data/usr/share/desktop/themes/kdm/bwlehrpool/theme.xml b/remote/modules/kdm-theme-bwlp/data/usr/share/desktop/themes/kdm/bwlehrpool/theme.xml index 5de73ea6..6aaac6b3 100644 --- a/remote/modules/kdm-theme-bwlp/data/usr/share/desktop/themes/kdm/bwlehrpool/theme.xml +++ b/remote/modules/kdm-theme-bwlp/data/usr/share/desktop/themes/kdm/bwlehrpool/theme.xml @@ -175,6 +175,14 @@ KDM-OpenSLX-Theme </item> </box> </item> + <!-- dynamic info --> + <item type="rect"> + <pos anchor="s" x="50%" y="100%" width="66%" height="30%"/> + <box> + <!-- INFO_START_MARKER --> + <!-- INFO_END_MARKER --> + </box> + </item> <!-- Icon/Logo of Uni --> <item type="pixmap" id="branding_logo" button="false"> <normal file="/etc/branding.svg" scalemode="fit"/> |
