-
Notifications
You must be signed in to change notification settings - Fork 0
/
regen_aggregated.sh
executable file
·53 lines (47 loc) · 1.1 KB
/
regen_aggregated.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
#!/bin/sh
# This helper script fetches each RIR's current delegation statistics and
# produces an aggregated CIDR version of the data.
usage()
{
echo "Usage: $0 [-f]"
echo " -f force data download"
exit 1
}
[ $# -eq 0 -o $# -eq 1 ] || usage
case $# in
0) FORCE=0 ;;
1)
case "$1" in
-f) FORCE=1 ;;
*) usage ;;
esac
;;
*) usage ;;
esac
if ! which aggregate >/dev/null 2>&1; then
echo 'Error: "aggregate" is not available!'
exit 2
fi
if which lftpget >/dev/null 2>&1; then
FETCH=lftpget
elif which wget >/dev/null 2>&1; then
FETCH=wget
elif which curl >/dev/null 2>&1; then
FETCH=curl
else
echo 'Error: neither "lftpget" nor "wget" nor "curl" is available!'
exit 2
fi
for rir in afrinic apnic arin lacnic ripencc; do
# Fetch NROESF, ARIN has discontinued RIRSEF.
dfile=delegated-$rir-extended-latest
afile=aggregated-delegated-$rir.txt
if [ ! -s $dfile -o $FORCE -eq 1 ]; then
[ -s $dfile ] && rm -f $dfile
lftpget ftp://ftp.ripe.net/pub/stats/$rir/$dfile
fi
if [ ! -s $afile -o $dfile -nt $afile ]; then
cat $dfile | ./stats-to-cidrs.rb | aggregate > $afile
wc -l $afile
fi
done