Use docker fallback for weather report script
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PY_SCRIPT="${WEATHER_REPORT_PY_SCRIPT:-$SCRIPT_DIR/weather-day-report.py}"
|
||||
TOKEN_FILE="${GRAFANA_TOKEN_FILE:-/mnt/user/appdata/secrets/monitoring_grafana_weather_report_token.txt}"
|
||||
PY_IMAGE="${WEATHER_REPORT_PY_IMAGE:-python:3.13-alpine}"
|
||||
|
||||
if command -v python3 >/dev/null 2>&1; then
|
||||
exec python3 "$PY_SCRIPT" "$@"
|
||||
fi
|
||||
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
echo "weather-day-report: neither python3 nor docker is available" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$TOKEN_FILE" ]; then
|
||||
echo "weather-day-report: token file missing: $TOKEN_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec docker run --rm \
|
||||
--network host \
|
||||
-v "$PY_SCRIPT:/weather-day-report.py:ro" \
|
||||
-v "$TOKEN_FILE:/run/secrets/grafana_weather_report_token:ro" \
|
||||
-e GRAFANA_TOKEN_FILE=/run/secrets/grafana_weather_report_token \
|
||||
-e GRAFANA_URL="${GRAFANA_URL:-https://monitoring.kaleschke.info}" \
|
||||
-e WEATHER_REPORT_TZ="${WEATHER_REPORT_TZ:-Europe/Berlin}" \
|
||||
"$PY_IMAGE" \
|
||||
python /weather-day-report.py "$@"
|
||||
Reference in New Issue
Block a user