From 54768f856e563a7501e578586ceb7ed1d0da4a43 Mon Sep 17 00:00:00 2001 From: XeOn Date: Thu, 20 Dec 2007 09:53:36 +1300 Subject: [PATCH] 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. --- src/spong-network.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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; } -- 2.30.2