MOON
Server: Apache
System: Linux vps.thepromohut.com 2.6.18-398.el5 #1 SMP Tue Sep 16 20:51:48 EDT 2014 i686
User: caretrak (507)
PHP: 5.2.10
Disabled: NONE
Upload Files
File: //scripts.20110601.041516.15411/restartsrv_postgresql
#!/usr/bin/perl
# cpanel - restartsrv_postgresql                  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;

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

setuppath();

$| = 1;

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

my $iscript        = '';
my $initdir        = '';
my $service        = 'postgresql';
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 $lock_file = '/var/run/restartsrv_postgresql.lock';
    lock_file($lock_file);

    if ( $manualstart != 1 ) {
        nooutputsystem( $iscript, 'stop' );
        doomedprocess($service);
        my ( $pgctl, $pgsqldir ) = postgresqlfixup($system);
        if ( -e "$pgsqldir/postmaster.pid" ) {
            unlink("$pgsqldir/postmaster.pid");
        }
        if ( $restart != -1 ) {
            system( $iscript, 'start' );
        }
    }
    else {
        my ( $pgctl, $pgsqldir ) = postgresqlfixup($system);
        runasuser( $processowner, ( $pgctl, '-D', $pgsqldir, 'stop' ) );
        doomedprocess($service);
        if ( -e "${pgsqldir}/postmaster.pid" ) {
            unlink("${pgsqldir}/postmaster.pid");
        }
        if ( $restart != -1 ) {
            runasuser( $processowner, ( $pgctl, '-D', $pgsqldir, '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 );
    }
}
elsif ($check) {
    exit if ($disabled);
    if ( check_service( 'service' => $service, 'user' => $processowner ) eq '' ) {
        print "$service is not running\n";
    }
}