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>
33 lines
664 B
Bash
Executable File
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."
|