Skip to content

Commit

Permalink
Merge pull request #326 from mariux64/add-pdistd
Browse files Browse the repository at this point in the history
I guess to test this we need to  install  it... Fingers crossed
  • Loading branch information
donald authored Jul 4, 2023
2 parents 005fc81 + 5e13644 commit 3e21c9d
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
4 changes: 4 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ install_exec mxstartup/mxstartupctl "$DESTDIR$usr_sbindir/
install_exec mxstartup/mxvipctl "$DESTDIR$usr_sbindir/mxvipctl"
install_data mxstartup/mxstartup.service "$DESTDIR$systemdunitdir/mxstartup.service"
install_data misc_systemd_units/lightdm.service "$DESTDIR$systemdunitdir/lightdm.service"
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
42 changes: 42 additions & 0 deletions pdist/pdist-bootcheck
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
15 changes: 15 additions & 0 deletions pdist/pdist-bootcheck.service
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
10 changes: 10 additions & 0 deletions pdist/pdistd.socket
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
ConditionPathExists=/node/tags/distmaster

[Socket]
ListenStream=237
ReusePort=yes
Accept=yes

[Install]
WantedBy=multi-user.target
6 changes: 6 additions & 0 deletions pdist/pdistd@.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
CollectMode=inactive-or-failed

[Service]
StandardOutput=socket
ExecStart=bash -c "read ip host <<< $(getent hosts ${REMOTE_ADDR}) ; echo update in progess... ; pdist push $host --timeout 60 --set-pdist-status"

0 comments on commit 3e21c9d

Please sign in to comment.