All pastes #526529 Raw Edit

Untitled

public text v1 · immutable
#526529 ·published 2007-05-31 20:53 UTC
rendered paste body
#!/usr/bin/perl

use strict;
use Apache::ConfigFile;
use Data::Dumper;

my $vhosts = parseVhosts();

#print Dumper($vhosts);

sub parseVhosts {
  for my $conf (qw(preview3.conf searchDomains.conf vhosts.conf )) {
    my $ac = Apache::ConfigFile->read('/usr/local/etc/apache2/Includes/'.$conf);
    for my $ip ( qw(216.126.79.106:80 216.126.79.105:80 216.126.79.107 216.126.79.105 216.126.79.106 ) ) {
      for my $vh ($ac->cmd_context(VirtualHost => $ip)) {
        my $vhost = $vh->cmd_config('ServerName');
        my $log =   $vh->cmd_config('CustomLog');
        $vhost =~ s/www\.//g;
        $log =~ m/\|\/usr\/local\/sbin\/rotatelogs (.*) 605800/;
        $log = $1;
        push @{$vhosts},{ vhost => $vhost, log => $log };
        print $vhost."\n";
      }
    }
  }

  return $vhosts;
}