CVS: ispman/lib http.lib,1.44,1.45

Atif Ghaffar <[email protected]>
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv11639

Modified Files:
	http.lib 
Log Message:
some more checking for the logdir and statdir. Both these are optional. In case they are not there, the older behaviour should be default

Index: http.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/http.lib,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -r1.44 -r1.45
*** http.lib	8 Oct 2003 02:58:29 -0000	1.44
--- http.lib	8 Oct 2003 04:08:31 -0000	1.45
***************
*** 23,29 ****
  
  sub read_vhosts_hash{
! 	my $vhostsFile=shift;
! 	do  $vhostsFile;
!   return $VAR1;
  }
  
--- 23,30 ----
  
  sub read_vhosts_hash{
!     my $vhostsFile=shift;
!     print "Reading hash file $vhostsFile\n";
!     do  $vhostsFile;
!     return $VAR1;
  }
  
***************
*** 31,34 ****
--- 32,36 ----
    my ($file, $hash) = @_;
  
+   print "Writting  hash file $file\n";
    open "F", ">$file";
      print F Dumper($hash);
***************
*** 40,44 ****
    my ($vhost, $domain) = @_;
    next unless $vhost and $domain;
!    
    my $vhostInfo = $ispman->getVhostInfo($vhost, $domain);
  	#print Dumper($vhostInfo);
--- 42,46 ----
    my ($vhost, $domain) = @_;
    next unless $vhost and $domain;
! 
    my $vhostInfo = $ispman->getVhostInfo($vhost, $domain);
  	#print Dumper($vhostInfo);
***************
*** 51,61 ****
  		# These aliases are not fully qualified names.
  		push @_ispmanVhostServerAliases, join '.', ($ispmanVhostServerAliases->{$_}{'ispmanVhostServerAlias'}, $domain);
! 		
  	}
  
  
  	$vhostInfo->{'ispmanVhostServerAlias'}=$ispman->as_arrayref(@_ispmanVhostServerAliases, $vhostInfo->{'ispmanVhostServerAlias'});
!         
! 	
  
    my $domainInfo = $ispman->getDomainInfo($domain);
--- 53,63 ----
  		# These aliases are not fully qualified names.
  		push @_ispmanVhostServerAliases, join '.', ($ispmanVhostServerAliases->{$_}{'ispmanVhostServerAlias'}, $domain);
! 
  	}
  
  
  	$vhostInfo->{'ispmanVhostServerAlias'}=$ispman->as_arrayref(@_ispmanVhostServerAliases, $vhostInfo->{'ispmanVhostServerAlias'});
! 
! 
  
    my $domainInfo = $ispman->getDomainInfo($domain);
***************
*** 66,70 ****
      $vhostHashFile = "$vhostConfFile/hash/$domain.hash";
      $vhostConfFile .= "/conf/$domain.conf";
!   }   
  
    # this is useful if there is no homedirectory defined
--- 68,72 ----
      $vhostHashFile = "$vhostConfFile/hash/$domain.hash";
      $vhostConfFile .= "/conf/$domain.conf";
!   }
  
    # this is useful if there is no homedirectory defined
***************
*** 72,76 ****
    $domainInfo->{'homedirectory'}||=join "/", ($ispman->getConf("defaultHomeDirectoryPath"), $domain);
    $domain_replicas = $ispman->getReplicasOfDomain($domain);
!    
    print "Working on $vhost.$domain\n\n";
  
--- 74,78 ----
    $domainInfo->{'homedirectory'}||=join "/", ($ispman->getConf("defaultHomeDirectoryPath"), $domain);
    $domain_replicas = $ispman->getReplicasOfDomain($domain);
! 
    print "Working on $vhost.$domain\n\n";
  
***************
*** 126,130 ****
    delete $_ispmanVhostDocumentRootOption->{'AllowFrontPage'};
    delete $_ispmanVhostDocumentRootOption->{'AllowApacheASP'};
!    
    $vhostInfo->{'ispmanVhostDocumentRootOption'} = [keys %$_ispmanVhostDocumentRootOption];
  
--- 128,132 ----
    delete $_ispmanVhostDocumentRootOption->{'AllowFrontPage'};
    delete $_ispmanVhostDocumentRootOption->{'AllowApacheASP'};
! 
    $vhostInfo->{'ispmanVhostDocumentRootOption'} = [keys %$_ispmanVhostDocumentRootOption];
  
***************
*** 161,177 ****
    }
  
-   if ($vhostInfo->{'ispmanVhostLogdir'} !~ /^\//) {
-     $vhostHash->{$domain}{$vhost}{'logdir'} = join "/", ($domainInfo->{'homeDirectory'}, "vhosts", $vhostInfo->{'ispmanVhostLogdir'});
-   } else {
-     ### its a static/non-relative directory. It starts with a "/"
-     $vhostHash->{$domain}{$vhost}{'logdir'} = $vhostInfo->{'ispmanVhostLogdir'};
-   }
  
!   if ($vhostInfo->{'ispmanVhostStatdir'} !~ /^\//) {
!     $vhostHash->{$domain}{$vhost}{'statdir'} = join "/", ($domainInfo->{'homeDirectory'}, "vhosts", $vhostInfo->{'ispmanVhostStatdir'});
    } else {
!     ### its a static/non-relative directory. It starts with a "/"
!     $vhostHash->{$domain}{$vhost}{'statdir'} = join "/", ($vhostInfo->{'ispmanVhostStatdir'});
    }
  
    ### Check for log and stat dir and make them if need be
--- 163,197 ----
    }
  
  
!   if ($vhostInfo->{'ispmanVhostLogdir'} =~/\S/) {
!      if ($vhostInfo->{'ispmanVhostLogdir'} !~ /^\//) {
!          # ispmanVhostLogdir is defined and is not relative
!          $vhostHash->{$domain}{$vhost}{'logdir'} = join "/", ($domainInfo->{'homeDirectory'}, "vhosts", $vhostInfo->{'ispmanVhostLogdir'});
!            } else {
!         ### its a static/non-relative directory. It starts with a "/"
!         $vhostHash->{$domain}{$vhost}{'logdir'} = $vhostInfo->{'ispmanVhostLogdir'} ;
!           }
    } else {
!          ### it is not defined so we use the default apacheLogsDirectory
!          $vhostHash->{$domain}{$vhost}{'logdir'} = $apacheLogsDirectory;
    }
+   print "Setting logdir to $vhostHash->{$domain}{$vhost}{'logdir'}\n";
+ 
+   if ($vhostInfo->{'ispmanVhostStatdir'} =~/\S/) {
+     if ($vhostInfo->{'ispmanVhostStatdir'} !~ /^\//) {
+        $vhostHash->{$domain}{$vhost}{'statdir'} = join "/", ($domainInfo->{'homeDirectory'}, "vhosts", $vhostInfo->{'ispmanVhostStatdir'});
+      } else {
+          ### its a static/non-relative directory. It starts with a "/"
+          $vhostHash->{$domain}{$vhost}{'statdir'} = join "/", ($vhostInfo->{'ispmanVhostStatdir'});
+      }
+      print "Setting statdir to $vhostHash->{$domain}{$vhost}{'statdir'}\n";
+     unless (-d $vhostHash->{$domain}{$vhost}{'statdir'}."/report") {
+       print "Statdir ".$vhostHash->{$domain}{$vhost}{'statdir'}."/report did not exist. Creating now.\n";
+       print "mkdir -p $vhostHash->{$domain}{$vhost}{'statdir'}/report \n";
+       system "mkdir -p $vhostHash->{$domain}{$vhost}{'statdir'}/report \n";
+     }
+    }
+ 
+ 
  
    ### Check for log and stat dir and make them if need be
***************
*** 181,191 ****
      system "mkdir -p $vhostHash->{$domain}{$vhost}{'logdir'} \n";
    }
!   unless (-d $vhostHash->{$domain}{$vhost}{'statdir'}."/report") {
!     print "Statdir ".$vhostHash->{$domain}{$vhost}{'statdir'}."/report did not exist. Creating now.\n";
!     print "mkdir -p $vhostHash->{$domain}{$vhost}{'statdir'}/report \n";
!     system "mkdir -p $vhostHash->{$domain}{$vhost}{'statdir'}/report \n";
!   }
!   print "Writing $vhostHashFile\n";
!   write_vhosts_hash("$vhostHashFile", $vhostHash);	   
  }
  
--- 201,207 ----
      system "mkdir -p $vhostHash->{$domain}{$vhost}{'logdir'} \n";
    }
! 
! 
!   write_vhosts_hash("$vhostHashFile", $vhostHash);
  }
  
***************
*** 242,253 ****
      for my $vh (keys %{$vhostHash->{$domain}}) {
        next unless $vh=~ /\S/;
!          
!       ### we dont pass an ARRAY ref to the poor template. 
        ### Lets keep the template simple and do complex stuff here
!         
        if (ref $vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'} eq "ARRAY") {
          $vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'} = join " ", @{$vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'}};
        }
!         
        if (ref $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} eq "ARRAY") {
          $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} = join " ", @{$vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'}};
--- 258,269 ----
      for my $vh (keys %{$vhostHash->{$domain}}) {
        next unless $vh=~ /\S/;
! 
!       ### we dont pass an ARRAY ref to the poor template.
        ### Lets keep the template simple and do complex stuff here
! 
        if (ref $vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'} eq "ARRAY") {
          $vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'} = join " ", @{$vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'}};
        }
! 
        if (ref $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} eq "ARRAY") {
          $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} = join " ", @{$vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'}};



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.