summaryrefslogtreecommitdiffstats
path: root/remote/modules/kdm-theme-bwlp/data
diff options
context:
space:
mode:
authorSimon Rettberg2016-03-31 16:34:57 +0200
committerSimon Rettberg2016-03-31 16:34:57 +0200
commit5c5e649721b2cf7c0c82dadb4c84dfb72bc0f516 (patch)
tree2e392d3c96382701f70c4b03bfbd1ca0ec43084c /remote/modules/kdm-theme-bwlp/data
parent[vmware] Disable link/map root share if shared folders are disabled (diff)
downloadtm-scripts-5c5e649721b2cf7c0c82dadb4c84dfb72bc0f516.tar.gz
tm-scripts-5c5e649721b2cf7c0c82dadb4c84dfb72bc0f516.tar.xz
tm-scripts-5c5e649721b2cf7c0c82dadb4c84dfb72bc0f516.zip
[kdm-theme-bwlp] Patch theme with warnings about suboptimal hw config
Diffstat (limited to 'remote/modules/kdm-theme-bwlp/data')
-rw-r--r--remote/modules/kdm-theme-bwlp/data/etc/systemd/system/kdm-hwinfo-warnings.service9
l---------remote/modules/kdm-theme-bwlp/data/etc/systemd/system/multi-user.target.wants/kdm-hwinfo-warnings.service1
-rwxr-xr-xremote/modules/kdm-theme-bwlp/data/opt/openslx/scripts/systemd-kdm_hwinfo_warnings61
-rw-r--r--remote/modules/kdm-theme-bwlp/data/usr/share/desktop/themes/kdm/bwlehrpool/theme.xml8
4 files changed, 79 insertions, 0 deletions
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 \&lt;
+ 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"/>