Files
family_home_lab/deploy/pi-dash-sync.sh

14 lines
783 B
Bash
Executable File

#!/usr/bin/env bash
# Copy Pi dashboard agent-session JSONs from the pi host to .13 so the portal's
# admin Pi Dashboard view (/admin/pi) can render them. Run this on the host
# where `pi` runs (sam-4screen-desktop). Automate with cron, e.g. every 5 min:
# */5 * * * * /home/sam/home_network/custom_tools/family_home_lab/deploy/pi-dash-sync.sh >> /tmp/pi-dash-sync.log 2>&1
set -e
DST="sam@192.168.20.13:/mnt/data/family-home-lab/pi-dashboard"
ssh sam@192.168.20.13 "mkdir -p /mnt/data/family-home-lab/pi-dashboard"
if command -v rsync >/dev/null 2>&1; then
rsync -a --delete /home/sam/.pi/agent/dashboard/*.json "$DST"/
else
scp -q /home/sam/.pi/agent/dashboard/*.json "$DST"/
fi
echo "pi dashboard synced: $(ls /home/sam/.pi/agent/dashboard/*.json 2>/dev/null | wc -l) files"