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/checkfcgid
#!/usr/bin/perl
# cpanel - checkfcgid                             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'; }

use Cpanel::SafeFile  ();
use Cpanel::HttpUtils ();
use Cpanel::Logger    ();

my $logger = Cpanel::Logger->new();

my $apache_base = '/usr/local/apache';
my $modules_dir = $apache_base . '/modules';
my $httpdconf   = $apache_base . '/conf/httpd.conf';
my $restart     = @ARGV && grep( /^--no-restart$/, @ARGV ) ? 0 : 1;
my $verbose     = @ARGV && grep( /^--verbose$/, @ARGV ) ? 1 : 0;

if ( !-e $modules_dir . '/mod_fcgid.so' ) {
    print "The current apache does not have FCGID support\n";
    exit 1;
}

my $has_load_module;
my $needs_update;

my $last_load_module;
my $last_add_module;

my $hlock = Cpanel::SafeFile::safeopen( \*HTTPC, '+<', $httpdconf );
if ( !$hlock ) {
    $logger->die("Could not edit $httpdconf");
}
my $line_count = 1;
my @httpdconf;
while ( my $line = <HTTPC> ) {
    if ( $line =~ m/^\s*LoadModule\s+(.+)\s*(?:$|#)/ ) {
        my $load_module = $1;
        $load_module =~ s/(?:^\s+|\s+$)//g;
        if ( $load_module =~ m/^fcgid_module\s+modules\/mod_fcgid\.so$/ ) {
            $has_load_module = 1;
            $line_count++;
            push @httpdconf, $line;
        }
        else {
            $line_count++;
            push @httpdconf, $line;
            $last_load_module = $line_count;
        }
    }
    else {
        $line_count++;
        push @httpdconf, $line;
    }
}

if ( !$needs_update && $has_load_module && !$has_add_module ) {
    Cpanel::SafeFile::safeclose( \*HTTPC, $hlock );
    exit;
}

print "Updating Apache configuration\n";

seek( HTTPC, 0, 0 );

my $new_line_count = 0;
foreach my $line (@httpdconf) {
    $new_line_count++;
    if ( $new_line_count == $last_load_module ) {
        print HTTPC "LoadModule fcgid_module modules/mod_fcgid.so\n";
    }
    else {
        print HTTPC $line;
    }
}

truncate( HTTPC, tell(HTTPC) );

Cpanel::SafeFile::safeclose( \*HTTPC, $hlock );

if ($restart) {
    Cpanel::HttpUtils::safeaprestart();
}

exit;