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_ipaliases
#!/usr/bin/perl
# cpanel - restartsrv_ipaliases                   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::Ips ();

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

setuppath();

my ( $restart, $check, $status ) = parseargv();

my $processowner = 'root';
my $service      = 'ipaliases';

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

my $disabled = 0;
if ( -e '/etc/ipaliasesdisable' ) {
    $disabled = 1;
}

if ( $restart && !$disabled ) {

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

    if ( $restart != -1 ) {
        nooutputsystem( '/etc/init.d/ipaliases', 'start');
    }
    else {
        nooutputsystem( '/etc/init.d/ipaliases', 'stop');
    }

    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);

    my $current_ips_ref = Cpanel::Ips::fetchipslist();
    my $configured_ips_ref = Cpanel::Ips::load_configured_ips();

    my $number_current_ips = (scalar keys %{$current_ips_ref});
    my $number_configured_ips = (scalar keys %{$configured_ips_ref});

    if ($number_configured_ips && $number_current_ips / $number_configured_ips < 0.75 ) {
        print "$service has missing ips\n";
        exit 1;
    }

    exit 0;
}