From 9902f24c13aaab88ed06ecaf8575173cfc15c51f Mon Sep 17 00:00:00 2001 From: Marc Chantreux Date: Thu, 8 Jan 2009 00:52:44 +0000 Subject: [PATCH] don't try to resolve if WEBSERVER_IP is set and now use WEBSERVER_HOST. as it crashed the installer when DNS doesn't respond as expected. it will now use the WEBSERVER_HOST described in the doc but unused in the script. TODO: - lot of koha-httpd.conf generation is useless if you plan to use vhosts strategy - on some recent linux distributions, $(getent hosts `hostname`) will give us 127.0.0.1. this is to not mess up the MTA when there is no network. Don't you think there would be an error message in this case? - default domain is localdomain .. this is not a good idea but i haven't a better one. can a network guru fix that ? Signed-off-by: Galen Charlton --- rewrite-config.PL | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/rewrite-config.PL b/rewrite-config.PL index 6167c5ee00..9caadf17fb 100644 --- a/rewrite-config.PL +++ b/rewrite-config.PL @@ -60,15 +60,21 @@ also need to override WEBSERVER_IP. =cut -$myhost = hostname(); -$mydomain = $myhost; -$mydomain =~ s/^.*?\.//; -# This is set here to rescue systems with broken DNS -if ( !gethostbyname( $myhost || 'localhost' ) ) { - die 'Could not get the IP address of ' . ( $myhost || 'localhost' ) . ', DNS fault?'; +if ( $myhost = $ENV{WEBSERVER_HOST} || hostname ) { + ( $mydomain = $myhost ) =~ s/.*?\.//; +} else { + $myhost = 'localhost'; + $mydomain = 'localdomain'; } -$myip = $ENV{'WEBSERVER_IP'} || inet_ntoa( scalar gethostbyname( $myhost||'localhost' ) ); +unless ( $myip = $ENV{WEBSERVER_IP} ) { + my $byname = gethostbyname( $myhost ) + or die "Could not get the IP address of $myhost, DNS fault? ($!)"; + $myip = inet_ntoa $byname + or die "can't inet_ntoa ($!)"; +} + + $prefix = $ENV{'INSTALL_BASE'} || "/usr"; # These are our configuration guesses -- 2.20.1