view scripts/addmissingcidr.sh @ 1253:b144c060246d draft

make ns.volatile.ano ipv6-only part of anonet migration away from ipv4, hoping others follow suit with their own nameservers
author opal hart <opal@wowana.me>
date Mon, 08 Jun 2020 19:50:02 +0000
parents 0e5d4b7fc3d8
children
line wrap: on
line source

#!/bin/sh
# adds missing ip/*/*/cidr entries

cd db || exit 1
cd ip || exit 1
for a in *
do
	[ -e "$a" ] || continue
	ia=$((0x$a)) || exit 1
	cd "$a" || exit 1
	for b in *
	do
		[ -e "$b" ] || continue
		ib=$((0x$b)) || exit 1
		cd "$b" || exit 1
		for c in *
		do
			[ -e "$c" ] || continue
			ic=$((0x$c)) || exit 1
			cd "$c" || exit 1
			if [ ! -e cidr ]
			then
				printf "%d.%d.%d.0/24\n" "$ia" "$ib" "$ic"> cidr
				printf "ip/%s/%s/%s %d.%d.%d.0/24\n" "$a" "$b" "$c" "$ia" "$ib" "$ic" >&2
			fi
			cd ..
		done
		cd ..
	done
	cd ..
done