replace service stuff with newly added subrotines in xCAT::Utils
This commit is contained in:
		@@ -1881,7 +1881,9 @@ sub get_image_name
 | 
			
		||||
    Example:
 | 
			
		||||
         if (xCAT::Utils->startService("named") { ...}
 | 
			
		||||
    Comments:
 | 
			
		||||
        none
 | 
			
		||||
         this subroutine is deprecated,
 | 
			
		||||
         will be used as an internal function to process AIX service,
 | 
			
		||||
         for linux, use xCAT::Utils->startservice instead
 | 
			
		||||
 | 
			
		||||
=cut
 | 
			
		||||
 | 
			
		||||
@@ -3586,7 +3588,7 @@ sub servicemap{
 | 
			
		||||
  # }
 | 
			
		||||
  my %svchash=(
 | 
			
		||||
     "dhcp" => {
 | 
			
		||||
                 0=>["dhcpd","isc-dhcp-server"],
 | 
			
		||||
                 0=>["dhcp3-server","dhcpd","isc-dhcp-server"],
 | 
			
		||||
                 1=>["dhcpd.service"],
 | 
			
		||||
               },
 | 
			
		||||
     "nfs" =>  {
 | 
			
		||||
 
 | 
			
		||||
@@ -66,12 +66,14 @@ sub start {
 | 
			
		||||
    my $mychildren_cfg="/etc/nagios/objects/mychildren.cfg";
 | 
			
		||||
    if ($isSN) { #start nagios daemon only when mychildren exists on the sn
 | 
			
		||||
	if (-f $mychildren_cfg) {
 | 
			
		||||
	    my $rc=`service nagios restart 2>&1`;
 | 
			
		||||
	    #my $rc=`service nagios restart 2>&1`;
 | 
			
		||||
	    my $rc=xCAT::Utils->restartservice("nagios");
 | 
			
		||||
	    reportError("$localhostname: $rc", $callback);
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
    else { #always start nagios daemon on mn
 | 
			
		||||
	my $rc=`service nagios restart 2>&1`;
 | 
			
		||||
	#my $rc=`service nagios restart 2>&1`;
 | 
			
		||||
	my $rc=xCAT::Utils->restartservice("nagios");
 | 
			
		||||
	reportError("$localhostname: $rc", $callback);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
@@ -122,7 +122,8 @@ sub start_RRD_server
 | 
			
		||||
		print FILE "\tserver_args = - /var/rrd\n";
 | 
			
		||||
		print FILE "}\n";
 | 
			
		||||
		close FILE;
 | 
			
		||||
		xCAT::Utils->runcmd("service xinetd restart", 0);
 | 
			
		||||
		#xCAT::Utils->runcmd("service xinetd restart", 0);
 | 
			
		||||
		xCAT::Utils->restartservice("xinetd");
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -188,7 +189,8 @@ sub stop_RRD_server
 | 
			
		||||
		} else {
 | 
			
		||||
			xCAT::Utils->runcmd("rm -f /etc/xinetd.d/rrdsrv", 0);
 | 
			
		||||
		}
 | 
			
		||||
		xCAT::Utils->runcmd("service xinetd restart", 0);
 | 
			
		||||
		#xCAT::Utils->runcmd("service xinetd restart", 0);
 | 
			
		||||
		xCAT::Utils->restartservice("xinetd");
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -509,8 +509,13 @@ sub setup_CONS
 | 
			
		||||
          "conserver cannot be started because the file $ca_file2 cannot be found\n";
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        my $rc = xCAT::Utils->startService("conserver");
 | 
			
		||||
    {  
 | 
			
		||||
        if (xCAT::Utils->isAIX()){
 | 
			
		||||
           $rc=xCAT::Utils->startService("conserver");  
 | 
			
		||||
        }elsif(xCAT::Utils->isLinux()){
 | 
			
		||||
        #my $rc = xCAT::Utils->startService("conserver");
 | 
			
		||||
           $rc=xCAT::Utils->startservice("conserver");
 | 
			
		||||
        }
 | 
			
		||||
        if ($rc != 0)
 | 
			
		||||
        {
 | 
			
		||||
            return 1;
 | 
			
		||||
@@ -537,9 +542,11 @@ sub setup_DHCP
 | 
			
		||||
    my $snonly = 0;
 | 
			
		||||
    # if on the MN check to see if dhcpd is running, and start it if not.
 | 
			
		||||
    if (xCAT::Utils->isMN()) { # on the MN
 | 
			
		||||
        my @output = xCAT::Utils->runcmd("service dhcpd status", -1);
 | 
			
		||||
        if ($::RUNCMD_RC != 0)  { # not running
 | 
			
		||||
          $rc = xCAT::Utils->startService("dhcpd");
 | 
			
		||||
        #my @output = xCAT::Utils->runcmd("service dhcpd status", -1);
 | 
			
		||||
        #if ($::RUNCMD_RC != 0)  { # not running
 | 
			
		||||
        my $retcode= xCAT::Utils->checkservicestatus("dhcpd");
 | 
			
		||||
        if($retcode!=0){
 | 
			
		||||
          $rc = xCAT::Utils->startservice("dhcpd");
 | 
			
		||||
          if ($rc != 0)
 | 
			
		||||
          {
 | 
			
		||||
            return 1;
 | 
			
		||||
@@ -573,12 +580,18 @@ sub setup_DHCP
 | 
			
		||||
      ->($cmdref, \&xCAT::Client::handle_response);
 | 
			
		||||
 | 
			
		||||
    my $distro = xCAT::Utils->osver();
 | 
			
		||||
    my $serv = "dhcpd";
 | 
			
		||||
    if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
 | 
			
		||||
        $serv = "isc-dhcp-server";	
 | 
			
		||||
    }
 | 
			
		||||
    #my $serv = "dhcpd";
 | 
			
		||||
    #if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
 | 
			
		||||
    #    $serv = "isc-dhcp-server";	
 | 
			
		||||
    #}
 | 
			
		||||
 | 
			
		||||
    my $rc = xCAT::Utils->startService($serv);
 | 
			
		||||
    #my $rc = xCAT::Utils->startService($serv);
 | 
			
		||||
    my $rc=0;
 | 
			
		||||
    if(xCAT::Utils->isAIX()){
 | 
			
		||||
       $rc = xCAT::Utils->startService("dhcpd");
 | 
			
		||||
    } elsif(xCAT::Utils->isLinux()){
 | 
			
		||||
       $rc = xCAT::Utils->startservice("dhcp");
 | 
			
		||||
    }
 | 
			
		||||
    if ($rc != 0)
 | 
			
		||||
    {
 | 
			
		||||
        return 1;
 | 
			
		||||
@@ -672,7 +685,13 @@ sub setup_FTP
 | 
			
		||||
 | 
			
		||||
    # start ftp
 | 
			
		||||
 | 
			
		||||
    my $rc = xCAT::Utils->startService("vsftpd");
 | 
			
		||||
    #my $rc = xCAT::Utils->startService("vsftpd");
 | 
			
		||||
    my $rc = 0;
 | 
			
		||||
    if(xCAT::Utils->isAIX()){
 | 
			
		||||
       $rc = xCAT::Utils->startService("vsftpd");
 | 
			
		||||
    }elsif(xCAT::Utils->isLinux()){
 | 
			
		||||
       $rc = xCAT::Utils->startservice("vsftpd");
 | 
			
		||||
    }
 | 
			
		||||
    if ($rc != 0)
 | 
			
		||||
    {
 | 
			
		||||
        return 1;
 | 
			
		||||
@@ -723,12 +742,19 @@ sub setup_DNS
 | 
			
		||||
    # turn DNS on
 | 
			
		||||
 | 
			
		||||
    my $distro = xCAT::Utils->osver();
 | 
			
		||||
    my $serv = "named";
 | 
			
		||||
    if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
 | 
			
		||||
        $serv = "bind9";
 | 
			
		||||
    #my $serv = "named";
 | 
			
		||||
    #if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
 | 
			
		||||
    #    $serv = "bind9";
 | 
			
		||||
    #}
 | 
			
		||||
 | 
			
		||||
    #my $rc = xCAT::Utils->startService($serv);
 | 
			
		||||
    my $rc = 0;
 | 
			
		||||
    if(xCAT::Utils->isAIX()){
 | 
			
		||||
       $rc = xCAT::Utils->startService("named"); 
 | 
			
		||||
    }elsif(xCAT::Utils->isLinux()){
 | 
			
		||||
       $rc=xCAT::Utils->startservice("named");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    my $rc = xCAT::Utils->startService($serv);
 | 
			
		||||
    if ($rc != 0)
 | 
			
		||||
    {
 | 
			
		||||
        return 1;
 | 
			
		||||
@@ -751,15 +777,17 @@ sub setup_DNS
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        #chkconfig
 | 
			
		||||
        my $cmd = "/sbin/chkconfig $serv on";
 | 
			
		||||
        my $outref = xCAT::Utils->runcmd("$cmd", 0);
 | 
			
		||||
        if ($::RUNCMD_RC != 0)
 | 
			
		||||
        #my $cmd = "/sbin/chkconfig $serv on";
 | 
			
		||||
        #my $outref = xCAT::Utils->runcmd("$cmd", 0);
 | 
			
		||||
        #if ($::RUNCMD_RC != 0)
 | 
			
		||||
        my $retcode=xCAT::Utils->enableservice("named");
 | 
			
		||||
        if($retcode!=0)
 | 
			
		||||
        {
 | 
			
		||||
            xCAT::MsgUtils->message("SE", " Error: Could not enable $serv.");
 | 
			
		||||
            xCAT::MsgUtils->message("SE", " Error: Could not enable dns server.");
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            xCAT::MsgUtils->message("SI", " $serv has been enabled on boot.");
 | 
			
		||||
            xCAT::MsgUtils->message("SI", " dns server has been enabled on boot.");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -778,7 +806,14 @@ sub setup_DNS
 | 
			
		||||
sub setup_LDAP
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    my $rc = xCAT::Utils->startService("ldap");
 | 
			
		||||
    #my $rc = xCAT::Utils->startService("ldap");
 | 
			
		||||
    my $rc = 0;
 | 
			
		||||
 
 | 
			
		||||
    if(xCAT::Utils->isAIX()){
 | 
			
		||||
       $rc = xCAT::Utils->startService("ldap");
 | 
			
		||||
    }elsif(xCAT::Utils->isLinux()){
 | 
			
		||||
       $rc=xCAT::Utils->startservice("ldap");
 | 
			
		||||
    }
 | 
			
		||||
    if ($rc != 0)
 | 
			
		||||
    {
 | 
			
		||||
        return 1;
 | 
			
		||||
@@ -805,16 +840,17 @@ sub setup_NFS
 | 
			
		||||
    my $rc = 0;
 | 
			
		||||
    if (xCAT::Utils->isLinux())
 | 
			
		||||
    {
 | 
			
		||||
        my $os = xCAT::Utils->osver();
 | 
			
		||||
        if ($os =~ /sles.*/)
 | 
			
		||||
        {
 | 
			
		||||
            $rc = xCAT::Utils->startService("nfs");
 | 
			
		||||
            $rc = xCAT::Utils->startService("nfsserver");
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            $rc = xCAT::Utils->startService("nfs");
 | 
			
		||||
        }
 | 
			
		||||
        #my $os = xCAT::Utils->osver();
 | 
			
		||||
        #if ($os =~ /sles.*/)
 | 
			
		||||
        #{
 | 
			
		||||
        #    $rc = xCAT::Utils->startService("nfs");
 | 
			
		||||
        #    $rc = xCAT::Utils->startService("nfsserver");
 | 
			
		||||
        #}
 | 
			
		||||
        #else
 | 
			
		||||
        #{
 | 
			
		||||
        #    $rc = xCAT::Utils->startService("nfs");
 | 
			
		||||
        #}
 | 
			
		||||
        $rc = xCAT::Utils->startservice("nfs");
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {    #AIX
 | 
			
		||||
@@ -944,7 +980,14 @@ sub setup_NTPmn
 | 
			
		||||
sub start_NTP
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    my $rc = xCAT::Utils->startService("ntpd");
 | 
			
		||||
    my $rc =0;
 | 
			
		||||
    if (xCAT::Utils->isAIX()){
 | 
			
		||||
        $rc=xCAT::Utils->startService("ntpd");  
 | 
			
		||||
    }elsif(xCAT::Utils->isLinux()){
 | 
			
		||||
        #my $rc = xCAT::Utils->startService("conserver");
 | 
			
		||||
        $rc=xCAT::Utils->startservice("ntpd");
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if ($rc != 0)
 | 
			
		||||
    {
 | 
			
		||||
        return 1;
 | 
			
		||||
@@ -1271,15 +1314,16 @@ sub setup_HTTP
 | 
			
		||||
 | 
			
		||||
    if (xCAT::Utils->isLinux())
 | 
			
		||||
    {
 | 
			
		||||
        my $os = xCAT::Utils->osver();
 | 
			
		||||
        if ($os =~ /sles.*/)
 | 
			
		||||
        {
 | 
			
		||||
            $rc = xCAT::Utils->startService("apache2");
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            $rc = xCAT::Utils->startService("httpd");
 | 
			
		||||
        }
 | 
			
		||||
        #my $os = xCAT::Utils->osver();
 | 
			
		||||
        #if ($os =~ /sles.*/)
 | 
			
		||||
        #{
 | 
			
		||||
        #    $rc = xCAT::Utils->startService("apache2");
 | 
			
		||||
        #}
 | 
			
		||||
        #else
 | 
			
		||||
        #{
 | 
			
		||||
        #    $rc = xCAT::Utils->startService("httpd");
 | 
			
		||||
        #}
 | 
			
		||||
        $rc=xCAT::Utils->startservice("http");
 | 
			
		||||
    }
 | 
			
		||||
    return $rc;
 | 
			
		||||
}
 | 
			
		||||
@@ -1385,24 +1429,33 @@ sub enable_TFTPhpa
 | 
			
		||||
      }
 | 
			
		||||
      print FILE @newcfgfile;
 | 
			
		||||
      close (FILE);
 | 
			
		||||
      my @output = xCAT::Utils->runcmd("service xinetd status", -1);
 | 
			
		||||
      if ($::RUNCMD_RC == 0) {
 | 
			
		||||
        if (grep(/running/, @output))
 | 
			
		||||
        {
 | 
			
		||||
          print ' ';              # indent service output to separate it from the xcatd service output
 | 
			
		||||
          system "service xinetd stop";
 | 
			
		||||
          if ($? > 0)
 | 
			
		||||
          {    # error
 | 
			
		||||
      #my @output = xCAT::Utils->runcmd("service xinetd status", -1);
 | 
			
		||||
      #if ($::RUNCMD_RC == 0) {}
 | 
			
		||||
      my $retcode=xCAT::Utils->checkservicestatus("xinetd");
 | 
			
		||||
      if($retcode==0){
 | 
			
		||||
        my $retcode=xCAT::Utils->restartservice("xinetd");
 | 
			
		||||
        if($retcode !=0 )
 | 
			
		||||
          {
 | 
			
		||||
              xCAT::MsgUtils->message("S",
 | 
			
		||||
                                        "Error on command: service xinetd stop\n");
 | 
			
		||||
                                        "Error on restart xinetd\n");
 | 
			
		||||
    
 | 
			
		||||
          }
 | 
			
		||||
          system "service xinetd start";
 | 
			
		||||
          if ($? > 0)
 | 
			
		||||
          {    # error
 | 
			
		||||
              xCAT::MsgUtils->message("S",
 | 
			
		||||
                                        "Error on command: service xinetd start\n");
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        #if (grep(/running/, @output))
 | 
			
		||||
        #{
 | 
			
		||||
        #  print ' ';              # indent service output to separate it from the xcatd service output
 | 
			
		||||
        #  system "service xinetd stop";
 | 
			
		||||
        #  if ($? > 0)
 | 
			
		||||
        #  {    # error
 | 
			
		||||
        #      xCAT::MsgUtils->message("S",
 | 
			
		||||
        #                                "Error on command: service xinetd stop\n");
 | 
			
		||||
        #  }
 | 
			
		||||
        #  system "service xinetd start";
 | 
			
		||||
        #  if ($? > 0)
 | 
			
		||||
        #  {    # error
 | 
			
		||||
        #      xCAT::MsgUtils->message("S",
 | 
			
		||||
        #                                "Error on command: service xinetd start\n");
 | 
			
		||||
        #  }
 | 
			
		||||
        #}
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@@ -1449,7 +1502,8 @@ sub enable_TFTPhpa
 | 
			
		||||
        sleep 1;
 | 
			
		||||
        my @checkproc=`ps axf|grep -v grep|grep in.tftpd`;
 | 
			
		||||
        if (@checkproc){
 | 
			
		||||
            system("service tftpd-hpa stop");
 | 
			
		||||
            #system("service tftpd-hpa stop");
 | 
			
		||||
            xCAT::Utils->stopservice("tftpd-hpa");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    my @tftpprocs=`ps axf|grep -v grep|grep in.tftpd`;
 | 
			
		||||
 
 | 
			
		||||
@@ -2000,9 +2000,11 @@ sub mksysclone
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    # check systemimager-server-rsyncd to make sure it's running.
 | 
			
		||||
    my $out = xCAT::Utils->runcmd("service systemimager-server-rsyncd status", -1);
 | 
			
		||||
     if ($::RUNCMD_RC != 0)  { # not running
 | 
			
		||||
         my $rc = xCAT::Utils->startService("systemimager-server-rsyncd");
 | 
			
		||||
    #my $out = xCAT::Utils->runcmd("service systemimager-server-rsyncd status", -1);
 | 
			
		||||
    # if ($::RUNCMD_RC != 0)  { # not running
 | 
			
		||||
    my $retcode=xCAT::Utils->checkservicestatus("systemimager-server-rsyncd");
 | 
			
		||||
    if($retcode!=0){
 | 
			
		||||
         my $rc = xCAT::Utils->startservice("systemimager-server-rsyncd");
 | 
			
		||||
         if ($rc != 0) {
 | 
			
		||||
            return 1;
 | 
			
		||||
         }
 | 
			
		||||
 
 | 
			
		||||
@@ -571,7 +571,8 @@ sub process_request {
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    system("service $service stop"); #named may otherwise hold on to stale journal filehandles
 | 
			
		||||
                    #system("service $service stop"); #named may otherwise hold on to stale journal filehandles
 | 
			
		||||
                    xCAT::Utils->stopservice("named");
 | 
			
		||||
                }
 | 
			
		||||
                my $conf = get_conf();
 | 
			
		||||
                unlink $conf;
 | 
			
		||||
@@ -614,24 +615,31 @@ sub process_request {
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        my $cmd = "service $service stop";
 | 
			
		||||
                        my @output=xCAT::Utils->runcmd($cmd, 0);
 | 
			
		||||
                        my $outp = join('', @output);
 | 
			
		||||
                        if ($::RUNCMD_RC != 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            my $rsp = {};
 | 
			
		||||
                            $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
 | 
			
		||||
                            xCAT::MsgUtils->message("E", $rsp, $callback);
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        #my $cmd = "service $service stop";
 | 
			
		||||
                        #my @output=xCAT::Utils->runcmd($cmd, 0);
 | 
			
		||||
                        #my $outp = join('', @output);
 | 
			
		||||
                        #if ($::RUNCMD_RC != 0)
 | 
			
		||||
                        #{
 | 
			
		||||
                        #    my $rsp = {};
 | 
			
		||||
                        #    $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
 | 
			
		||||
                        #    xCAT::MsgUtils->message("E", $rsp, $callback);
 | 
			
		||||
                        #    return;
 | 
			
		||||
                        #}
 | 
			
		||||
    
 | 
			
		||||
                        $cmd = "service $service start";
 | 
			
		||||
                        @output=xCAT::Utils->runcmd($cmd, 0);
 | 
			
		||||
                        $outp = join('', @output);
 | 
			
		||||
                        if ($::RUNCMD_RC != 0)
 | 
			
		||||
                        {
 | 
			
		||||
                        #$cmd = "service $service start";
 | 
			
		||||
                        #@output=xCAT::Utils->runcmd($cmd, 0);
 | 
			
		||||
                        #$outp = join('', @output);
 | 
			
		||||
                        #if ($::RUNCMD_RC != 0)
 | 
			
		||||
                        #{
 | 
			
		||||
                        #    my $rsp = {};
 | 
			
		||||
                        #    $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
 | 
			
		||||
                        #    xCAT::MsgUtils->message("E", $rsp, $callback);
 | 
			
		||||
                        #    return;
 | 
			
		||||
                        #}
 | 
			
		||||
                        my $retcode=xCAT::Utils->restartservice("named");
 | 
			
		||||
                        if($retcode!=0){
 | 
			
		||||
                            my $rsp = {};
 | 
			
		||||
                            $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
 | 
			
		||||
                            $rsp->{data}->[0] = "failed to start named.\n";
 | 
			
		||||
                            xCAT::MsgUtils->message("E", $rsp, $callback);
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
@@ -673,20 +681,29 @@ sub process_request {
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            my $cmd = "service $service status|grep running";
 | 
			
		||||
            my @output=xCAT::Utils->runcmd($cmd, 0);
 | 
			
		||||
            if ($::RUNCMD_RC != 0)
 | 
			
		||||
            #my $cmd = "service $service status|grep running";
 | 
			
		||||
            #my @output=xCAT::Utils->runcmd($cmd, 0);
 | 
			
		||||
            #if ($::RUNCMD_RC != 0)
 | 
			
		||||
            #{
 | 
			
		||||
            #    $cmd = "service $service start";
 | 
			
		||||
            #    @output=xCAT::Utils->runcmd($cmd, 0);
 | 
			
		||||
            #    my $outp = join('', @output);
 | 
			
		||||
            #    if ($::RUNCMD_RC != 0)
 | 
			
		||||
            #    {
 | 
			
		||||
            #        my $rsp = {};
 | 
			
		||||
            #        $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
 | 
			
		||||
            #        xCAT::MsgUtils->message("E", $rsp, $callback);
 | 
			
		||||
            #        return;
 | 
			
		||||
            #    }
 | 
			
		||||
            #}
 | 
			
		||||
            my $retcode=xCAT::Utils->startservice("named");
 | 
			
		||||
            if($retcode!=0)
 | 
			
		||||
            {
 | 
			
		||||
                $cmd = "service $service start";
 | 
			
		||||
                @output=xCAT::Utils->runcmd($cmd, 0);
 | 
			
		||||
                my $outp = join('', @output);
 | 
			
		||||
                if ($::RUNCMD_RC != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    my $rsp = {};
 | 
			
		||||
                    $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
 | 
			
		||||
                    $rsp->{data}->[0] = "failed to start named.\n";
 | 
			
		||||
                    xCAT::MsgUtils->message("E", $rsp, $callback);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -884,15 +884,19 @@ sub check_options
 | 
			
		||||
    # if not help and not -n,  dhcpd needs to be running
 | 
			
		||||
    if (!($opt->{h})&& (!($opt->{n}))) {
 | 
			
		||||
     if (xCAT::Utils->isLinux()) {
 | 
			
		||||
       my $DHCPSERVER="dhcpd";
 | 
			
		||||
       if( -e "/etc/init.d/isc-dhcp-server" ){
 | 
			
		||||
              $DHCPSERVER="isc-dhcp-server";
 | 
			
		||||
       } 
 | 
			
		||||
       #my $DHCPSERVER="dhcpd";
 | 
			
		||||
       #if( -e "/etc/init.d/isc-dhcp-server" ){
 | 
			
		||||
       #       $DHCPSERVER="isc-dhcp-server";
 | 
			
		||||
       #} 
 | 
			
		||||
 | 
			
		||||
       my @output = xCAT::Utils->runcmd("service $DHCPSERVER status", -1);
 | 
			
		||||
       if ($::RUNCMD_RC != 0)  { # not running
 | 
			
		||||
       #my @output = xCAT::Utils->runcmd("service $DHCPSERVER status", -1);
 | 
			
		||||
       #if ($::RUNCMD_RC != 0)  { # not running
 | 
			
		||||
       my $ret=0;
 | 
			
		||||
       $ret=xCAT::Utils->checkservicestatus("dhcp");
 | 
			
		||||
       if($ret!=0)
 | 
			
		||||
       {
 | 
			
		||||
          my $rsp = {};
 | 
			
		||||
          $rsp->{data}->[0] = "$DHCPSERVER is not running.  Run service $DHCPSERVER start and rerun your command.";
 | 
			
		||||
          $rsp->{data}->[0] = "dhcp server is not running.  please start the dhcp server.";
 | 
			
		||||
          xCAT::MsgUtils->message("E", $rsp, $callback, 1);
 | 
			
		||||
          return 1;
 | 
			
		||||
       }
 | 
			
		||||
@@ -1840,25 +1844,29 @@ sub process_request
 | 
			
		||||
        {
 | 
			
		||||
            restart_dhcpd_aix();
 | 
			
		||||
        }
 | 
			
		||||
        elsif ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i)
 | 
			
		||||
        {
 | 
			
		||||
            if (-e '/etc/dhcp/dhcpd.conf') {
 | 
			
		||||
                system("chmod a+r /etc/dhcp/dhcpd.conf");
 | 
			
		||||
                system("/etc/init.d/isc-dhcp-server restart");
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                #ubuntu config
 | 
			
		||||
                system("chmod a+r /etc/dhcp3/dhcpd.conf");
 | 
			
		||||
                system("/etc/init.d/dhcp3-server restart");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            system("/etc/init.d/dhcpd restart");
 | 
			
		||||
            # should not chkconfig dhcpd on every makedhcp invoation
 | 
			
		||||
            # it is not appropriate and will cause problem for HAMN
 | 
			
		||||
            # do it in xcatconfig instead
 | 
			
		||||
            #system("chkconfig dhcpd on");
 | 
			
		||||
        else {
 | 
			
		||||
            if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i)
 | 
			
		||||
		{
 | 
			
		||||
		    if (-e '/etc/dhcp/dhcpd.conf') {
 | 
			
		||||
			system("chmod a+r /etc/dhcp/dhcpd.conf");
 | 
			
		||||
			#system("/etc/init.d/isc-dhcp-server restart");
 | 
			
		||||
		    }
 | 
			
		||||
		    else {
 | 
			
		||||
			#ubuntu config
 | 
			
		||||
			system("chmod a+r /etc/dhcp3/dhcpd.conf");
 | 
			
		||||
			#system("/etc/init.d/dhcp3-server restart");
 | 
			
		||||
		    }
 | 
			
		||||
		}
 | 
			
		||||
		#else
 | 
			
		||||
		#{
 | 
			
		||||
		#    system("/etc/init.d/dhcpd restart");
 | 
			
		||||
		#    # should not chkconfig dhcpd on every makedhcp invoation
 | 
			
		||||
		#    # it is not appropriate and will cause problem for HAMN
 | 
			
		||||
		#    # do it in xcatconfig instead
 | 
			
		||||
		#    #system("chkconfig dhcpd on");
 | 
			
		||||
		#}
 | 
			
		||||
            xCAT::Utils->restartservice("dhcp");
 | 
			
		||||
        print "xx";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    flock($dhcplockfd,LOCK_UN);
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,7 @@ Getopt::Long::Configure("pass_through");
 | 
			
		||||
use xCAT::Table;
 | 
			
		||||
use xCAT::MsgUtils;
 | 
			
		||||
use xCAT::DBobjUtils;
 | 
			
		||||
use xCAT::Utils;
 | 
			
		||||
 | 
			
		||||
sub handled_commands {
 | 
			
		||||
    return {
 | 
			
		||||
@@ -376,7 +377,9 @@ sub update_export {
 | 
			
		||||
    for my $l  (@new_export) { print $new_export_fd $l; }
 | 
			
		||||
    flock($new_export_fd,LOCK_UN);
 | 
			
		||||
    close($new_export_fd);
 | 
			
		||||
    system("service nfs restart");
 | 
			
		||||
    #system("service nfs restart");
 | 
			
		||||
    my $retcode=xCAT::Utils->restartservice("nfs");
 | 
			
		||||
    return $retcode;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub update_syslog {
 | 
			
		||||
@@ -391,7 +394,9 @@ sub update_syslog {
 | 
			
		||||
        open($new_syslog_fd, ">>", "/etc/exports");
 | 
			
		||||
        print $new_syslog_fd "local2.* /var/log/nimol.log\n";
 | 
			
		||||
        close($new_syslog_fd);
 | 
			
		||||
        system("service rsyslog restart");
 | 
			
		||||
        #system("service rsyslog restart");
 | 
			
		||||
	my $retcode=xCAT::Utils->restartservice("rsyslog");
 | 
			
		||||
	return $retcode;
 | 
			
		||||
    } else {
 | 
			
		||||
        print "Don't need to update syslog configure file.\n";
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1520,9 +1520,11 @@ sub mksysclone
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    # check systemimager-server-rsyncd to make sure it's running.
 | 
			
		||||
    my $out = xCAT::Utils->runcmd("service systemimager-server-rsyncd status", -1);
 | 
			
		||||
    if ($::RUNCMD_RC != 0)  { # not running
 | 
			
		||||
        my $rc = xCAT::Utils->startService("systemimager-server-rsyncd");
 | 
			
		||||
    #my $out = xCAT::Utils->runcmd("service systemimager-server-rsyncd status", -1);
 | 
			
		||||
    #if ($::RUNCMD_RC != 0)  { # not running
 | 
			
		||||
    my $retcode=xCAT::Utils->checkservicestatus("systemimager-server-rsyncd");
 | 
			
		||||
    if($retcode !=0){
 | 
			
		||||
        my $rc = xCAT::Utils->startservice("systemimager-server-rsyncd");
 | 
			
		||||
        if ($rc != 0) {
 | 
			
		||||
            return 1;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -453,8 +453,8 @@ if ($::INITIALINSTALL || $::FORCE)
 | 
			
		||||
     &setuphttp;
 | 
			
		||||
 | 
			
		||||
     # chkconfig dhcpd on
 | 
			
		||||
     system("chkconfig dhcpd on");
 | 
			
		||||
 | 
			
		||||
     #system("chkconfig dhcpd on");
 | 
			
		||||
     xCAT::Utils->enableservice("dhcp");
 | 
			
		||||
 | 
			
		||||
     # Turn off selinux on RedHat
 | 
			
		||||
     if (-f "/etc/redhat-release")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user