repleace the servcie stuff with newly added generic subroutines in xcat-client
This commit is contained in:
		| @@ -3613,6 +3613,10 @@ sub servicemap{ | ||||
|                  0=>["ntpd","ntp"], | ||||
|                  1=>["ntpd.service"], | ||||
|                }, | ||||
|      "mysql" =>  { | ||||
|                  0=>["mysqld","mysql"], | ||||
|                  1=>["mysqld.service"], | ||||
|                }, | ||||
|   ); | ||||
|  | ||||
|   my $path=undef; | ||||
|   | ||||
| @@ -590,13 +590,16 @@ sub startxcatd | ||||
|       } else { | ||||
|         $xcmd = "$::XCATROOT/sbin/restartxcatd"; | ||||
|       } | ||||
|       system($xcmd); | ||||
|  | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|      $xcmd = "service xcatd restart"; | ||||
|      #$xcmd = "service xcatd restart"; | ||||
|      my $ret=xCAT::Utils->restartservice("xcatd"); | ||||
|      return $ret; | ||||
|    } | ||||
|    system($xcmd); | ||||
|  | ||||
| } | ||||
|  | ||||
| #----------------------------------------------------------------------------- | ||||
| @@ -618,13 +621,16 @@ sub shutdownxcatd | ||||
|     if ($::osname eq 'AIX') | ||||
|     { | ||||
|         $xcmd = "stopsrc -s xcatd"; | ||||
|         system($xcmd); | ||||
|  | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         $xcmd = "service xcatd stop"; | ||||
|         #$xcmd = "service xcatd stop"; | ||||
|         my $ret=xCAT::Utils->stopservice("xcatd"); | ||||
|         return $ret; | ||||
|     } | ||||
|     system($xcmd); | ||||
|  | ||||
| } | ||||
|  | ||||
| #----------------------------------------------------------------------------- | ||||
| @@ -2073,11 +2079,12 @@ sub adddb2paths | ||||
| #----------------------------------------------------------------------------- | ||||
| sub remove | ||||
| { | ||||
| 	my $cmd; | ||||
| 	my @output; | ||||
| 	my $error = 0; | ||||
| 	#see if DB2 is installed | ||||
| 	if (!(-e ($::installdb2dir))) | ||||
|     my $cmd;  | ||||
|     my @output; | ||||
|     my $error = 0; | ||||
|     my $retcode=0; | ||||
|     #see if DB2 is installed | ||||
|     if (!(-e ($::installdb2dir))) | ||||
|     { | ||||
|         my $message = | ||||
|           "\nDB2 is not installed."; | ||||
| @@ -2120,18 +2127,23 @@ sub remove | ||||
|             	 | ||||
|             	my $cmd = "ps -elf|grep xcatd"; | ||||
|                 my @output = xCAT::Utils->runcmd($cmd, 0); | ||||
|  | ||||
|                 if ($::RUNCMD_RC == 0) | ||||
|                 {       | ||||
|                     if ($::osname eq 'AIX') | ||||
|                     { | ||||
|                     	my $cmd = "startsrc -s xcatd"; | ||||
|                         xCAT::Utils->runcmd($cmd, -1); | ||||
|                         $retcode=$::RUNCMD_RC; | ||||
|                     } | ||||
|                     else | ||||
|                     {            | ||||
|                     	my $cmd = "service xcatd start"; | ||||
|                     	#my $cmd = "service xcatd start"; | ||||
|                     	$retcode=xCAT::Utils->startservice("xcatd"); | ||||
|                     } | ||||
|                     xCAT::Utils->runcmd($cmd, -1); | ||||
|             	    if ($::RUNCMD_RC !=0) | ||||
|                     #xCAT::Utils->runcmd($cmd, -1); | ||||
|             	    #if ($::RUNCMD_RC !=0) | ||||
|             	    if($retcode!=0) | ||||
|             	    { | ||||
|             	    	my $message = "can't start xcatd"; | ||||
|             	    	$error += 1; | ||||
| @@ -2155,13 +2167,17 @@ sub remove | ||||
|             if ($::osname eq 'AIX') | ||||
|             { | ||||
|             	my $cmd = "stopsrc -s xcatd"; | ||||
|                 xCAT::Utils->runcmd($cmd, -1); | ||||
|                 $retcode=$::RUNCMD_RC; | ||||
|             } | ||||
|             else | ||||
|             {            | ||||
|             	my $cmd = "service xcatd stop"; | ||||
|             	#my $cmd = "service xcatd stop"; | ||||
|             	$retcode=xCAT::Utils->stopservice("xcatd"); | ||||
|             } | ||||
|             xCAT::Utils->runcmd($cmd, -1); | ||||
|             if ($::RUNCMD_RC !=0) | ||||
|             #xCAT::Utils->runcmd($cmd, -1); | ||||
|             #if ($::RUNCMD_RC !=0) | ||||
|             if($retcode!=0) | ||||
|             { | ||||
|             	my $message = "can't stop xcatd"; | ||||
|             	xCAT::MsgUtils->message("E", "$message"); | ||||
| @@ -2198,13 +2214,17 @@ sub remove | ||||
|             if ($::osname eq 'AIX') | ||||
|             { | ||||
|             	my $cmd = "startsrc -s xcatd"; | ||||
|                 xCAT::Utils->runcmd($cmd, -1); | ||||
|                 $retcode=$::RUNCMD_RC;  | ||||
|             } | ||||
|             else | ||||
|             {            | ||||
|             	my $cmd = "service xcatd start"; | ||||
|             	#my $cmd = "service xcatd start"; | ||||
|             	$retcode=xCAT::Utils->startservice("xcatd"); | ||||
|             } | ||||
|             xCAT::Utils->runcmd($cmd, -1); | ||||
|             if ($::RUNCMD_RC !=0) | ||||
|             #xCAT::Utils->runcmd($cmd, -1); | ||||
|             #if ($::RUNCMD_RC !=0) | ||||
|             if($retcode!=0) | ||||
|             { | ||||
|             	my $message = "can't start xcatd"; | ||||
|             	xCAT::MsgUtils->message("E", "$message"); | ||||
|   | ||||
| @@ -608,13 +608,16 @@ sub shutdownxcatd | ||||
|     if ($::osname eq 'AIX') | ||||
|     { | ||||
|         $xcmd = "stopsrc -s xcatd"; | ||||
|         system($xcmd); | ||||
|  | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         $xcmd = "service xcatd stop"; | ||||
|         #$xcmd = "service xcatd stop"; | ||||
|         my $ret=xCAT::Utils->stopservice("xcatd"); | ||||
|         return $ret;  | ||||
|     } | ||||
|     system($xcmd); | ||||
|  | ||||
| } | ||||
|  | ||||
| #----------------------------------------------------------------------------- | ||||
| @@ -861,6 +864,7 @@ sub initmysqldb | ||||
| sub mysqlstart | ||||
| { | ||||
|     my $cmd; | ||||
|     my $ret=0; | ||||
|     if ($::osname eq 'AIX') | ||||
|     { | ||||
|         my $hostname = `hostname`; | ||||
| @@ -872,28 +876,32 @@ sub mysqlstart | ||||
|         $cmd = $cmd2; | ||||
|         $cmd .= | ||||
|           "$::installdir/bin/mysqld --user=mysql --basedir=$::installdir --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/$hostname.err --pid-file=/var/lib/mysql/$hostname.pid --socket=/tmp/mysql.sock --port=3306 &"; | ||||
|         $ret=xCAT::Utils->runcmd($cmd, 0); | ||||
|          | ||||
|          | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         if ($::MariaDB==1) {    # running MariaDB | ||||
|             $cmd = "service mariadb start"; | ||||
|             #$cmd = "service mariadb start"; | ||||
|             $ret=xCAT::Utils->startservice("mariadb"); | ||||
|             | ||||
|         } else {   # it is mysql | ||||
|  | ||||
|           if ($::linuxos =~ /rh.*/) | ||||
|           { | ||||
|             $cmd = "service mysqld start"; | ||||
|           } | ||||
|           else | ||||
|           {    # sles | ||||
|             $cmd = "service mysql start"; | ||||
|           } | ||||
|           #if ($::linuxos =~ /rh.*/) | ||||
|           #{ | ||||
|           #  $cmd = "service mysqld start"; | ||||
|           #} | ||||
|           #else | ||||
|           #{    # sles | ||||
|           #  $cmd = "service mysql start"; | ||||
|           #} | ||||
|           $ret=xCAT::Utils->startservice("mysql"); | ||||
|        } | ||||
|     } | ||||
|     xCAT::Utils->runcmd($cmd, 0); | ||||
|     if ($::RUNCMD_RC != 0) | ||||
|     if ($ret != 0) | ||||
|     { | ||||
|         xCAT::MsgUtils->message("E", " $cmd failed."); | ||||
|         xCAT::MsgUtils->message("E", " failed to start mysql/mariadb."); | ||||
|         exit(1); | ||||
|     } | ||||
|  | ||||
| @@ -1809,12 +1817,14 @@ sub restorexcatdb | ||||
|     if ($::osname eq 'AIX') | ||||
|     { | ||||
|         $xcmd = "$::XCATROOT/sbin/restartxcatd"; | ||||
|  | ||||
|         system($xcmd); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         $xcmd = "service xcatd restart"; | ||||
|         #$xcmd = "service xcatd restart"; | ||||
|         my $ret=xCAT::Utils->restartservie("xcatd"); | ||||
|         return $ret; | ||||
|     } | ||||
|     system($xcmd); | ||||
|  | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -444,13 +444,16 @@ sub shutdownxcatd | ||||
|     if ($::osname eq 'AIX') | ||||
|     { | ||||
|         $xcmd = "stopsrc -s xcatd"; | ||||
|         system($xcmd); | ||||
|  | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         $xcmd = "service xcatd stop"; | ||||
|        # $xcmd = "service xcatd stop"; | ||||
|        my $ret=xCAT::Utils->stopservice("xcatd"); | ||||
|        return $ret; | ||||
|     } | ||||
|     system($xcmd); | ||||
|  | ||||
| } | ||||
|  | ||||
| #----------------------------------------------------------------------------- | ||||
| @@ -832,6 +835,7 @@ sub initpgdb | ||||
| sub pgstart | ||||
| { | ||||
|     my $cmd; | ||||
|     my $ret=0; | ||||
|     xCAT::MsgUtils->message("I", "Starting the PosgreSQL Server"); | ||||
|     if ($::osname eq 'AIX') | ||||
|     { | ||||
| @@ -843,27 +847,35 @@ sub pgstart | ||||
|     else    # linux | ||||
|     { | ||||
|         if (defined($::postgres9)) { # set to the PTF level of postgresql 9.X | ||||
|           $cmd = "service postgresql-9.$::postgres9 start"; | ||||
|           #$cmd = "service postgresql-9.$::postgres9 start"; | ||||
|           $cmd = "postgresql-9.$::postgres9"; | ||||
|         } else { | ||||
|           $cmd = "service postgresql start"; | ||||
|           #$cmd = "service postgresql start"; | ||||
|           $cmd = "postgresql"; | ||||
|         } | ||||
|         system($cmd); | ||||
|         if ($? > 0) { | ||||
|             xCAT::MsgUtils->message("E", " $cmd failed."); | ||||
|         #system($cmd) | ||||
|         #if ($? > 0) { | ||||
|         $ret=xCAT::Utils->startservice($cmd); | ||||
|         if ($ret != 0) { | ||||
|             xCAT::MsgUtils->message("E", " failed to start $cmd."); | ||||
|             exit(1); | ||||
|         } | ||||
|         # check to see if running before continuing | ||||
|         my $retries =0; | ||||
|         my $pgstarted =0; | ||||
|         if (defined($::postgres9)) { # set to the PTF level of postgresql 9.X | ||||
|             $cmd = "service postgresql-9.$::postgres9 status"; | ||||
|         } else { | ||||
|             $cmd = "service postgresql status"; | ||||
|         } | ||||
|         #if (defined($::postgres9)) { # set to the PTF level of postgresql 9.X | ||||
|         #    #$cmd = "service postgresql-9.$::postgres9 status"; | ||||
|         #    $ret=xCAT::Utils->checkservicestatus("postgresql-9.$::postgres9"); | ||||
|         #} else { | ||||
|         #    #$cmd = "service postgresql status"; | ||||
|         #    $ret=xCAT::Utils->checkservicestatus("postgresql"); | ||||
|         #} | ||||
|         while ($retries < 30) { | ||||
|           $retries++; | ||||
|           my @status=xCAT::Utils->runcmd($cmd, -1); | ||||
|           if (grep(/[r|R]unning/, @status)) { | ||||
|           #my @status=xCAT::Utils->runcmd($cmd, -1); | ||||
|           #if (grep(/[r|R]unning/, @status)) { | ||||
|           $ret=xCAT::Utils->checkservicestatus($cmd); | ||||
|           if($ret == 0){  | ||||
|             $pgstarted=1; | ||||
|             last; | ||||
|           } | ||||
| @@ -903,15 +915,19 @@ sub pgreboot | ||||
|     else    # linux | ||||
|     { | ||||
|         if (defined($::postgres9)) { # set to the postgresql ptf level | ||||
|             $cmd = "chkconfig postgresql-9.$::postgres9 on"; | ||||
|         #    $cmd = "chkconfig postgresql-9.$::postgres9 on"; | ||||
|             $cmd = "postgresql-9.$::postgres9"; | ||||
|         } else { | ||||
|             $cmd = "chkconfig postgresql on"; | ||||
|             #$cmd = "chkconfig postgresql on"; | ||||
|             $cmd = "postgresql"; | ||||
|         } | ||||
|         if ($debianflag){ | ||||
|             $cmd = "update-rc.d postgresql defaults"; | ||||
|         } | ||||
|         xCAT::Utils->runcmd($cmd, 0); | ||||
|         if ($::RUNCMD_RC != 0) | ||||
|         #if ($debianflag){ | ||||
|             #$cmd = "update-rc.d postgresql defaults"; | ||||
|         #} | ||||
|         #xCAT::Utils->runcmd($cmd, 0); | ||||
|         #if ($::RUNCMD_RC != 0) | ||||
|         my $ret=xCAT::Utils->enableservice($cmd); | ||||
|         if($cmd !=0 ) | ||||
|         { | ||||
|             xCAT::MsgUtils->message("E", | ||||
|                         " $cmd failed. PostgreSQL will not restart on reboot."); | ||||
| @@ -1347,12 +1363,15 @@ sub restorexcatdb | ||||
|     if ($::osname eq 'AIX') | ||||
|     { | ||||
|         $xcmd = "startsrc -s xcatd"; | ||||
|         system($xcmd); | ||||
|  | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         $xcmd = "service xcatd start"; | ||||
|         #$xcmd = "service xcatd start"; | ||||
|         my $ret=xCAT::Utils->startservice("xcatd"); | ||||
|         return $ret; | ||||
|     } | ||||
|     system($xcmd); | ||||
|  | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user