-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgen-fg_server_map.html.pl
More file actions
executable file
·103 lines (69 loc) · 1.93 KB
/
gen-fg_server_map.html.pl
File metadata and controls
executable file
·103 lines (69 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/perl -w
# Simple perl script to generate fg_server_map.html from fg_server_map.html.in
# See README, fgmap.keys and fgmap.servers
use strict;
my $FGMAP_KEYS = 'fgmap.keys';
my $FGMAP_KEYS_TAG = '<!-- ### fgmap.keys ### -->';
my $FGMAP_SERVERS = 'fgmap.servers';
my $FGMAP_SERVERS_TAG = '// ### fgmap.servers ###';
my $TEMPLATE = 'fg_server_map.html.in';
my $OUTPUT = 'fg_server_map.html';
my $GMAPI_VERSION = '2.66';
my $ssis = "";
my @lines;
my $fh;
open($fh, ${FGMAP_KEYS}) or die("${FGMAP_KEYS} does not exist...");
@lines = grep(!/(^#|^$)/, <$fh>);
close($fh);
print("Reading [${FGMAP_KEYS}]\n");
foreach my $l (@lines)
{
chomp($l);
my($host, $key) = split(/::/, $l);
print("Adding key for host [${host}]\n");
$ssis .= <<SSI;
<!--#if expr="\\"\${HTTP_HOST}\\" = \\"${host}\\"" -->
<!-- Using HTTP_HOST ${host} -->
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?key=${key}&sensor=false"></script>
<!--#endif -->
SSI
}
my $js = "";
open($fh, ${FGMAP_SERVERS}) or die("${FGMAP_SERVERS} does not exist...");
@lines = grep(!/(^#|^$)/, <$fh>);
close($fh);
print("Reading [${FGMAP_SERVERS}]\n");
foreach my $l (@lines)
{
chomp($l);
my($id, $desc, $host, $port, $ip) = split(/::/, $l, 5);
if($id && $desc && $host && $port)
{
print("Adding server [${id}]\n");
$js .= <<JS;
fgmap.server_add("${id}",
"${desc}",
"${host}", ${port},
"${ip}");
JS
}
elsif($id)
{
print("Adding server group [${id}]\n");
$js .= <<JS;
fgmap.server_group_add("${id}");
JS
}
}
open($fh, ${TEMPLATE});
my($lines) = join("", <$fh>);
close($fh);
$lines =~ s/${FGMAP_KEYS_TAG}/${ssis}/;
$lines =~ s/${FGMAP_SERVERS_TAG}/${js}/;
print("Generating [${OUTPUT}]\n");
open($fh, ">${OUTPUT}");
print($fh $lines);
close($fh);
print("Done.\n");
exit(0);
# vim: set sw=4 sts=4 expandtab: #