Skip to content

Commit

Permalink
pdist> Add pdist-bootcheck
Browse files Browse the repository at this point in the history
Work in progres....
  • Loading branch information
donald committed Jun 19, 2023
1 parent e465079 commit bd98e63
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 45 additions & 0 deletions pdist/pdist-bootcheck
Original file line number Diff line number Diff line change
@@ -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 </dev/null &
echo triggered backgroud update
elif [ "$need_pdist_and_reboot" ]; then
if [[ -e /var/run/updatecheck.reboot-triggered ]]; then
echo "Update and reboot required but prevented due to previous attempt"
rm /var/run/updatecheck.reboot-triggered
exit 1
fi
echo "Update and reboot required. Please be patient..."
netcat $(distmaster) 237
mxgrub default
touch /var/run/updatecheck.reboot-triggered
systemctl start reboot.target --job-mode=replace-irreversibly
fi

echo debug delay 30
sleep 30
18 changes: 18 additions & 0 deletions pdist/pdist-bootcheck.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]

Requires=network.target startup-tags.service
After=network.target startup-tags.service
Before=getty-pre.target lightdm.service mxstartup.service nvidia.service
Wants=getty-pre.target
ConditionPathExists=/node/tags/desktop

[Service]

Type=oneshot
RemainAfterExit=yes
StandardOutput=journal+console
ExecStart=/usr/libexec/pdist-bootcheck

[Install]

WantedBy=basic.target

0 comments on commit bd98e63

Please sign in to comment.