From a71ef698ac1a45530d2dfa8f1b1571769e96c61c Mon Sep 17 00:00:00 2001 From: David Runge Date: Sat, 25 Feb 2017 00:15:13 +0100 Subject: 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. --- scripts/update-motd | 51 ++++++++++++++++++++++++++++++++++++++++++++++ system/update-motd.service | 15 ++------------ 2 files changed, 53 insertions(+), 13 deletions(-) create mode 100755 scripts/update-motd diff --git a/scripts/update-motd b/scripts/update-motd new file mode 100755 index 0000000..8fe4c81 --- /dev/null +++ b/scripts/update-motd @@ -0,0 +1,51 @@ +#!/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 +pacman -Sy 2>&1 > /dev/null +pacman -Qu > /tmp/updates +# 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 + diff --git a/system/update-motd.service b/system/update-motd.service index a821688..740ea7b 100644 --- a/system/update-motd.service +++ b/system/update-motd.service @@ -1,23 +1,12 @@ [Unit] Description=Update MOTD +After=multi-user.target network.target [Service] -Type=oneshot -ExecStart=/usr/bin/sh -c 'if [ -s /etc/motd.name ] ; then cat /etc/motd.name > /tmp/motd ; else cat /etc/hostname | banner -w 80 > /tmp/motd && echo >> /tmp/motd ; fi' -ExecStart=/usr/bin/sh -c 'uname -a >> /tmp/motd' -ExecStart=/usr/bin/sh -c 'echo >> /tmp/motd' -ExecStart=-/usr/bin/sh -c 'pacman -Sy 2>&1 > /dev/null' -ExecStart=/usr/bin/sh -c 'echo "Package updates available:" >> /tmp/motd' -ExecStart=-/usr/bin/sh -c 'pacman -Qu >> /tmp/motd' -ExecStart=/usr/bin/sh -c 'echo >> /tmp/motd' -ExecStart=/usr/bin/sh -c 'echo "Security updates needed:" >> /tmp/motd' -ExecStart=/usr/bin/sh -c 'if [ -x /usr/bin/arch-audit ]; then arch-audit -uf "%n|%c" >> /tmp/motd ; else echo "Install arch-audit from AUR." >> /tmp/motd ; fi' -ExecStart=/usr/bin/sh -c 'if [ -x /usr/bin/lolcat ] ; then lolcat /tmp/motd > /etc/motd ; else mv /tmp/motd /etc/motd ; fi' +ExecStart=/usr/bin/update-motd PrivateDevices=yes PrivateTmp=yes ProtectSystem=full ReadWriteDirectories=/etc/motd ProtectHome=yes NoNewPrivileges=yes - - -- cgit v1.2.3-70-g09d2 From aa6c19665c133d61b9f99fac74e63d84712aa928 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sat, 25 Feb 2017 01:25:59 +0100 Subject: user/postpone-screensaver.service: Moving executable to /usr/bin. scripts/{postpone-screensaver,update-motd}: moving to bin subfolder for better distinction from scripts. --- bin/postpone-screensaver | 43 +++++++++++++++++++++++++++++++++ bin/update-motd | 51 +++++++++++++++++++++++++++++++++++++++ scripts/postpone-screensaver | 43 --------------------------------- scripts/update-motd | 51 --------------------------------------- user/postpone-screensaver.service | 2 +- 5 files changed, 95 insertions(+), 95 deletions(-) create mode 100755 bin/postpone-screensaver create mode 100755 bin/update-motd delete mode 100755 scripts/postpone-screensaver delete mode 100755 scripts/update-motd diff --git a/bin/postpone-screensaver b/bin/postpone-screensaver new file mode 100755 index 0000000..7ece93d --- /dev/null +++ b/bin/postpone-screensaver @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Script to adjust dpms settings when running certain programs, +# that don't use fullscreen, but should not be "blanked" in between. + +export DISPLAY=:0.0 + +blankoff=0 +programs=( ${programs} ) +# loop all programs and check for running instances +for i in "${programs[@]}" +do + pid=$(pidof -x $i) + re='^[0-9]+$' + if [[ $pid =~ $re ]]; then + echo "$i running ($pid)" + blankoff=1 + fi +done + +# if valuable programs are running, don't use screen blanking +if [ $blankoff -gt 0 ]; then + echo "Some program requires screensaver to be off." + # print currently set values for screensaver timeout to tmp file + echo "s $(xset q|grep timeout|awk '{print $2}') $(xset q|grep timeout|awk '{print $4}')" > $adjust_dpms + echo "dpms $(xset q|grep Standby|awk '{print $2}') $(xset q|grep Standby|awk '{print $4}') $(xset q|grep Standby|awk '{print $6}')" >> $adjust_dpms + # disable screensaver and dpms + xset s off + xset -dpms +else + xsetq=$(xset q|grep timeout|awk '{print $2}') + # if the timeout is still 0, set it to its former value, or just switch on screensaver/dpms again + if [[ $xsetq -eq 0 ]];then + if [[ -f "$adjust_dpms" ]];then + xset $(head -n1 $adjust_dpms) + xset $(tail -n1 $adjust_dpms) + rm -rf $adjust_dpms + else + xset +dpms + xset s on + fi + fi +fi + diff --git a/bin/update-motd b/bin/update-motd new file mode 100755 index 0000000..8fe4c81 --- /dev/null +++ b/bin/update-motd @@ -0,0 +1,51 @@ +#!/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 +pacman -Sy 2>&1 > /dev/null +pacman -Qu > /tmp/updates +# 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 + diff --git a/scripts/postpone-screensaver b/scripts/postpone-screensaver deleted file mode 100755 index 7ece93d..0000000 --- a/scripts/postpone-screensaver +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -# Script to adjust dpms settings when running certain programs, -# that don't use fullscreen, but should not be "blanked" in between. - -export DISPLAY=:0.0 - -blankoff=0 -programs=( ${programs} ) -# loop all programs and check for running instances -for i in "${programs[@]}" -do - pid=$(pidof -x $i) - re='^[0-9]+$' - if [[ $pid =~ $re ]]; then - echo "$i running ($pid)" - blankoff=1 - fi -done - -# if valuable programs are running, don't use screen blanking -if [ $blankoff -gt 0 ]; then - echo "Some program requires screensaver to be off." - # print currently set values for screensaver timeout to tmp file - echo "s $(xset q|grep timeout|awk '{print $2}') $(xset q|grep timeout|awk '{print $4}')" > $adjust_dpms - echo "dpms $(xset q|grep Standby|awk '{print $2}') $(xset q|grep Standby|awk '{print $4}') $(xset q|grep Standby|awk '{print $6}')" >> $adjust_dpms - # disable screensaver and dpms - xset s off - xset -dpms -else - xsetq=$(xset q|grep timeout|awk '{print $2}') - # if the timeout is still 0, set it to its former value, or just switch on screensaver/dpms again - if [[ $xsetq -eq 0 ]];then - if [[ -f "$adjust_dpms" ]];then - xset $(head -n1 $adjust_dpms) - xset $(tail -n1 $adjust_dpms) - rm -rf $adjust_dpms - else - xset +dpms - xset s on - fi - fi -fi - diff --git a/scripts/update-motd b/scripts/update-motd deleted file mode 100755 index 8fe4c81..0000000 --- a/scripts/update-motd +++ /dev/null @@ -1,51 +0,0 @@ -#!/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 -pacman -Sy 2>&1 > /dev/null -pacman -Qu > /tmp/updates -# 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 - diff --git a/user/postpone-screensaver.service b/user/postpone-screensaver.service index 92211f8..32a43c9 100644 --- a/user/postpone-screensaver.service +++ b/user/postpone-screensaver.service @@ -8,5 +8,5 @@ IOSchedulingClass=2 IOSchedulingPriority=7 EnvironmentFile=-/etc/conf.d/postpone-screensaver EnvironmentFile=-/home/%u/.config/postpone-screensaver -ExecStart=/usr/lib/systemd/scripts/postpone-screensaver +ExecStart=/usr/bin/postpone-screensaver -- cgit v1.2.3-70-g09d2 From 7f4c46da3aeba3290e700835b54fbe80c6ad94ce Mon Sep 17 00:00:00 2001 From: David Runge Date: Sat, 25 Feb 2017 02:24:03 +0100 Subject: bin/update-motd: Fix non-zero exit code in bashs safe mode. --- bin/update-motd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/update-motd b/bin/update-motd index 8fe4c81..658f859 100755 --- a/bin/update-motd +++ b/bin/update-motd @@ -23,8 +23,11 @@ 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 @@ -49,3 +52,4 @@ else cat /tmp/motd > /etc/motd fi +exit 0 -- cgit v1.2.3-70-g09d2 From 8b3300b9a7105fa34252c90e30e43296d04eeb39 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sat, 25 Feb 2017 15:48:25 +0100 Subject: README.rst: Adding working homepage link for XenGi. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 954731c..3f1564f 100644 --- a/README.rst +++ b/README.rst @@ -392,6 +392,6 @@ ______________ .. |website-xen| raw:: html - XenGi + XenGi -- cgit v1.2.3-70-g09d2