-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrefresh_ip2location.sh
executable file
·54 lines (46 loc) · 1.65 KB
/
refresh_ip2location.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
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#source /etc/environment
set -e
echo "This script is executed from: $PWD"
#if [ ! -f "./server.key" ]; then
# openssl genrsa 2048 > server.key
# chmod 400 server.key
# if [ ! -f "./server.crt" ]; then
# openssl req -batch -new -x509 -nodes -sha256 -days 365 -key server.key -out ./server.crt
# fi
#fi
if [ -z "$IP2LOCATION_TOKEN" ]; then
echo "You must create a .env file and set IP2LOCATION_TOKEN" && exit 1
else
echo "Successfuly load ip2location token: $IP2LOCATION_TOKEN"
fi
FILE=db1lite.zip
if [ `find $FILE -type f -mtime +2 -print` ];
then
echo "Le fichier $FILE a été modifié il y a plus de 2 jours."
rm $FILE
wget -O $FILE "http://www.ip2location.com/download/?token=${IP2LOCATION_TOKEN}&file=DB1LITE"
[ -f $FILE ] && unzip -o $FILE
else
echo "Le fichier $FILE a été modifié il y a moins de 2 jours."
fi
FILE=DBASNLITE.zip
if [ `find $FILE -type f -mtime +2 -print` ];
then
echo "Le fichier $FILE a été modifié il y a plus de 2 jours."
rm $FILE
wget -O $FILE "http://www.ip2location.com/download/?token=${IP2LOCATION_TOKEN}&file=DBASNLITE"
[ -f $FILE ] && unzip -o $FILE
else
echo "Le fichier $FILE a été modifié il y a moins de 2 jours."
fi
FILE=ipv4-address-space.csv
if [ `find $FILE -type f -mtime +2 -print` ];
then
echo "Le fichier $FILE a été modifié il y a plus de 2 jours."
wget -O ipv4-address-space.csv https://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.csv
[ -f ipv4-address-space.csv ] && cp -rf ipv4-address-space.csv build-tiles/ipv4-address-space.csv
else
echo "Le fichier $FILE a été modifié il y a moins de 2 jours."
fi
#sudo service ipv4explorer restart