-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-entrypoint.sh
34 lines (25 loc) · 1012 Bytes
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
set -eu
# GEOIP_ACCOUNTID, GEOIP_LICENSEKEY,GEOIP_EDITIONID should be set otherwise unbound variable error (due to set -u)
sed -i s/GEOIP_ACCOUNTID/$GEOIP_ACCOUNTID/g /opt/geoip.conf;
sed -i s/GEOIP_LICENSEKEY/$GEOIP_LICENSEKEY/g /opt/geoip.conf;
sed -i s/GEOIP_EDITIONID/$GEOIP_EDITIONID/g /opt/geoip.conf;
sed -i s/GEOIP_EDITIONID/$GEOIP_EDITIONID/g /etc/nginx/conf.d/nginx.conf;
# Update geoipupdate cron
GEOIP_CRONTAB="${GEOIP_CRONTAB:-48 14 * * 3,6}" # NOTE: maxmind databases are updated twice weekly, every Tuesday and Friday.
sed -i s/GEOIP_CRONTAB/"$GEOIP_CRONTAB"/g /opt/crontab.txt;
/usr/bin/crontab /opt/crontab.txt
mkdir -p /usr/share/geoip
case $1 in
start)
if [ ! -f /usr/share/geoip/$GEOIP_EDITIONID.mmdb ]; then
echo "/usr/share/geoip/$GEOIP_EDITIONID.mmdb is not present; downloading"
/usr/local/bin/geoipupdate -v -f /opt/geoip.conf -d /usr/share/geoip
fi
exec /usr/bin/supervisord -c /opt/supervisord.conf
;;
*)
exec "$@"
;;
esac
exit 0