summaryrefslogtreecommitdiffstats
path: root/core/modules/lightdm-greeter-bwlp
diff options
context:
space:
mode:
authorSimon Rettberg2019-05-28 18:05:19 +0200
committerroot2019-05-28 18:05:19 +0200
commit8b04ae13e7675528968080873873ae224b3eb7f0 (patch)
tree51cf1692c11c8811b2458c69983de06a7b3e0839 /core/modules/lightdm-greeter-bwlp
parent[nvidia-common] Fix drm.cfg filenames (diff)
downloadmltk-8b04ae13e7675528968080873873ae224b3eb7f0.tar.gz
mltk-8b04ae13e7675528968080873873ae224b3eb7f0.tar.xz
mltk-8b04ae13e7675528968080873873ae224b3eb7f0.zip
[lightdm-greeter-bwlp] Download login-news on startup
Diffstat (limited to 'core/modules/lightdm-greeter-bwlp')
-rw-r--r--core/modules/lightdm-greeter-bwlp/data/etc/systemd/system/lightdm.service.d/download-news.conf2
-rwxr-xr-xcore/modules/lightdm-greeter-bwlp/data/opt/openslx/scripts/lightdm-download_news36
2 files changed, 38 insertions, 0 deletions
diff --git a/core/modules/lightdm-greeter-bwlp/data/etc/systemd/system/lightdm.service.d/download-news.conf b/core/modules/lightdm-greeter-bwlp/data/etc/systemd/system/lightdm.service.d/download-news.conf
new file mode 100644
index 00000000..c0ab14cb
--- /dev/null
+++ b/core/modules/lightdm-greeter-bwlp/data/etc/systemd/system/lightdm.service.d/download-news.conf
@@ -0,0 +1,2 @@
+[Service]
+ExecStartPre=-/opt/openslx/scripts/lightdm-download_news
diff --git a/core/modules/lightdm-greeter-bwlp/data/opt/openslx/scripts/lightdm-download_news b/core/modules/lightdm-greeter-bwlp/data/opt/openslx/scripts/lightdm-download_news
new file mode 100755
index 00000000..c1d7c97a
--- /dev/null
+++ b/core/modules/lightdm-greeter-bwlp/data/opt/openslx/scripts/lightdm-download_news
@@ -0,0 +1,36 @@
+#!/bin/ash
+
+. /opt/openslx/config
+
+. /opt/openslx/bin/slx-tools
+
+dlfile="/tmp/news-raw.$$$RANDOM"
+newsfile="/opt/openslx/lightdm/news.html"
+
+if [ -n "$SLX_VMCHOOSER_BASE_URL" ]; then
+ URL="$SLX_VMCHOOSER_BASE_URL"
+elif [ -n "$SLX_PXE_SERVER_IP" ]; then
+ URL="http://$SLX_PXE_SERVER_IP/vmchooser/"
+else
+ exit 0
+fi
+
+download_retry -o "$dlfile" "$URL/login-news"
+
+if [ -s "$dlfile" ]; then
+ hl="$( xml_get "//news/headline" "$dlfile" | str_trim )"
+ body="$( xml_get "//news/info" "$dlfile" | str_trim )"
+ if [ "${#hl}${#body}" != "00" ]; then
+ printf "%s" "<h1>$hl</h1>$body" > "$newsfile"
+ mkdir -p "/etc/lightdm/qt-lightdm-greeter.conf.d"
+ cat > "/etc/lightdm/qt-lightdm-greeter.conf.d/10-bwlp-news.conf" <<EOF
+[General]
+news-html-file = $newsfile
+EOF
+ fi
+fi
+
+rm -f -- "$dlfile"
+
+exit 0
+