Mercurial > hg > anonet-resdb
annotate scripts/add_ip @ 1094:1d2f501fa55e draft
epoch added as 4141 and CIDR 1.41.41.0/24
author | epoch <epoch@hacking.allowed.org> |
---|---|
date | Sun, 24 Mar 2013 12:51:10 +0000 |
parents | 31e3b4edf502 |
children | 2f57d4d36759 |
rev | line source |
---|---|
19
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
1 #!/bin/sh |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
2 |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
3 if [ x"$2" = x ]; then |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
4 echo "Usage: $0 <cidr> <owner> [<ns[/nsip]>...]" >&2; exit 255 |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
5 fi |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
6 |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
7 cidr="$1" |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
8 hex="$(./scripts/cidr2hex "$cidr")" |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
9 dir=db/ip/"$hex" |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
10 if [ -e "$dir" ]; then |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
11 echo "Refusing to clobber existing record" >&2; exit 1 |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
12 fi |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
13 mkdir -p "$dir" || exit 1 |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
14 echo "$cidr" > "$dir"/cidr |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
15 echo "$2" > "$dir"/owner |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
16 mkdir "$dir"/ns || exit 1 |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
17 shift; shift; |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
18 while [ x"$1" != x ]; do |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
19 echo "$1" | tr / ' ' | ( |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
20 read ns nsip |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
21 echo "$nsip" > "$dir/ns/$ns" |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
22 ) |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
23 shift; |
31e3b4edf502
scripts for dom&ip, dn42 resdb, and doc (www.anonet2.org)
Nick <nick@somerandomnick.ano>
parents:
diff
changeset
|
24 done |