11#! /bin/bash
22set -e
33
4- # Schreibe die Umgebungsvariable in eine Datei, damit cron sie laden kann
5- printenv | grep USER_GAME_ID > /etc/environment
4+ # Optional: Zeitzone setzen
5+ if [ -n " $TZ " ] && [ -f " /usr/share/zoneinfo/$TZ " ]; then
6+ ln -snf " /usr/share/zoneinfo/$TZ " /etc/localtime
7+ echo " $TZ " > /etc/timezone
8+ else
9+ echo " Invalid timezone: $TZ . Skipping timezone configuration." >&2
10+ fi
611
7- # Richte den Cron-Job ein
8- # Führt das Skript jeden Tag um 02:00 Uhr aus
9- echo " 0 2 * * * /usr/local/bin/python /app/app.py >> /var/log/cron.log 2>&1" > /etc/cron.d/claim-cron
12+ # Cron-Job samt Umgebungsvariable konfigurieren
13+ {
14+ echo " USER_GAME_ID=$USER_GAME_ID "
15+ echo " 0 2 * * * root /usr/local/bin/python /app/app.py >> /var/log/cron.log 2>&1"
16+ } > /etc/cron.d/claim-cron
1017
11- # Setze die richtigen Berechtigungen
18+ # Rechte setzen und Log-Datei anlegen
1219chmod 0644 /etc/cron.d/claim-cron
13-
14- # Erstelle die Log-Datei, damit wir sie mit 'tail' verfolgen können
1520touch /var/log/cron.log
1621
17- # Zeige die Start-Nachricht an
22+ # Startmeldung schreiben
1823/usr/local/bin/python /app/app.py --status >> /var/log/cron.log 2>&1
1924
20- # Starte den Cron-Dienst im Hintergrund und zeige die Logs im Vordergrund an
21- cron && tail -f /var/log/cron.log
25+ # Cron starten und Logs ausgeben
26+ cron && tail -f /var/log/cron.log
0 commit comments