Files
tvj-epg/entrypoint.sh
T
Lyncoln c6bcdedef7
Build and Publish TVJ EPG Image / build (push) Successful in 24s
Make HTTP port configurable with default 1876
2026-09-10 10:01:34 -04:00

26 lines
965 B
Bash

#!/bin/sh
set -eu
PORT="${PORT-1876}"
export PORT
PORT="$(python -c 'import os; value = os.environ["PORT"]; valid = value.isascii() and value.isdigit() and 1 <= int(value) <= 65535; valid or exit("PORT must be an integer from 1 to 65535"); print(int(value))')"
mkdir -p /app/output
UPDATE_INTERVAL="${UPDATE_INTERVAL:-6}"
export UPDATE_INTERVAL
UPDATE_INTERVAL="$(python -c 'import os; value = os.environ["UPDATE_INTERVAL"]; assert value.isascii() and value.isdigit() and int(value) > 0, "UPDATE_INTERVAL must be a positive integer (hours)"; print(int(value))')"
# Fail fast on invalid channel/output configuration.
python -c 'from epg.config import load; load()'
( while true; do
echo "$(date) - Updating EPG and playlist..."
if ! python -m epg.engine; then
echo "$(date) - Update failed; retrying after ${UPDATE_INTERVAL} hours." >&2
fi
sleep "$((UPDATE_INTERVAL * 3600))"
done
) &
cd /app/output
exec python3 -m http.server "$PORT"