Last active
August 29, 2015 14:10
-
-
Save oskar456/88e412f1e52632dccf2c to your computer and use it in GitHub Desktop.
Czech IP allocations from RIPE NCC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
allocurl="ftp://ftp.ripe.net/pub/stats/ripencc/membership/alloclist.txt" | |
#The workdir have to exist and be empty! It's content will be deleted after each run. | |
workdir="/var/tmp/czalloc" | |
function alloc2lir() { | |
local dstdir="$1" | |
local lirfile="" | |
while read line; do | |
if egrep -q '^cz.' <<<$line; then | |
lirfile="$dstdir/$line"; | |
elif [[ -n "$lirfile" ]]; then | |
if egrep -q '^de.' <<<$line; then | |
lirfile=""; | |
break; | |
else | |
echo $line >> "$lirfile" | |
fi | |
fi | |
done | |
} | |
mkdir "${workdir}.new" | |
curl -s "$allocurl" | alloc2lir "${workdir}.new" | |
diff -Nrup "${workdir}" "${workdir}.new" | |
rm -fR "${workdir}" | |
mv "${workdir}.new" "${workdir}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment