Skip to content

Instantly share code, notes, and snippets.

@oskar456
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oskar456/88e412f1e52632dccf2c to your computer and use it in GitHub Desktop.
Save oskar456/88e412f1e52632dccf2c to your computer and use it in GitHub Desktop.
Czech IP allocations from RIPE NCC
#!/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