Support parallel generating

This commit is contained in:
Yifan Gao 2019-12-19 16:00:25 +08:00
parent da40357727
commit a497a9fc47
2 changed files with 18 additions and 7 deletions

View File

@ -19,15 +19,24 @@ get_asn(){
awk '{gsub(/AS/, ""); print $1 }'
}
prepare_data(){
curl -sSL https://bgp.potaroo.net/cidr/autnums.html | awk '-F[<>]' '{print $3,$5}' | grep '^AS' > asnames.txt
prepare_data_v4(){
curl -sSLo rib.bz2 http://archive.routeviews.org/dnszones/rib.bz2
log_info "runing bgpdump v4 ..."
docker run -it --rm -v `pwd`:/bgpdump -w /bgpdump gaoyifan/bgpdump bgpdump -m -O rib.txt rib.bz2
log_info "finish bgpdump v4"
}
prepare_data_v6(){
IP6UPSTREAM="http://archive.routeviews.org/route-views6/bgpdata"
MONTH6=$(lftp -e 'cls -1;exit' $IP6UPSTREAM 2>/dev/null | sort | tail -n 1)
LATEST6=$(lftp -e 'cls -1;exit' $IP6UPSTREAM/$MONTH6/RIBS/ 2>/dev/null | sort | tail -n 1)
curl -sSLo rib6.bz2 "$IP6UPSTREAM/$MONTH6/RIBS/$LATEST6"
log_info "runing bgpdump ..."
docker run -it --rm -v `pwd`:/bgpdump -w /bgpdump gaoyifan/bgpdump bgpdump -m -O rib.txt rib.bz2
log_info "runing bgpdump v6 ..."
docker run -it --rm -v `pwd`:/bgpdump -w /bgpdump gaoyifan/bgpdump bgpdump -m -O rib6.txt rib6.bz2
log_info "done"
log_info "finish bgpdump v6"
}
prepare_data(){
curl -sSL https://bgp.potaroo.net/cidr/autnums.html | awk '-F[<>]' '{print $3,$5}' | grep '^AS' > asnames.txt &
prepare_data_v4 &
prepare_data_v6 &
wait
}

View File

@ -3,13 +3,15 @@
source common.sh
set -e
[[ $SKIP_DATA_PREPARATION != true ]] && prepare_data
reset
mkdir -p result
for file in operator/*.conf; do
operator=${file%.*}
operator=${operator##*/}
log_info "generating IP list of $operator ..."
get_asn $file
get_asn $file | xargs bgptools -b rib.txt | sort | uniq | docker run -i --rm yangzhaofengsteven/cidr-merge > result/${operator}.txt
get_asn $file | xargs bgptools -b rib6.txt | sort | uniq | docker run -i --rm yangzhaofengsteven/cidr-merge > result/${operator}6.txt
get_asn $file | xargs bgptools -b rib.txt | sort | uniq | docker run -i --rm yangzhaofengsteven/cidr-merge > result/${operator}.txt &
get_asn $file | xargs bgptools -b rib6.txt | sort | uniq | docker run -i --rm yangzhaofengsteven/cidr-merge > result/${operator}6.txt &
done
wait