2012-06-27 09:27:35 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2013-04-20 22:11:52 +02:00
|
|
|
$|++; # OUTPUT_AUTOFLUSH
|
|
|
|
|
2012-06-30 02:39:44 +02:00
|
|
|
use Cwd;
|
2012-06-27 09:27:35 +02:00
|
|
|
use Data::Dumper;
|
|
|
|
use File::Tail;
|
|
|
|
|
2012-06-30 02:39:44 +02:00
|
|
|
my $dir = get_qp_dir() or die "unable to find QP home dir";
|
|
|
|
my $file = "$dir/log/main/current";
|
2013-03-23 05:52:06 +01:00
|
|
|
my $fh = File::Tail->new(name=>$file, interval=>1, maxinterval=>1, debug =>1, tail =>300 );
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
while ( defined (my $line = $fh->read) ) {
|
|
|
|
my (undef, $line) = split /\s/, $line, 2; # strip off tai timestamps
|
|
|
|
print $line;
|
|
|
|
};
|
|
|
|
|
2012-06-30 02:39:44 +02:00
|
|
|
sub get_qp_dir {
|
2012-06-27 09:27:35 +02:00
|
|
|
foreach my $user ( qw/ qpsmtpd smtpd / ) {
|
|
|
|
my ($homedir) = (getpwnam( $user ))[7] or next;
|
|
|
|
|
2012-06-30 02:39:44 +02:00
|
|
|
if ( -d "$homedir/plugins" ) {
|
|
|
|
return "$homedir";
|
2012-06-27 09:27:35 +02:00
|
|
|
};
|
2012-06-30 02:39:44 +02:00
|
|
|
foreach my $s ( qw/ smtpd qpsmtpd qpsmtpd-dev / ) {
|
|
|
|
if ( -d "$homedir/$s/plugins" ) {
|
|
|
|
return "$homedir/$s";
|
|
|
|
};
|
2012-06-27 09:27:35 +02:00
|
|
|
};
|
|
|
|
};
|
2012-06-30 02:39:44 +02:00
|
|
|
if ( -d "./plugins" ) {
|
|
|
|
return Cwd::getcwd();
|
|
|
|
};
|
2012-06-27 09:27:35 +02:00
|
|
|
};
|
2012-06-30 02:39:44 +02:00
|
|
|
|