summaryrefslogtreecommitdiffstats
path: root/refresh-token.sh
diff options
context:
space:
mode:
authorKen D'Ambrosio <ken@claude>2026-05-25 00:46:10 +0000
committerKen D'Ambrosio <ken@claude>2026-05-25 00:46:10 +0000
commit55bcec90c14db6f2956ed51cf4df1503c0767f81 (patch)
treef25bfb8c46366b5d3dc6b4f66e242c65094b4ada /refresh-token.sh
Initial commit — menu.jots.org Flask/SQLite meal planner
Full-featured weekly menu planner with: - Recipe library with ratings, comments, cuisine/nationality, added-by attribution - AI recipe assistant (Claude) with URL fetching and file upload - Weekly meal plan grid with shopping list generation - Sort by name, prep/cook time, or rating - Print and copy-link support - Deployed on LXC container (192.168.10.51) behind Apache reverse proxy Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'refresh-token.sh')
-rwxr-xr-xrefresh-token.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/refresh-token.sh b/refresh-token.sh
new file mode 100755
index 0000000..0f9038b
--- /dev/null
+++ b/refresh-token.sh
@@ -0,0 +1,26 @@
+#!/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."