bitspire/deploy/nixos/provision-branding.sh
Padreug b6169da45d feat(machine): operator branding — optional logo-dark.png variant
Sibling-file convention: drop a logo-dark.png alongside logo.png in
/var/lib/bitspire/branding/ and the renderer uses it whenever the
effective color mode is dark, falling back to logo.png when absent.
No branding.json change — the file name itself is the contract.

Wiring:
- electron/main.ts:loadBranding() reads logo-dark.png and base64-encodes
  it into logoDarkDataUrl on the IPC payload
- composables/useTheme.ts exposes an `isDark` computed that resolves
  the 'system' colorMode via the prefers-color-scheme media query (and
  reacts to OS-level dark-mode changes via the existing listener)
- composables/useBranding.ts switches logoUrl reactively based on isDark
- IdleView already binds to logoUrl — no template change needed

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-01 19:12:11 +02:00

62 lines
2.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# Provision operator branding (logo + branding.json) to a deployed bitSpire ATM.
# Composes with provision-atm.sh — that one wires LNbits creds, this one wires
# operator look-and-feel. Per issue #47.
#
# Usage:
# bash provision-branding.sh <branding-dir> # SSH to localhost:2222 (QEMU)
# bash provision-branding.sh <branding-dir> 192.168.1.50 # SSH to a real ATM on the LAN
# bash provision-branding.sh <branding-dir> 192.168.1.50 22 # custom SSH port
#
# Expected files in <branding-dir>:
# logo.png — operator logo (any reasonable size; rendered ~12vh)
# logo-dark.png — optional dark-mode variant; falls back to logo.png if absent
# branding.json — { title, theme, custom_colors{...}, custom_colors.dark{...} }
#
# Any file is optional; the on-disk schema in /var/lib/bitspire/branding/
# matches whatever <branding-dir> contains (rsync --delete).
set -euo pipefail
BRANDING_DIR="${1:-}"
ATM_HOST="${2:-localhost}"
ATM_SSH_PORT="${3:-2222}"
ATM_USER="bitspire"
REMOTE_DIR="/var/lib/bitspire/branding"
if [ -z "$BRANDING_DIR" ]; then
echo "Usage: $0 <branding-dir> [host] [port]" >&2
echo " $0 ./acme-brand (QEMU on localhost:2222)" >&2
echo " $0 ./acme-brand 192.168.1.50 (real ATM)" >&2
exit 1
fi
if [ ! -d "$BRANDING_DIR" ]; then
echo "ERROR: branding directory not found: $BRANDING_DIR" >&2
exit 1
fi
echo "=== Provisioning branding to $ATM_HOST:$ATM_SSH_PORT ==="
echo "Local dir : $BRANDING_DIR"
echo "Remote dir: $REMOTE_DIR"
echo ""
# Show what we're about to push so the operator can sanity-check before sync.
ls -la "$BRANDING_DIR"
echo ""
# rsync over SSH. --delete to clean stale files (a removed logo.png should
# disappear, not linger). sudo on the remote side because /var/lib/bitspire
# is owned by the bitspire service user, not the SSH user.
rsync -avz --delete \
--rsync-path="sudo rsync" \
-e "ssh -o StrictHostKeyChecking=no -p $ATM_SSH_PORT" \
"$BRANDING_DIR/" \
"$ATM_USER@$ATM_HOST:$REMOTE_DIR/"
# Restart the service so loadBranding() re-runs and the renderer picks up the
# new files. V2 (Nostr-event source) will eliminate the restart need.
ssh -o StrictHostKeyChecking=no -p "$ATM_SSH_PORT" "$ATM_USER@$ATM_HOST" \
"sudo systemctl restart bitspire"
echo ""
echo "=== Branding provisioned. Service restarted. ==="