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_ftpserver
#!/usr/bin/perl
# cpanel - restartsrv_ftpserver                   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 RestartSrv;
use Cpanel::OSSys ();
use strict;

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

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

setuppath();

my $iscript        = '';
my $initdir        = '';
my $service        = 'ftpserver';
my $processowner   = '';
my $overridercconf = '';
my $manualstart    = 0;
my $servicebin     = '';
my $serviceflags   = '';
my $disabled       = 0;

( $processowner, $service, $iscript, $manualstart, $servicebin, $serviceflags, $disabled ) = servicefixup( $system, $service );

if ( $restart && !$disabled ) {

    my $pureauth = '/usr/sbin/pureauth';
    if ( $system =~ m/freebsd/i ) {
        $pureauth = '/usr/local/sbin/pureauth';
    }
    if (
        $servicebin =~ /pure/i
        && (   ( stat('/usr/local/cpanel/bin/pureauth') )[7] != ( stat($pureauth) )[7]
            || ( stat('/usr/local/cpanel/bin/pureauth') )[9] > ( stat($pureauth) )[9] )
      ) {
        system( 'cp', '-fv', '/usr/local/cpanel/bin/pureauth', $pureauth );
        chmod( 0700, $pureauth );
    }

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

    if ( $manualstart != 1 ) {
        nooutputsystem( $iscript, 'stop' );
        doomedprocess('proftpd');
        doomedprocess('pure-ftpd');
        doomedprocess('pure-authd');
        if ( $restart != -1 ) {
            system( $iscript, 'start' );
            if ( $servicebin =~ m/pure/i && $system =~ m/freebsd/i ) {
                nooutputsystem( '/usr/local/sbin/pure-authd', '-B', '-s', '/var/run/ftpd.sock', '-r', $pureauth );
            }
        }
    }
    else {
        doomedprocess('proftpd');
        doomedprocess('pure-ftpd');
        doomedprocess('pure-authd');
        if ( $restart != -1 ) {
            print "Starting manually\n";
            nooutputsystem( $servicebin, $serviceflags );
            if ( $servicebin =~ /pure/i && $system =~ /freebsd/i ) {
                nooutputsystem( '/usr/local/sbin/pure-authd', '-B', '-s', '/var/run/ftpd.sock', '-r', $pureauth );
            }
        }
    }

    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 );
        if ( $service =~ m/pure/ ) {
            print check_service( 'service' => 'pure-authd', 'user' => 'root' );
        }

    }
}
elsif ($check) {
    exit if ($disabled);
    if ( check_service( 'service' => $service, 'user' => $processowner ) eq '' ) {
        print "$service is not running\n";
    }
    if ( $service =~ m/pure/ ) {
        if ( check_service( 'service' => 'pure-authd', 'user' => 'root' ) eq '' ) {
            print "pure-authd is not running\n";
        }
    }
}