Self-heal wrolpi-upgrade.service unit before delegating in upgrade.sh

upgrade.sh delegates to wrolpi-upgrade.service at the very start, but that
unit is only installed by repair.sh, which runs near the end of the upgrade.
On a box that has never run a repair since the unit was introduced, the
delegation fails immediately with "Unit wrolpi-upgrade.service not found",
the service never runs (so nothing is logged to the journal), and
/opt/wrolpi/upgrade.log is never created.

Install/refresh the unit from the checked-out tree and daemon-reload right
before starting the service. The delegation block already runs as root, so
no sudoers changes are needed. This is idempotent and also self-heals a
stale unit file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roland 2026-05-29 13:16:07 -06:00
parent f245f25179
commit e7591b16ad
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680

View file

@ -56,6 +56,12 @@ fi
if [ -z "$WROLPI_UPGRADE_SERVICE" ]; then
trap 'echo ""; echo "Note: The upgrade service is still running in the background."; echo "Monitor with: journalctl -fu wrolpi-upgrade.service"' INT
echo "Delegating upgrade to wrolpi-upgrade.service..."
# Self-heal: ensure the unit is installed and current before starting it.
# repair.sh installs it normally, but that runs late in the upgrade, so a
# missing or stale unit would otherwise break delegation entirely.
install -m644 /opt/wrolpi/etc/raspberrypios/wrolpi-upgrade.service \
/etc/systemd/system/wrolpi-upgrade.service
systemctl daemon-reload
# Write branch config for the service.
echo "BRANCH=${BRANCH}" >/tmp/wrolpi-upgrade.env
chown wrolpi:wrolpi /tmp/wrolpi-upgrade.env