-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoupdate.sh
executable file
·41 lines (35 loc) · 1.33 KB
/
autoupdate.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
35
36
37
38
39
40
41
#!/bin/bash
COUNTRY_IPV4="https://dl.miyuru.lk/geoip/maxmind/country/maxmind4.dat.gz"
COUNTRY_IPV6="https://dl.miyuru.lk/geoip/maxmind/country/maxmind6.dat.gz"
CITY_IPV4="https://dl.miyuru.lk/geoip/maxmind/city/maxmind4.dat.gz"
CITY_IPV6="https://dl.miyuru.lk/geoip/maxmind/city/maxmind6.dat.gz"
DEFAULT_PATH="/etc/nginx/geoip"
if [[ ! -z $1 ]]; then
OUTPUT_PATH=$1
else
read -p "Full Path to store dat files : (default : /etc/nginx/geoip) " OUTPUT_PATH
OUTPUT_PATH="${OUTPUT_PATH:=${DEFAULT_PATH}}"
fi
if [[ ! -d ${OUTPUT_PATH} ]]; then
mkdir -p ${OUTPUT_PATH}
fi
case $2 in
ipv4)
wget -q -O ${OUTPUT_PATH}/geolite-country-ipv4.dat.gz ${COUNTRY_IPV4}
wget -q -O ${OUTPUT_PATH}/geolite-city-ipv4.dat.gz ${CITY_IPV4}
;;
ipv6)
wget -q -O ${OUTPUT_PATH}/geolite-country-ipv6.dat.gz ${COUNTRY_IPV6}
wget -q -O ${OUTPUT_PATH}/geolite-city-ipv6.dat.gz ${CITY_IPV6}
;;
*)
wget -q -O ${OUTPUT_PATH}/geolite-country-ipv6.dat.gz ${COUNTRY_IPV6}
wget -q -O ${OUTPUT_PATH}/geolite-city-ipv6.dat.gz ${CITY_IPV6}
wget -q -O ${OUTPUT_PATH}/geolite-country-ipv4.dat.gz ${COUNTRY_IPV4}
wget -q -O ${OUTPUT_PATH}/geolite-city-ipv4.dat.gz ${CITY_IPV4}
;;
esac
for GZIP_FILE in $(find ${OUTPUT_PATH} -type f -name "*.gz")
do
gunzip -f $GZIP_FILE
done