diff options
Diffstat (limited to 'refresh-token.sh')
| -rwxr-xr-x | refresh-token.sh | 26 |
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." |
