-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·111 lines (86 loc) · 2.4 KB
/
update.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
MAXDIFF=15
# compare percentage difference of two files
compare_files()
{
file1=$1
file2=$2
maxdiff=$3
file1_size=`stat -c %s $file1`
file2_size=`stat -c %s $file2`
if [[ $file1_size -gt $file2_size ]]
then
perc=`echo "scale=20; (100 - ((100 / $file1_size) * $file2_size))" | bc`
perc=${perc/\.*}
else
perc=`echo "scale=20; (100 - ((100 / $file2_size) * $file1_size))" | bc`
perc=${perc/\.*}
fi
if [[ $perc -gt $maxdiff ]]
then
return 1
else
return 0
fi
}
# Generate msprefix list
wget -O - http://www.cidr-report.org/as2.0/msprefix-list.html | perl parse_msprefix.pl | sort | uniq > list_as_name.txt_new
if ! compare_files list_as_name.txt list_as_name.txt_new $MAXDIFF
then
echo "Too many changes for AS/Name DB ... exiting"
exit 1
else
mv list_as_name.txt_new list_as_name.txt
fi
# Generate AS/Name DB
wget -O - http://www.cidr-report.org/as2.0/autnums.html | perl parse_autnums.pl > list_autnums.txt_new
if ! compare_files list_autnums.txt list_autnums.txt_new $MAXDIFF
then
echo "Too many changes for AS/Name DB ... exiting"
exit 1
else
mv list_autnums.txt_new list_autnums.txt
fi
# Get latest bview DB
wget -O - http://data.ris.ripe.net/rrc00/latest-bview.gz | zcat -dc | bgpdump -v -m - > bview_new
if ! compare_files bview bview_new $MAXDIFF
then
echo "Too many changes for bview ... exiting"
exit 1
else
mv bview_new bview
fi
# Get latest delegations from RIRs
wget -O - ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest \
ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest \
ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest \
ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest \
ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest \
> delegations_new
if ! compare_files delegations delegations_new $MAXDIFF
then
echo "Too many changes for RIRs delegation file ... exiting"
exit 1
else
mv delegations_new delegations
fi
# Parse it all
python bview2asnet.py
if ! compare_files net_as net_as_new $MAXDIFF
then
echo "Too many changes for net_as file ... exiting"
exit 1
else
mv net_as_new net_as
fi
if [ -f net_as_msgpack ]
then
if ! compare_files net_as_msgpack net_as_new_msgpack $MAXDIFF
then
echo "Too many changes for net_as_msgpack file ... exiting"
exit 1
else
mv net_as_new_msgpack net_as_msgpack
fi
fi
exit 0