-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work in progres....
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#! /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 background 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
After=network-online.target | ||
Wants=network-online.target | ||
Before=getty-pre.target | ||
Wants=getty-pre.target | ||
ConditionPathExists=/node/tags/desktop | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
StandardOutput=journal+console | ||
ExecStart=/usr/libexec/pdist-bootcheck | ||
|
||
[Install] | ||
WantedBy=multi-user.target |