From: XeOn Date: Wed, 19 Dec 2007 20:53:36 +0000 (+1300) Subject: Allow having hosts file by hostname. X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54768f856e563a7501e578586ceb7ed1d0da4a43;p=spong.git Allow having hosts file by hostname. This allows you to share the Spong config file between a bunch of hosts using NFS (or other method), which can ease configuration. Patch originally written by XeOn (pspa@isp.novis.pt) on Wed, Nov 22 2000 I've tidied it up a little bit. --- diff --git a/src/spong-network.pl b/src/spong-network.pl index 4ed8b74..72f7447 100755 --- a/src/spong-network.pl +++ b/src/spong-network.pl @@ -478,7 +478,18 @@ sub load_config_files { # some junk to scan through the file so that we can maintain the order of # the hosts as they appear in the file. - open( HOSTS, $hosts_file ) || die "Can't load $hosts_file: $!"; + # This is a little hack to allow the use of 'spong.hosts.hostname" (as in + # spong.conf.hostname. + my $hname = `hostname`; + chomp $hname; + if ( -f "$hosts_file.$hname" ) { + open( HOSTS, "$hosts_file.$hname" ) + || die "Can't load $hosts_file.$hname: $!"; + } else { + open( HOSTS, $hosts_file ) + || die "Can't load $hosts_file: $!"; + } + while( ) { $evalme .= $_; if( /^\s*%HOSTS\s*=\s*\(/ ) { $inhosts = 1; }