#!/usr/bin/env bash # Refresh the Claude OAuth token and update it on menu.jots.org # Runs automatically twice daily via systemd timer (menu-token-refresh.timer) set -e CREDS="$HOME/.claude/.credentials.json" if [ ! -f "$CREDS" ]; then echo "ERROR: $CREDS not found" exit 1 fi ACCESS_TOKEN=$(grep -o '"accessToken":"[^"]*"' "$CREDS" | cut -d'"' -f4) if [ -z "$ACCESS_TOKEN" ]; then echo "ERROR: could not read access token from $CREDS" exit 1 fi echo "Pushing fresh token to menu-planner LXC container..." ssh root@192.168.10.50 " sed -i 's|^ANTHROPIC_API_KEY=.*|ANTHROPIC_API_KEY=${ACCESS_TOKEN}|' /var/lib/lxc/menu-planner/rootfs/etc/menu-planner.env && lxc-attach -n menu-planner -- systemctl restart menu-planner " echo "Done. AI assistant is live with a fresh token."