aboutsummaryrefslogtreecommitdiffstats
path: root/bin/update-motd
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2017-06-26 15:52:04 +0200
committerDavid Runge <dave@sleepmap.de>2017-06-26 15:52:04 +0200
commitf7aeb073e09c5118063108659550743c1bd04755 (patch)
treea336c6ddf001eff77ad2fcedb669f1f50e5e77f2 /bin/update-motd
parentbd0dad221eabfcd94d0848d022c61e06b30843b9 (diff)
parent8b3300b9a7105fa34252c90e30e43296d04eeb39 (diff)
downloaduenv-5a99bfa72f3dc98c71a756922ed8719b10fa38b5.tar.gz
uenv-5a99bfa72f3dc98c71a756922ed8719b10fa38b5.tar.bz2
uenv-5a99bfa72f3dc98c71a756922ed8719b10fa38b5.tar.xz
uenv-5a99bfa72f3dc98c71a756922ed8719b10fa38b5.zip
Merge branch 'master' of sleepmap.de:software/uenv0.9
* 'master' of sleepmap.de:software/uenv: README.rst: Adding working homepage link for XenGi. bin/update-motd: Fix non-zero exit code in bashs safe mode. user/postpone-screensaver.service: Moving executable to /usr/bin. scripts/{postpone-screensaver,update-motd}: moving to bin subfolder for better distinction from scripts. scripts/update-motd,system/update-motd.service: Adding script to be called by update-motd.service instead of using so many sh invocations in the service file.
Diffstat (limited to 'bin/update-motd')
-rwxr-xr-xbin/update-motd55
1 files changed, 55 insertions, 0 deletions
diff --git a/bin/update-motd b/bin/update-motd
new file mode 100755
index 0000000..658f859
--- /dev/null
+++ b/bin/update-motd
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+# get the hostname
+if [ -s /etc/motd.name ]; then
+ cat /etc/motd.name > /tmp/motd
+elif [ -x /usr/bin/banner ]; then
+ cat /etc/hostname | banner -w 80 > /tmp/motd
+else
+ cat /etc/hostname > /tmp/motd
+fi
+echo >> /tmp/motd
+
+# get additional info
+if [ -s /etc/motd.info ]; then
+ cat /etc/motd.info >> /tmp/motd
+ echo >> /tmp/motd
+fi
+
+# get currently running kernel version
+uname -a >> /tmp/motd
+echo >> /tmp/motd
+
+# update package cache
+set +eu
+pacman -Sy 2>&1 > /dev/null
+pacman -Qu > /tmp/updates
+set -eu
+
+# show updatable packages
+if [ -s /tmp/updates ]; then
+ echo "Package updates available:" >> /tmp/motd
+ cat /tmp/updates >> /tmp/motd
+ echo >> /tmp/motd
+fi
+
+if [ -x /usr/bin/arch-audit ]; then
+ arch-audit -uf "%n|%c" >> /tmp/cves
+ if [ -s /tmp/cves ]; then
+ echo "Security updates needed:" >> /tmp/motd
+ cat /tmp/cves >> /tmp/motd
+ fi
+else
+ echo "Install arch-audit for information on CVEs." >> /tmp/motd
+fi
+
+# move all to /etc/motd
+if [ -x /usr/bin/lolcat ]; then
+ lolcat /tmp/motd > /etc/motd
+else
+ cat /tmp/motd > /etc/motd
+fi
+
+exit 0