diff --git a/docker-compose.yml.example b/docker-compose.yml.example index b8e1622..1369647 100644 --- a/docker-compose.yml.example +++ b/docker-compose.yml.example @@ -11,5 +11,5 @@ services: - MYSQL_ENV_MYSQL_PASSWORD=phpipamadmin - MYSQL_ENV_MySQL_PORT=3306 - PHPIPAM_AGENT_KEY=2RuQ0rt4Rir29vGN4_1ZOqShcUX7PSUb - - CRON_SCHEDULE=*/15 * * * * + - SCAN_INTERVAL=15m - TZ=UTC diff --git a/entrypoint.sh b/entrypoint.sh index 2188272..106831e 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,31 @@ #!/bin/sh set -e -[ -z "$CRON_SCHEDULE" ] && CRON_SCHEDULE="*/15 * * * *" +case "$SCAN_INTERVAL" in + 5m) CRON_S="*/5 *" + ;; + 10m) CRON_S="*/10 *" + ;; + 15m) CRON_S="*/15 *" + ;; + 30m) CRON_S="*/30 *" + ;; + 1h) CRON_S="0 *" + ;; + 2h) CRON_S="0 */2" + ;; + 4h) CRON_S="0 */4" + ;; + 6h) CRON_S="0 */6" + ;; + 12h) CRON_S="0 */12" + ;; + *) CRON_S="0 *" + ;; +esac -echo "$CRON_SCHEDULE /usr/local/bin/php /opt/phpipam-agent/index.php update > /proc/self/fd/1 2>/proc/self/fd/2" > $CRONTAB_FILE -echo "$CRON_SCHEDULE /usr/local/bin/php /opt/phpipam-agent/index.php discover > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE +echo "$CRON_S /usr/local/bin/php /opt/phpipam-agent/index.php update > /proc/self/fd/1 2>/proc/self/fd/2" > $CRONTAB_FILE +echo "$CRON_S /usr/local/bin/php /opt/phpipam-agent/index.php discover > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE chmod 0644 $CRONTAB_FILE exec "$@"