40 lines
1.5 KiB
Text
40 lines
1.5 KiB
Text
|
#!/usr/bin/with-contenv bash
|
||
|
|
||
|
echo '------------------------------------------------------------------------'
|
||
|
echo '| Made by GilbN'
|
||
|
echo '| Running installation of required modules for geoip2influx'
|
||
|
echo '------------------------------------------------------------------------'
|
||
|
|
||
|
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\
|
||
|
MAXMINDDB_LICENSE_KEY=${MAXMINDDB_LICENSE_KEY}\\n"
|
||
|
|
||
|
mkdir -p /config/geoip2db
|
||
|
cp -f /geoip2influx/geoip2influx.py /config/geoip2db
|
||
|
chown -R abc:abc /config/geoip2db
|
||
|
chmod +x /config/geoip2db/geoip2influx.py
|
||
|
|
||
|
# 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/conf.d/libmaxminddb
|
||
|
if [ ! -f /var/lib/libmaxminddb/GeoLite2-City.mmdb ]; then
|
||
|
echo "Downloading GeoIP2 City database."
|
||
|
/etc/periodic/weekly/libmaxminddb
|
||
|
fi
|
||
|
fi
|