Files
brother-ql-bridge/scripts/update.sh
Tim Hadwen b48a0ffe93 Add nightly auto-update via systemd timer
Add scripts/update.sh that fetches origin/main, resets if changed,
reinstalls dependencies when requirements.txt differs, and restarts
the service. Deploy script now installs a systemd timer that triggers
the update nightly at 03:00 with Persistent=true for catch-up on
missed runs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:29:35 +10:00

38 lines
937 B
Bash

#!/bin/bash
# Brother QL Bridge - Nightly Update Script
# Pulls latest code from GitHub and restarts the service if anything changed.
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_DIR"
echo "Fetching latest changes from origin/main..."
git fetch origin main
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/main)
if [ "$LOCAL" = "$REMOTE" ]; then
echo "Already up to date."
exit 0
fi
echo "Updating from $LOCAL to $REMOTE..."
# Check if requirements.txt will change
REQUIREMENTS_CHANGED=$(git diff HEAD origin/main --name-only -- requirements.txt)
git reset --hard origin/main
if [ -n "$REQUIREMENTS_CHANGED" ]; then
echo "requirements.txt changed, reinstalling dependencies..."
uv pip install -r requirements.txt
fi
echo "Restarting brother-ql-bridge service..."
sudo systemctl restart brother-ql-bridge
echo "Update complete."