-
Notifications
You must be signed in to change notification settings - Fork 3
/
start
executable file
·33 lines (25 loc) · 864 Bytes
/
start
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
#!/usr/bin/env sh
## By default it will try to update the database
## Every day at 10:00.
JOB_SCHEDULE=${JOB_SCHEDULE:-"0 10 * * *"}
MAXMIND_PRODUCTS=${MAXMIND_PRODUCTS:-"GeoLite2-City"}
if [[ -z "${MAXMIND_ACCOUNT}" ]] || [[ -z "${MAXMIND_KEY}" ]]; then
echo "[Error] Missing environment variables MAXMIND_ACCOUNT and/or MAXMIND_KEY"
exit 1
fi
mkdir -p /usr/local/etc/
cat <<GeoIP > /usr/local/etc/GeoIP.conf
AccountID ${MAXMIND_ACCOUNT}
LicenseKey ${MAXMIND_KEY}
EditionIDs ${MAXMIND_PRODUCTS}
DatabaseDirectory /etc/nginx/geoip
GeoIP
crontab - <<Task
${JOB_SCHEDULE} geoipupdate -v >> /var/log/cron.log 2>&1
Task
mkdir -p /etc/nginx/geoip && geoipupdate -v
mv `ls /etc/nginx/geoip/*.mmdb | head -n 1` /etc/nginx/geoip/db.mmdb
ln -sf /dev/stdout /var/log/nginx/access.log
ln -sf /dev/stderr /var/log/nginx/error.log
crond
exec nginx -g "daemon off;"