logs: improve ability to find logs

This commit is contained in:
Matt Simerson 2012-06-29 20:39:44 -04:00
parent 56f41de1ec
commit 6a24626f33
2 changed files with 16 additions and 10 deletions

View File

@ -284,8 +284,8 @@ sub get_qp_dir {
return "$homedir"; return "$homedir";
}; };
foreach my $s ( qw/ smtpd qpsmtpd qpsmtpd-dev / ) { foreach my $s ( qw/ smtpd qpsmtpd qpsmtpd-dev / ) {
if ( -d "$homedir/smtpd/plugins" ) { if ( -d "$homedir/$s/plugins" ) {
return "$homedir/smtpd"; return "$homedir/$s";
}; };
}; };
}; };

View File

@ -3,11 +3,12 @@
use strict; use strict;
use warnings; use warnings;
use Cwd;
use Data::Dumper; use Data::Dumper;
use File::Tail; use File::Tail;
my $dir = find_qp_log_dir() or die "unable to find QP home dir"; my $dir = get_qp_dir() or die "unable to find QP home dir";
my $file = "$dir/main/current"; my $file = "$dir/log/main/current";
my $fh = File::Tail->new(name=>$file, interval=>1, maxinterval=>1, debug =>1, tail =>100 ); my $fh = File::Tail->new(name=>$file, interval=>1, maxinterval=>1, debug =>1, tail =>100 );
while ( defined (my $line = $fh->read) ) { while ( defined (my $line = $fh->read) ) {
@ -15,16 +16,21 @@ while ( defined (my $line = $fh->read) ) {
print $line; print $line;
}; };
sub find_qp_log_dir { sub get_qp_dir {
foreach my $user ( qw/ qpsmtpd smtpd / ) { foreach my $user ( qw/ qpsmtpd smtpd / ) {
my ($homedir) = (getpwnam( $user ))[7] or next; my ($homedir) = (getpwnam( $user ))[7] or next;
if ( -d "$homedir/log" ) { if ( -d "$homedir/plugins" ) {
return "$homedir/log"; return "$homedir";
}; };
if ( -d "$homedir/smtpd/log" ) { foreach my $s ( qw/ smtpd qpsmtpd qpsmtpd-dev / ) {
return "$homedir/smtpd/log"; if ( -d "$homedir/$s/plugins" ) {
return "$homedir/$s";
}; };
}; };
}; };
if ( -d "./plugins" ) {
return Cwd::getcwd();
};
};