don't try to resolve if WEBSERVER_IP is set and now use WEBSERVER_HOST.
authorMarc Chantreux <marc.chantreux@biblibre.com>
Thu, 8 Jan 2009 00:52:44 +0000 (00:52 +0000)
committerGalen Charlton <galen.charlton@liblime.com>
Tue, 28 Apr 2009 11:51:45 +0000 (06:51 -0500)
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 <galen.charlton@liblime.com>

rewrite-config.PL

index 6167c5e..9caadf1 100644 (file)
@@ -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