upgrade.sh delegates to wrolpi-upgrade service so that logs are visible in controller, even if launched from terminal.

This commit is contained in:
Roland 2026-02-03 16:42:06 -07:00
parent 98d670feb7
commit d697fc4603
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
2 changed files with 19 additions and 0 deletions

View file

@ -4,6 +4,7 @@ After=network.target
[Service]
Type=oneshot
Environment=WROLPI_UPGRADE_SERVICE=1
EnvironmentFile=/tmp/wrolpi-upgrade.env
ExecStart=/opt/wrolpi/upgrade.sh -b ${BRANCH}
User=root

View file

@ -52,6 +52,24 @@ if [ "$BRANCH_OVERRIDE" = false ]; then
fi
fi
# If not running via the wrolpi-upgrade service, delegate to it so logs are captured.
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..."
# Write branch config for the service.
echo "BRANCH=${BRANCH}" >/tmp/wrolpi-upgrade.env
# Start following journal in background (new entries only).
journalctl -fn0 -u wrolpi-upgrade.service &
JOURNAL_PID=$!
# Start service (blocks until complete for oneshot).
systemctl start wrolpi-upgrade.service
EXIT_CODE=$?
# Clean up journal follower.
kill $JOURNAL_PID 2>/dev/null
wait $JOURNAL_PID 2>/dev/null
exit $EXIT_CODE
fi
echo "Upgrading WROLPi from branch: ${BRANCH}"
set -x