#!/usr/bin/with-contenv bash echo -e "Variables set:\\n\ NGINX_LOG_PATH=${NGINX_LOG_PATH}\\n\ INFLUX_HOST=${INFLUX_HOST}\\n\ INFLUX_HOST_PORT=${INFLUX_HOST_PORT}\\n\ INFLUX_DATABASE=${INFLUX_DATABASE}\\n\ INFLUX_USER=${INFLUX_USER}\\n\ INFLUX_PASS=${INFLUX_PASS}\\n\ INFLUX_RETENTION=${INFLUX_RETENTION}\\n\ INFLUX_SHARD=${INFLUX_SHARD}\\n\ GEO_MEASUREMENT=${GEO_MEASUREMENT}\\n\ LOG_MEASUREMENT=${LOG_MEASUREMENT}\\n\ SEND_NGINX_LOGS=${SEND_NGINX_LOGS}\\n\ GEOIP2INFLUX_LOG_LEVEL=${GEOIP2INFLUX_LOG_LEVEL}\\n\ GEOIP2INFLUX_LOG_PATH=${GEOIP2INFLUX_LOG_PATH}\\n\ MAXMINDDB_LICENSE_KEY=${MAXMINDDB_LICENSE_KEY}\\n" mkdir -p \ /config/geoip2db \ /config/log/geoip2influx cp -f /geoip2influx/geoip2influx.py /config/geoip2db # move old log if needed if [ -f /config/geoip2db/geoip2influx.log ]; then mv /config/geoip2db/geoip2influx.log /config/log/geoip2influx fi # create GeoIP2 folder symlink [[ -d /var/lib/libmaxminddb ]] && [[ ! -L /var/lib/libmaxminddb ]] && \ rm -rf /var/lib/libmaxminddb [[ ! -d /var/lib/libmaxminddb ]] && \ ln -s /config/geoip2db /var/lib/libmaxminddb # check GeoIP2 database if [ -n "$MAXMINDDB_LICENSE_KEY" ]; then sed -i "s|.*MAXMINDDB_LICENSE_KEY.*|MAXMINDDB_LICENSE_KEY=\"${MAXMINDDB_LICENSE_KEY}\"|g" /etc/libmaxminddb.cron.conf if [ ! -f /var/lib/libmaxminddb/GeoLite2-City.mmdb ]; then echo "Downloading GeoIP2 City database." /etc/periodic/weekly/libmaxminddb fi fi # permissions chown -R abc:abc /config/geoip2db chmod +x /config/geoip2db/geoip2influx.py chmod -R 0644 /etc/logrotate.d