From 00e6fb5033c12a5a9db98fc84e768547367e3388 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 20 Dec 2015 21:27:28 +0000 Subject: Rename script --- autorestart/scripts/95-systemd-restart-as-needed | 34 ------------------------ autorestart/scripts/systemd-restart-as-needed | 34 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 34 deletions(-) delete mode 100755 autorestart/scripts/95-systemd-restart-as-needed create mode 100755 autorestart/scripts/systemd-restart-as-needed (limited to 'autorestart') diff --git a/autorestart/scripts/95-systemd-restart-as-needed b/autorestart/scripts/95-systemd-restart-as-needed deleted file mode 100755 index c8099ee..0000000 --- a/autorestart/scripts/95-systemd-restart-as-needed +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -TMP="/tmp" -DELETED="$TMP/restart.deleted" -OWNED="$TMP/restart.owned" -UPDATED="$TMP/restart.updated" -UNITS="$TMP/restart.units" - -lsof -n | awk '{ if ($5 == "DEL" || $10 == "(deleted)") print $9,$2; }' | sort -uk 1,2 > $DELETED -find /var/db/pkg/ -name CONTENTS | xargs cat | awk '{ if ($1 != "dir") print $2; }' | xargs realpath 2> /dev/null | sort > $OWNED -join $DELETED $OWNED | awk '{ print $2 }' | sort -gu > $UPDATED - -(for pid in $(cat $UPDATED) ; do - systemctl status $pid | head -n 1 -done) | sort -u > $UNITS - -if [ -s $UNITS ] ; then - ( - echo "Restarting units:" - for unit in $(awk '{print $2}' $UNITS) ; do - if ( echo $unit | grep $( ls -1 /etc/autorestart/ignore.d/* | sed -e 's/^/-f /' ) > /dev/null ) ; then - echo "Skipping $unit" - else - systemctl restart $unit - systemctl status $unit - fi - echo - done - ) | mailx -a "Content-Type: text/plain; charset=utf-8" \ - -s "$(hostname) systemd units requiring restart" $(whoami) -fi - -rm -f $TMP/restart.* - diff --git a/autorestart/scripts/systemd-restart-as-needed b/autorestart/scripts/systemd-restart-as-needed new file mode 100755 index 0000000..c8099ee --- /dev/null +++ b/autorestart/scripts/systemd-restart-as-needed @@ -0,0 +1,34 @@ +#!/bin/bash + +TMP="/tmp" +DELETED="$TMP/restart.deleted" +OWNED="$TMP/restart.owned" +UPDATED="$TMP/restart.updated" +UNITS="$TMP/restart.units" + +lsof -n | awk '{ if ($5 == "DEL" || $10 == "(deleted)") print $9,$2; }' | sort -uk 1,2 > $DELETED +find /var/db/pkg/ -name CONTENTS | xargs cat | awk '{ if ($1 != "dir") print $2; }' | xargs realpath 2> /dev/null | sort > $OWNED +join $DELETED $OWNED | awk '{ print $2 }' | sort -gu > $UPDATED + +(for pid in $(cat $UPDATED) ; do + systemctl status $pid | head -n 1 +done) | sort -u > $UNITS + +if [ -s $UNITS ] ; then + ( + echo "Restarting units:" + for unit in $(awk '{print $2}' $UNITS) ; do + if ( echo $unit | grep $( ls -1 /etc/autorestart/ignore.d/* | sed -e 's/^/-f /' ) > /dev/null ) ; then + echo "Skipping $unit" + else + systemctl restart $unit + systemctl status $unit + fi + echo + done + ) | mailx -a "Content-Type: text/plain; charset=utf-8" \ + -s "$(hostname) systemd units requiring restart" $(whoami) +fi + +rm -f $TMP/restart.* + -- cgit v1.2.3