aboutsummaryrefslogtreecommitdiffstats
path: root/SiteSummary.pm
diff options
context:
space:
mode:
Diffstat (limited to 'SiteSummary.pm')
-rw-r--r--SiteSummary.pm28
1 files changed, 19 insertions, 9 deletions
diff --git a/SiteSummary.pm b/SiteSummary.pm
index 43d459d..53b3c50 100644
--- a/SiteSummary.pm
+++ b/SiteSummary.pm
@@ -39,20 +39,30 @@ my $debian_edu_config = "/debian-edu/config";
# available via tunnels.
my $hostmapfile = "/etc/sitesummary/hostmap";
+my $hostmapdir = "/etc/sitesummary/hostmap.d";
my %hostmap;
sub load_hostmap {
- if (open(my $fh, '<', $hostmapfile)) {
- %hostmap = (); # Clear hostmap
- while (<$fh>) {
- chomp;
- my ($hostid, $newhostname) = split(/\s+/);
- $hostmap{$hostid} = $newhostname;
+ my @files = ($hostmapfile);
+ %hostmap = (); # Clear hostmap
+
+ if (opendir(my $dh, $hostmapdir)) {
+ push(@files, grep { /^\./ && -f "$some_dir/$_" } sort readdir($dh));
+ closedir $dh;
+ }
+ for my $file (@files) {
+ if (open(my $fh, '<', $file)) {
+ while (<$fh>) {
+ chomp;
+ s/\#.*$//;
+ next if m/^\s*$/;
+ my ($hostid, $newhostname) = split(/\s+/);
+ $hostmap{$hostid} = $newhostname;
+ }
+ close $fh;
}
- close $fh;
- } else {
- return;
}
+ return;
}
sub get_filepath_current {