#!/usr/bin/env sh
set -eu

log_file="$HOME/.cache/matugen-sync-pi.log"

mkdir -p "$HOME/.cache"

{
  ssh mac-attio "mkdir -p ~/.pi/agent/themes"
  scp "$HOME/.pi/agent/themes/matugen.json" \
    mac-attio:~/.pi/agent/themes/matugen.json.tmp
  ssh mac-attio "mv ~/.pi/agent/themes/matugen.json.tmp ~/.pi/agent/themes/matugen.json"
} >>"$log_file" 2>&1
