mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
upgrade.sh delegates to wrolpi-upgrade service so that logs are visible in controller, even if launched from terminal.
This commit is contained in:
parent
98d670feb7
commit
d697fc4603
2 changed files with 19 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
18
upgrade.sh
18
upgrade.sh
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue