aboutsummaryrefslogtreecommitdiffstats
path: root/SiteSummary.pm
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2011-12-17 14:47:55 +0000
committerPetter Reinholdtsen <pere@hungry.com>2011-12-17 14:47:55 +0000
commit3e7133117f4cf3c3ad2823610b255416f9beaefe (patch)
tree3aa43c592488c180b8acc189471beb1c8bd1beeb /SiteSummary.pm
parent120798867d5fed900dec9f17c13e361f49101cc4 (diff)
downloadsitesummary-3e7133117f4cf3c3ad2823610b255416f9beaefe.tar.gz
sitesummary-3e7133117f4cf3c3ad2823610b255416f9beaefe.tar.bz2
sitesummary-3e7133117f4cf3c3ad2823610b255416f9beaefe.tar.xz
Add support for hostmap.d/ and comments.
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 {