File: //scripts.20110531.215904.25158/restartsrv_mailman
#!/usr/bin/perl
# cpanel - restartsrv_mailman Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel', '/scripts'; }
## note: copied from restartsrv_tailwatchd and modified
use RestartSrv;
use strict;
eval {
local $SIG{'__DIE__'};
require Cpanel::Rlimit;
Cpanel::Rlimit::set_rlimit_to_infinity();
};
setuppath();
my ( $restart, $check, $status ) = parseargv();
my $service = 'mailmanctl';
my $processowner = 'mailman';
## in other words, does $processowner or $service depend on $system
#OUT#( $processowner, $service ) = servicefixup( $system, $service );
my $disabled = 0;
## TODO: case 5966 and 30562
if ( -e '/etc/mailmandisable' ) {
$disabled = 1;
}
my $mailmanctl = '/usr/local/cpanel/3rdparty/mailman/bin/mailmanctl';
if ( $restart && !$disabled ) {
my $lock_file = '/var/run/restartsrv_mailman.lock';
lock_file($lock_file);
nooutputsystem( $mailmanctl, 'stop' );
doomedprocess( $service );
doomedprocess( "qrunner" );
## e.g. invoked with '--stop'
if ( $restart != -1 ) {
## note: otherwise, we get the """The master qrunner lock could not be acquired.
## It appears as though there is a stale master qrunner lock.""" warning
nooutputsystem( $mailmanctl, '--stale-lock-cleanup', 'start' );
}
unlink $lock_file if -e $lock_file;
}
elsif ($status) {
#--status (show ps)
if ($disabled) {
print "$service is disabled\n";
}
else {
print check_service( 'service' => $service, 'user' => $processowner );
print check_service( 'service' => '3rdparty/mailman/bin/qrunner', 'user' => $processowner );
}
}
elsif ($check) {
exit if ($disabled);
if ( check_service( 'service' => $service, 'user' => $processowner ) eq '' ) {
print "$service is not running\n";
}
}