ispman/lib http.lib,1.67,1.68

Joerg Delker <[email protected]> Tue, 27 Nov 2007 23:35:12 +0000
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/lib
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv20546/lib

Modified Files:
	http.lib 
Log Message:
fixed [ 1828830 ] No syntax check before restart of apache is done

Index: http.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/http.lib,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- http.lib	1 Aug 2007 11:15:33 -0000	1.67
+++ http.lib	27 Nov 2007 23:35:07 -0000	1.68
@@ -308,7 +308,8 @@
                 eq "ARRAY" )
             {
                 $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} =
-                  join " ", @{ $vhostHash->{$domain}{$vh}
+                  join " ",
+                  @{ $vhostHash->{$domain}{$vh}
                       {'ispmanVhostDocumentRootOption'} };
             }
 
@@ -442,17 +443,27 @@
 
     close("VHOSTS");
 
-    ### uncomment this if you want checking of the generated file and
-    ### replace "/opt/ispman/bin/httpd -T -f  $name"
-    ### with whatever the command on your system is to check the integrity
-    ### of the conf.
-    ### perhaps cat /etc/httpd/httpd.conf $name | httpd -T
-    ### $name is name of the temporary file that is generated.
-# return 0 unless (system("/opt/ispman/bin/httpd -T -f $name >/dev/null") == 0);
-
+    # does the generated config contain any changes?
     if ( system("diff $vhostConfFile $name > /dev/null 2>&1") ) {
+
+        # replace config
+        system("mv -f $vhostConfFile $vhostConfFile.previous");
         system("mv -f $name $vhostConfFile");
         print "File $name moved to $vhostConfFile\n";
+
+        # verify generated config file
+        my $apacheConfigTestCommand =
+          $ispman->getConf("apacheConfigTestCommand");
+        if ($apacheConfigTestCommand) {
+            print `$apacheConfigTestCommand`;
+            if ( $? > 0 ) {
+
+                # recover old config
+                system("mv -f $vhostConfFile $vhostConfFile.broken");
+                system("mv -f $vhostConfFile.previous $vhostConfFile");
+                return 0;
+            }
+        }
     }
     else {
         unlink("$name");


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4