Files
elprice/sync-month.sh
T
magnusandClaude Opus 4.6 3a319f5cf4 Fix sync: add missing tables, Linux date, token from env
Add production and consumption table migrations. Fix sync-month.sh
to use Linux date syntax and default to port 3030. Read Eloverblik
token from ELOVERBLIK_TOKEN env var with .token file fallback.
Mount .token into Docker container.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 13:06:14 +01:00

33 lines
664 B
Bash
Executable File

#!/usr/bin/env bash
# Sync Eloverblik data for a specific month.
# Usage: ./sync-month.sh 2026-02
set -euo pipefail
if [ $# -ne 1 ]; then
echo "Usage: $0 YYYY-MM"
exit 1
fi
MONTH="$1"
BASE_URL="${BASE_URL:-http://localhost:3030}"
# Last day of the month
days=$(date -d "${MONTH}-01 +1 month -1 day" "+%d")
echo "Syncing $MONTH ($days days)"
for day in $(seq 1 "$days"); do
d=$(printf "%s-%02d" "$MONTH" "$day")
resp=$(curl -s -X POST "${BASE_URL}/eloverblik/sync?date=${d}")
text=$(echo "$resp" | sed 's/<[^>]*>//g' | xargs)
if [ -z "$text" ]; then
echo "$d: no response (server down?)"
exit 1
fi
echo "$d: $text"
done
echo "Done."