8 # Initialise continent and country tables
 
  12 # Create a parser for the country database
 
  13 my $countries = XML::TreeBuilder->new;
 
  15 # Parse the country database
 
  16 $countries->parsefile("lib/countries.xml");
 
  18 # Build continent and country tables
 
  19 foreach my $country ($countries->look_down("_tag" => "country"))
 
  21     my $continent = $country->look_down("_tag" => "continent")->as_text;
 
  22     my $code = $country->look_down("_tag" => "countryCode")->as_text;
 
  24     next if $code eq "SS" or $code eq "XK";
 
  26     $continents{$continent} ||= [];
 
  28     push @countries, $code;
 
  29     push @{$continents{$continent}}, $code;
 
  33 push @countries, "XX";
 
  35 print "plugins => {\n";
 
  36 print "  geoip => {\n";
 
  38 print "      country => {\n";
 
  39 print "        geoip_db => /usr/share/GeoIP/GeoIPv6.dat\n";
 
  40 print "        datacenters => [";
 
  42 print join(",", map { lc($_) } sort @countries);
 
  46 print "          default => [xx]\n";
 
  48 foreach my $continent (sort keys %continents)
 
  50     print "          ${continent} => {\n";
 
  52     foreach my $country (sort @{$continents{$continent}})
 
  54         print "            ${country} => [\L${country}\E]\n";
 
  63 print "    resources => {\n";
 
  65 print "        map => country\n";
 
  66 print "        dcmap => {\n";
 
  68 foreach my $country (sort @countries)
 
  70     print "          \L${country}\E => \L${country}\E.tile.openstreetmap.org.\n";