diff --git a/Dockerfile b/Dockerfile index 76c73d3..b98491b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,8 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . . -# Make entrypoint script executable -RUN chmod +x /app/entrypoint.sh +# Upewnij się, że skrypt entrypoint.sh jest wykonywalny +RUN chmod a+x /app/entrypoint.sh -# Set the entrypoint -ENTRYPOINT ["/app/entrypoint.sh"] +# Uruchom skrypt entrypoint, który zajmie się resztą +CMD ["/app/entrypoint.sh"] diff --git a/config.yaml b/config.yaml index 0a90ec8..382557d 100644 --- a/config.yaml +++ b/config.yaml @@ -11,5 +11,7 @@ arch: init: false startup: application boot: auto -options: {} -schema: [] +options: + credentials_json: "" +schema: + credentials_json: text diff --git a/entrypoint.sh b/entrypoint.sh index b233ae6..756b78b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,11 +1,16 @@ #!/bin/bash +set -e -# Load the cron job +# Odczytaj opcję 'credentials_json' z konfiguracji dodatku i utwórz plik +# Home Assistant udostępnia opcje jako zmienne środowiskowe z prefiksem CONFIG_ +echo "${CONFIG_CREDENTIALS_JSON}" > /app/credentials.json + +echo "✅ Plik credentials.json został utworzony." + +# Dodaj zadania crona z pliku crontab crontab /app/crontab +echo "✅ Zadania crona zostały załadowane." -# Create the log file and set permissions -touch /var/log/cron.log -chmod 0666 /var/log/cron.log - -# Start cron in the foreground -cron -f +# Uruchom usługę cron na pierwszym planie, aby kontener się nie zamknął +echo "🚀 Uruchamiam usługę cron..." +cron -f \ No newline at end of file