# Open output files
my $zonefile = IO::File->new("> include/${zone}.js") || die "$!";
-my $jsonfile = IO::File->new("> json/${zone}.json") || die "$!";
+my $jsonfile = IO::File->new("> json/${zone}.openstreetmap.org.json") || die "$!";
# Output headers
$zonefile->print("var \U${zone}\E_RECORDS = [\n");
if (my $default = $cluster->{default})
{
- output_server($zonefile, "${default}.${zone}", $cluster);
+ output_server($zonefile, "${default}.${zone}", $cluster, 0);
}
elsif (exists($cluster->{default}))
{
- output_server($zonefile, "${zone}", $cluster);
+ output_server($zonefile, "${zone}", $cluster, 0);
}
}
}
{
my $name = $cluster->{name};
- output_server($zonefile, "${name}.${zone}", $cluster);
-
if (@{$cluster->{servers}} > 1)
{
- output_server($zonefile, "${name}-%02d.${zone}", $cluster);
+ output_server($zonefile, "${name}-%02d.${zone}", $cluster, 1);
+ }
+ else
+ {
+ output_server($zonefile, "${name}.${zone}", $cluster, 1);
}
}
my $number = sprintf("%02d", $index + 1);
my $bandwidth = $server->{bandwidth};
- $gdnsweightedfile->print(" ${name}-${number} = [ ${name}-${number}.${zone}., ${bandwidth} ]\n");
+ $gdnsweightedfile->print(" ${name}-${number} = [ ${name}-${number}.${zone}.openstreetmap.org., ${bandwidth} ]\n");
}
}
}
else
{
- $gdnsresourcefile->print(" ${name} => ${name}.${zone}.\n");
+ $gdnsresourcefile->print(" ${name} => ${name}.${zone}.openstreetmap.org.\n");
}
}
my $zonefile = shift;
my $name = shift;
my $cluster = shift;
+ my $all = shift;
while (my($index,$server) = each @{$cluster->{servers}})
{
- if ($server->{status} eq "up")
+ if ($all || $server->{status} eq "up")
{
$zonefile->printf(" A(\"${name}\", \"$server->{ipv4}\", TTL(\"10m\")),\n", $index + 1);
if ($server->{ipv6})
{
- my $ipv6 = $server->{ipv6};
-
- $ipv6 =~ s/([0-9a-f]{4})(?=.)/$1:/ig;
-
- $zonefile->printf(" AAAA(\"${name}\", \"${ipv6}\", TTL(\"10m\")),\n", $index + 1);
+ $zonefile->printf(" AAAA(\"${name}\", \"$server->{ipv6}\", TTL(\"10m\")),\n", $index + 1);
}
}
}