From 8f61e35281153cfa17686a87e174159186e9c9f1 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 14 Jun 2023 16:35:01 +0200 Subject: [PATCH] pdist> Add pdist-bootcheck Work in progres.... --- install.sh | 2 ++ pdist/pdist-bootcheck | 45 +++++++++++++++++++++++++++++++++++ pdist/pdist-bootcheck.service | 18 ++++++++++++++ 3 files changed, 65 insertions(+) create mode 100755 pdist/pdist-bootcheck create mode 100644 pdist/pdist-bootcheck.service diff --git a/install.sh b/install.sh index 165f4b3..211fb38 100755 --- a/install.sh +++ b/install.sh @@ -267,6 +267,8 @@ install_symlink /etc/local/access.conf "$DESTDIR$sysconfdir/s install_data misc_etc_files/cups/client.conf "$DESTDIR$sysconfdir/cups/client.conf" install_data pdist/pdistd.socket "$DESTDIR$systemdunitdir/pdistd.socket" install_data pdist/pdistd@.service "$DESTDIR$systemdunitdir/pdistd@.service" +install_exec pdist/pdist-bootcheck "$DESTDIR$usr_exec_prefix/libexec/pdist-bootcheck" +install_data pdist/pdist-bootcheck.service "$DESTDIR$systemdunitdir/pdist-bootcheck.service" postinstall exit diff --git a/pdist/pdist-bootcheck b/pdist/pdist-bootcheck new file mode 100755 index 0000000..6ad571c --- /dev/null +++ b/pdist/pdist-bootcheck @@ -0,0 +1,45 @@ +#! /bin/bash + +set -e + +if [ -e /.pdist_status ]; then + now=$(date +%s) + if [ $now -lt $(date +%s -d 2023-06-01) ]; then + echo $(date -d @$now): implausible system time + exit 1 + fi + echo "system time: $(date -d @$now)" + pdist_time=$(stat -c%Y /.pdist_status) + echo "pdist time: $(date -d @$pdist_time)" + pdist_age=$(( ($now - $pdist_time) /60 /60 /24 )) + echo "pdist age: $pdist_age days" + if [ $pdist_age -ge 7 ]; then + need_pdist_and_reboot=1 + elif [ $pdist_age -ge 1 ]; then + need_async_pdist=1 + else + echo no update required + fi +else + echo "no recorded update time" + need_pdist_and_reboot=1 +fi + +if [ "$need_async_pdist" ]; then + netcat $(distmaster) 237 >/dev/null 2>&1