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/proc/self/root/scripts.20110531.215904.25158/restartsrv_nsd
#!/usr/bin/perl
# cpanel - restartsrv_nsd                         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                  ();
use Cpanel::CleanupStub            ();
use Cpanel::NameServer::Utils::NSD ();
use Cpanel::NameServer::Conf       ();
use Cpanel::OSSys                  ();

unless ( -e '/var/cpanel/usensd' ) {
    exec '/scripts/restartsrv_named', @ARGV;
}

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

my $iscript        = '';
my $initdir        = '';
my $service        = 'nsd';
my $processowner   = 'root';
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_nsd.lock';
    lock_file($lock_file);

    if ( $restart != -1 ) {
        my $nameserverconf_obj = new Cpanel::NameServer::Conf;

        Cpanel::NameServer::Utils::NSD::setup_nsd_dirs($nameserverconf_obj);
        Cpanel::NameServer::Utils::NSD::update_nsd_conf_ips();

        my ( $exit_code, $output ) = Cpanel::NameServer::Utils::NSD::rebuild_zonedb($nameserverconf_obj);
        $nameserverconf_obj->finish();
        if ($exit_code) {
            print $output;
            print "Failed to start NSD\n";
            unlink $lock_file if -e $lock_file;
            exit $exit_code;
        }
    }

    my ( $nsd_conf, $nsd_conf_dir ) = Cpanel::NameServer::Utils::NSD::get_nsd_conf_and_dir();

    my $nsd_bin = Cpanel::NameServer::Utils::NSD::find_nsd();

    if ( !$nsd_bin ) {
        unlink $lock_file if -e $lock_file;
        die "nsd is not installed";
    }

    Cpanel::NameServer::Utils::NSD::nsd_command('stop');
    doomedprocess('named');    #jic
    doomedprocess('nsd');      #jic

    if ( $restart != -1 ) {

        if ( my $pid = fork() ) {
            waitpid( $pid, 0 );
        }
        else {
            Cpanel::OSSys::setsid();
            Cpanel::CleanupStub::daemonclosefds();
            exec $nsd_bin, '-c', $nsd_conf;
            print "Failed to start NSD\n";
            exit 1;
        }
    }
    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";
    }
}