]> git.openstreetmap.org Git - dns.git/blob - bin/mkgdns
Update IP addresses for move from Imperial to Amsterdam
[dns.git] / bin / mkgdns
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use XML::TreeBuilder;
7
8 # Initialise continent and country tables
9 my %continents;
10 my @countries;
11
12 # Create a parser for the country database
13 my $countries = XML::TreeBuilder->new;
14
15 # Parse the country database
16 $countries->parsefile("lib/countries.xml");
17
18 # Build continent and country tables
19 foreach my $country ($countries->look_down("_tag" => "country"))
20 {
21     my $continent = $country->look_down("_tag" => "continent")->as_text;
22     my $code = $country->look_down("_tag" => "countryCode")->as_text;
23
24     next if $code eq "SS" or $code eq "XK";
25
26     $continents{$continent} ||= [];
27
28     push @countries, $code;
29     push @{$continents{$continent}}, $code;
30 }
31
32 # Add unknown country
33 push @countries, "XX";
34
35 print "plugins => {\n";
36 print "  geoip => {\n";
37 print "    maps => {\n";
38 print "      country => {\n";
39 print "        geoip_db => /usr/share/GeoIP/GeoIPv6.dat\n";
40 print "        datacenters => [";
41
42 print join(",", map { lc($_) } sort @countries);
43
44 print "]\n";
45 print "        map => {\n";
46 print "          default => [xx]\n";
47
48 foreach my $continent (sort keys %continents)
49 {
50     print "          ${continent} => {\n";
51
52     foreach my $country (sort @{$continents{$continent}})
53     {
54         print "            ${country} => [\L${country}\E]\n";
55     }
56
57     print "          }\n";
58 }
59
60 print "        }\n";
61 print "      }\n";
62 print "    }\n";
63 print "    resources => {\n";
64 print "      tile => {\n";
65 print "        map => country\n";
66 print "        dcmap => {\n";
67
68 foreach my $country (sort @countries)
69 {
70     print "          \L${country}\E => \L${country}\E.tile.openstreetmap.org.\n";
71 }
72
73 print "        }\n";
74 print "      }\n";
75 print "    }\n";
76 print "  }\n";
77 print "}\n";
78
79 exit 0;