[Koha-patches] [PATCH] don't try to resolve if WEBSERVER_IP is set and now use WEBSERVER_HOST.

Marc Chantreux marc.chantreux at biblibre.com
Thu Jan 8 01:52:44 CET 2009


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 ?
---
 rewrite-config.PL |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/rewrite-config.PL b/rewrite-config.PL
index 6167c5e..9caadf1 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
-- 
1.5.6.5




More information about the Koha-patches mailing list