Commit 08a61cbb authored by intrigeri's avatar intrigeri
Browse files

Encode the biggest allocated mirror ID in the CNAME record.

This feels like a more robust way to track what's the highest allocated mirror
ID than the previous loop. And contrary to the previous implementation, it
doesn't rely on the fact that there is no hole in the range of the NNN.dl.a.b.o
we've allocated (which should be more robust against mistakes in the pool
parent e982c38b
......@@ -6,18 +6,22 @@ set -o pipefail
function usage {
echo "Usage: $0 IP"
echo "Creates a A record pointing to IP"
echo "Creates a A record pointing to IP,"
echo "and updates the CNAME record to"
echo "point to that new host name."
exit 1
function next_free_mirror_id {
while host -t a "$" >/dev/null ; do
current=$(($current + 1))
echo $current
last_hostname=$(dig CNAME +short \
| sed -e 's,\.$,,')
last_id=$(echo "$last_hostname" \
| perl -p -E 's,^(\d+)\.dl\.amnesia\.boum\.org$,$1,')
echo "$last_id" | grep -qs --line-regexp --extended-regexp '[0-9]+' || exit 2
echo $(($last_id + 1))
[ "$#" -eq 1 ] || usage
[ -z "$1" ] && usage
......@@ -26,8 +30,12 @@ nsupdate -v -k ~/lizard-boum.key << EOF
prereq nxrrset $ A
prereq yxdomain
prereq yxrrset CNAME
update add $ 300 A $1
update delete 300 CNAME
update add 300 CNAME $
echo "Created $"
echo "Created $, and updated"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment