#!/usr/bin/env bash set -euo pipefail cat > /usr/local/etc/php/conf.d/cacti-runtime.ini < /var/www/html/cacti/include/config.php <<'PHPCONFIG' &2 exit 1 fi done cat >> /var/www/html/cacti/include/config.php <> /var/www/html/cacti/include/config.php <<'PHPCONFIG' $database_retries = 5; $database_ssl = false; $database_persist = false; $poller_id = 1; $url_path = '/cacti/'; $cacti_session_name = 'Cacti'; PHPCONFIG # The file holds the DB password; php-fpm and the poller only need to read it. chown root:www-data /var/www/html/cacti/include/config.php chmod 0640 /var/www/html/cacti/include/config.php else echo "NOTICE: include/config.php already exists; DB_* environment variables are ignored" >&2 fi # cron runs with PATH=/usr/bin:/bin, which lacks the image's /usr/local/bin/php. # The job starts as root so the shell can open PID 1's stdout and stderr for # docker logs, then runuser drops to www-data before the poller starts. cat > /etc/cron.d/cacti-poller <> /proc/1/fd/1 2>> /proc/1/fd/2 CRON chmod 0644 /etc/cron.d/cacti-poller cron php-fpm -D exec apachectl -D FOREGROUND