view scripts/add_ip @ 972:96dd81a3c298 draft

The artist formerly known as spoonzy - now known as lucifer presents this git commit as his entry into the resdb On branch master Changes to be committed: new file: db/dom/ano/lucifer/ns/a.ns.lucifer.ano new file: db/dom/ano/lucifer/owner new file: db/ip/01/06/00/cidr new file: db/ip/01/06/00/owner new file: db/usr/lucifer/git
author lucifer <contact@lucifer.ano>
date Wed, 01 Aug 2012 02:46:51 +0000
parents 31e3b4edf502
children 2f57d4d36759
line wrap: on
line source

#!/bin/sh

if [ x"$2" = x ]; then
 echo "Usage: $0 <cidr> <owner> [<ns[/nsip]>...]" >&2; exit 255
fi

cidr="$1"
hex="$(./scripts/cidr2hex "$cidr")"
dir=db/ip/"$hex"
if [ -e "$dir" ]; then
 echo "Refusing to clobber existing record" >&2; exit 1
fi
mkdir -p "$dir" || exit 1
echo "$cidr" > "$dir"/cidr
echo "$2" > "$dir"/owner
mkdir "$dir"/ns || exit 1
shift; shift;
while [ x"$1" != x ]; do
 echo "$1" | tr / ' ' | (
  read ns nsip
  echo "$nsip" > "$dir/ns/$ns"
 )
 shift;
done