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: //proc/self/root/scripts.20110531.215904.25158/restartsrv_httpd
#!/usr/bin/perl
# cpanel - restartsrv_httpd                       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 RestartSrv;
use Cpanel::OSSys ();

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, $verbose ) = parseargv();

my $iscript      = '';
my $service      = 'httpd';
my $processowner = '';
my $disabled     = ( -e '/etc/httpddisable' || -e '/etc/apachedisable' || -e '/etc/httpdisable' ) ? 1 : 0;

( $processowner, $service ) = servicefixup( $system, $service );

system '/scripts/ensure_conf_dir_crt_key';

if ( $restart && !$disabled ) {
    if ( -e '/var/cpanel/mgmt_queue/apache_update_no_restart' ) {
        print "Apache build currently in progress. Restarts disabled by existence of /var/cpanel/mgmt_queue/apache_update_no_restart. Restarting Apache now may result in a broken Apache build.\n";
        exit;
    }

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

    $iscript = getinitfile( $service, $system );

    #--restart or nothing (restart service)
    if ($iscript) {
        if ($verbose) {
            print "Init script $iscript located.\n";
            system( $iscript, 'stop' );
        }
        else {
            nooutputsystem( $iscript, 'stop' );
        }
        doomedprocess( $service, $verbose );

        cleanup();

        if ( $restart != -1 ) {
            system $iscript, 'start';
        }
    }
    else {
        if ($verbose) {
            print "Init script /usr/local/apache/bin/apachectl located.\n";
        }

        doomedprocess( $service, $verbose );

        cleanup();

        if ( $restart != -1 ) {
            system '/usr/local/apache/bin/apachectl', 'startssl';
        }
    }

    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 );
    }
}
elsif ($check) {
    exit if ($disabled);
    if ( check_service( 'service' => $service, 'user' => $processowner ) eq '' ) {
        print "$service is not running\n";
    }
}

sub cleanup {

    # Clean up
    if ( -e '/usr/local/apache/logs/httpd.scoreboard' ) {
        unlink '/usr/local/apache/logs/httpd.scoreboard' or warn "Unable to remove: $!";
    }
    if ( -e '/usr/local/apache/logs/httpd.pid' ) {
        unlink '/usr/local/apache/logs/httpd.pid' or warn "Unable to remove: $!";
    }
    if ( -e '/usr/local/apache/logs/rewrite_lock' ) {
        unlink '/usr/local/apache/logs/rewrite_lock' or warn "Unable to remove: $!";
    }
}