MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //scripts.20110531.215904.25158/restartsrv_spamd
#!/usr/bin/perl
# cpanel - restartsrv_spamd                       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'; }

use strict;
use Cpanel::OSSys       ();
use Cpanel::CleanupStub ();
use RestartSrv;

$ENV{'TMPDIR'} = '/tmp' if -d '/tmp';

eval {
    local $SIG{'__DIE__'};
    require Cpanel::Rlimit;
    Cpanel::Rlimit::set_rlimit_to_infinity();
};

setuppath();

my ( $system, $nodename, $release, $version, $machine ) = Cpanel::OSSys::uname();
my ( $restart, $check, $status ) = parseargv();

my $spamd_manualstart = needsmanualstart( $system, 'spamd' );
my $spamdscript = getinitfile( 'spamd', $system );
my $disabled = -e '/etc/spamddisable' ? 1 : 0;

if ( $restart && !$disabled ) {

    my $lock_file = '/var/run/restartsrv_spamd.lock';
    lock_file($lock_file);

    if ( $restart != -1 ) {
        system '/scripts/update_sa_rules';
    }
    if ( my $pid = fork() ) {
        waitpid( $pid, 0 );
    }
    else {
        Cpanel::OSSys::setsid();
        Cpanel::CleanupStub::daemonclosefds();

        if ( $spamdscript && !$spamd_manualstart ) {
            nooutputsystem( $spamdscript, 'stop' );
            doomedprocess('spamd');

            #Bludgeon spamd because it doesn't play nice
            system '/scripts/ckillall', '-TERM', 'spamd -d';

            if ( $restart != -1 ) {
                $ENV{'LANG'}   = 'C';
                $ENV{'LC_ALL'} = 'C';
                system $spamdscript, 'start';
            }
        }
        else {
            my $spamdoptions = getspamdopts();
            doomedprocess('spamd');

            # Bludgeon spamd because it doesn't play nice
            if ( $system =~ m/freebsd/i ) {
                system '/scripts/ckillall', '-TERM', 'spamd -d';
            }

            if ( $restart != -1 ) {
                if ( -x '/usr/bin/spamd' ) {
                    $ENV{'LANG'}   = 'C';
                    $ENV{'LC_ALL'} = 'C';
                    system "/usr/bin/spamd -d $spamdoptions";
                }
                elsif ( -x '/usr/local/bin/spamd' ) {
                    $ENV{'LANG'}   = 'C';
                    $ENV{'LC_ALL'} = 'C';
                    system("/usr/local/bin/spamd -d $spamdoptions");
                }
            }
        }
        exit;
    }
    unlink $lock_file if -e $lock_file;
}
elsif ($status) {
    if ($disabled) {
        print "spamd is disabled\n";
    }
    else {
        print check_service( 'service' => 'spamd', 'user' => 'root' );
    }
}
elsif ($check) {
    exit if ($disabled);
    my ($spamdstat,$raw_out) = spamdcheck();
    if ( $spamdstat == 0 ) {
        print "Spamd is not running\nRaw Output: $raw_out\n";
    }
}