replace the service stuff with new added generic routines
This commit is contained in:
parent
b979de76b6
commit
c02119ea54
@ -3580,6 +3580,10 @@ sub servicemap{
|
||||
0=>["apache2","httpd"],
|
||||
1=>["httpd.service"],
|
||||
},
|
||||
"ntpserver" => {
|
||||
0=>["ntpd","ntp"],
|
||||
1=>["ntpd.service"],
|
||||
},
|
||||
);
|
||||
|
||||
my $path=undef;
|
||||
|
@ -505,66 +505,74 @@ if ($::INITIALINSTALL || $::FORCE)
|
||||
xCAT::MsgUtils->message('E', "Failed to update /etc/ntp.conf");
|
||||
}
|
||||
|
||||
my $ntpserv;
|
||||
if (-f "/etc/redhat-release")
|
||||
{
|
||||
$ntpserv = "ntpd";
|
||||
}
|
||||
else
|
||||
{
|
||||
$ntpserv = "ntp";
|
||||
}
|
||||
$cmd = "service $ntpserv restart";
|
||||
$outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
#my $ntpserv;
|
||||
#if (-f "/etc/redhat-release")
|
||||
#{
|
||||
# $ntpserv = "ntpd";
|
||||
#}
|
||||
#else
|
||||
#{
|
||||
# $ntpserv = "ntp";
|
||||
#}
|
||||
#$cmd = "service $ntpserv restart";
|
||||
#$outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
#if ($::RUNCMD_RC != 0)
|
||||
my $ret=xCAT::Utils->restartservice("ntpserver");
|
||||
if($ret !=0)
|
||||
{
|
||||
xCAT::MsgUtils->message('E', "Failed to start ntp service");
|
||||
}
|
||||
if (-f "/sbin/chkconfig")
|
||||
{
|
||||
$cmd = "chkconfig $ntpserv on";
|
||||
$outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
#if (-f "/sbin/chkconfig")
|
||||
#{
|
||||
# $cmd = "chkconfig $ntpserv on";
|
||||
# $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
$ret=xCAT::Utils->enableservice("ntpserver");
|
||||
# if ($::RUNCMD_RC != 0)
|
||||
if($ret!=0)
|
||||
{
|
||||
xCAT::MsgUtils->message('E', "Failed to enable ntp service on every boot");
|
||||
}
|
||||
}
|
||||
#}
|
||||
}
|
||||
|
||||
# Disable firewall
|
||||
my $fwserv;
|
||||
if(-f "/etc/SuSE-release")
|
||||
{
|
||||
$fwserv = "SuSEfirewall2_setup";
|
||||
}
|
||||
elsif(-f "/etc/redhat-release")
|
||||
{
|
||||
$fwserv = "iptables";
|
||||
if( -f "/usr/sbin/firewalld" )
|
||||
{
|
||||
$fwserv = "firewalld";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#Ubuntu: FIXME
|
||||
}
|
||||
#my $fwserv;
|
||||
#if(-f "/etc/SuSE-release")
|
||||
#{
|
||||
# $fwserv = "SuSEfirewall2_setup";
|
||||
#}
|
||||
#elsif(-f "/etc/redhat-release")
|
||||
#{
|
||||
# $fwserv = "iptables";
|
||||
# if( -f "/usr/sbin/firewalld" )
|
||||
# {
|
||||
# $fwserv = "firewalld";
|
||||
# }
|
||||
#}
|
||||
#else
|
||||
#{
|
||||
# #Ubuntu: FIXME
|
||||
#}
|
||||
|
||||
if($fwserv)
|
||||
{
|
||||
my $cmd = "service $fwserv stop";
|
||||
my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
#if($fwserv)
|
||||
#{
|
||||
# my $cmd = "service $fwserv stop";
|
||||
# my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
# if ($::RUNCMD_RC != 0)
|
||||
my $ret=xCAT::Utils->stopservice("firewall");
|
||||
if($ret!=0)
|
||||
{
|
||||
xCAT::MsgUtils->message('E', "Failed to stop firewall");
|
||||
}
|
||||
$cmd = "chkconfig $fwserv off";
|
||||
$outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
# $cmd = "chkconfig $fwserv off";
|
||||
# $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
# if ($::RUNCMD_RC != 0)
|
||||
$ret=xCAT::Utils->disableservice("firewall");
|
||||
if($ret!=0)
|
||||
{
|
||||
xCAT::MsgUtils->message('E', "Failed to disable firewall on boot");
|
||||
}
|
||||
}
|
||||
#}
|
||||
|
||||
# Enable ip forwarding. In most cases,
|
||||
# the MN itself will act as the default gateway for the compute nodes,
|
||||
@ -1781,16 +1789,18 @@ sub setupLinuxexports
|
||||
{
|
||||
|
||||
# restart nfs
|
||||
my $cmd;
|
||||
my $os = xCAT::Utils->osver();
|
||||
my $SERVICE = xCAT::Utils->fullpathbin("service");
|
||||
if ($os =~ /sles/) {
|
||||
$cmd = "$SERVICE nfsserver restart";
|
||||
} else {
|
||||
$cmd = "$SERVICE nfs restart";
|
||||
}
|
||||
my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
# my $cmd;
|
||||
# my $os = xCAT::Utils->osver();
|
||||
# my $SERVICE = xCAT::Utils->fullpathbin("service");
|
||||
# if ($os =~ /sles/) {
|
||||
# $cmd = "$SERVICE nfsserver restart";
|
||||
# } else {
|
||||
# $cmd = "$SERVICE nfs restart";
|
||||
# }
|
||||
# my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
# if ($::RUNCMD_RC != 0)
|
||||
my $ret=xCAT::Utils->restartservice("nfs");
|
||||
if($ret!=0)
|
||||
{
|
||||
xCAT::MsgUtils->message('E', "Could not restart NFS.");
|
||||
}
|
||||
@ -1799,14 +1809,18 @@ sub setupLinuxexports
|
||||
xCAT::MsgUtils->message('I', "NFS has been restarted.");
|
||||
}
|
||||
|
||||
my $CHKCONFIG=xCAT::Utils->fullpathbin("chkconfig");
|
||||
if ($os =~ /sles/) {
|
||||
$cmd = "$CHKCONFIG nfsserver on";
|
||||
} else {
|
||||
$cmd = "$CHKCONFIG nfs on";
|
||||
}
|
||||
$outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
#my $CHKCONFIG=xCAT::Utils->fullpathbin("chkconfig");
|
||||
#if ($os =~ /sles/) {
|
||||
# $cmd = "$CHKCONFIG nfsserver on";
|
||||
#} else {
|
||||
# $cmd = "$CHKCONFIG nfs on";
|
||||
#}
|
||||
#$outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
#if ($::RUNCMD_RC != 0)
|
||||
|
||||
|
||||
$ret=xCAT::Utils->enableservice("nfs");
|
||||
if($ret!=0)
|
||||
{
|
||||
xCAT::MsgUtils->message('E', "Could not enable NFS.");
|
||||
}
|
||||
@ -1895,24 +1909,26 @@ sub makenetworks
|
||||
sub setuphttp
|
||||
{
|
||||
|
||||
my $cmd;
|
||||
my $distro = xCAT::Utils->osver();
|
||||
# restart httpd
|
||||
if (-e "/etc/init.d/apache2")
|
||||
{ #for sles/ubuntu
|
||||
$cmd = "/etc/init.d/apache2 stop; /etc/init.d/apache2 start";
|
||||
}
|
||||
elsif (-e "/etc/init.d/httpd")
|
||||
{
|
||||
$cmd = "/etc/init.d/httpd stop; /etc/init.d/httpd start";
|
||||
}
|
||||
else
|
||||
{
|
||||
$cmd = "service httpd stop; service httpd start";
|
||||
}
|
||||
# my $cmd;
|
||||
# my $distro = xCAT::Utils->osver();
|
||||
# # restart httpd
|
||||
# if (-e "/etc/init.d/apache2")
|
||||
# { #for sles/ubuntu
|
||||
# $cmd = "/etc/init.d/apache2 stop; /etc/init.d/apache2 start";
|
||||
# }
|
||||
# elsif (-e "/etc/init.d/httpd")
|
||||
# {
|
||||
# $cmd = "/etc/init.d/httpd stop; /etc/init.d/httpd start";
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# $cmd = "service httpd stop; service httpd start";
|
||||
# }
|
||||
|
||||
my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
# my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
# if ($::RUNCMD_RC != 0)
|
||||
my $ret=xCAT::Utils->restartservice("http");
|
||||
if($ret!=0)
|
||||
{
|
||||
xCAT::MsgUtils->message('E', "Could not restart httpd.");
|
||||
}
|
||||
@ -1922,26 +1938,28 @@ sub setuphttp
|
||||
}
|
||||
|
||||
# enable httpd
|
||||
if (-e "/etc/init.d/apache2")
|
||||
{
|
||||
if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) {
|
||||
$cmd = "/usr/sbin/update-rc.d apache2 enable";
|
||||
}
|
||||
else
|
||||
{ # for sles
|
||||
$cmd = "/sbin/chkconfig apache2 on";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig");
|
||||
$cmd = "$CHKCONFIG httpd on";
|
||||
}
|
||||
#if (-e "/etc/init.d/apache2")
|
||||
#{
|
||||
# if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) {
|
||||
# $cmd = "/usr/sbin/update-rc.d apache2 enable";
|
||||
# }
|
||||
# else
|
||||
# { # for sles
|
||||
# $cmd = "/sbin/chkconfig apache2 on";
|
||||
# }
|
||||
#}
|
||||
#else
|
||||
#{
|
||||
# my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig");
|
||||
# $cmd = "$CHKCONFIG httpd on";
|
||||
#}
|
||||
|
||||
|
||||
|
||||
$outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
#$outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
#if ($::RUNCMD_RC != 0)
|
||||
$ret=xCAT::Utils->enableservice("http");
|
||||
if($ret!=0)
|
||||
{
|
||||
xCAT::MsgUtils->message('E', "Could not enable httpd.");
|
||||
}
|
||||
@ -2182,12 +2200,12 @@ sub startnamedonboot
|
||||
else
|
||||
{
|
||||
#chkconfig
|
||||
my $serv = "named";
|
||||
my $cmd = "/sbin/chkconfig $serv on";
|
||||
if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) {
|
||||
$serv = "bind9";
|
||||
$cmd = "update-rc.d $serv enable";
|
||||
}
|
||||
#my $serv = "named";
|
||||
#my $cmd = "/sbin/chkconfig $serv on";
|
||||
#if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) {
|
||||
# $serv = "bind9";
|
||||
# $cmd = "update-rc.d $serv enable";
|
||||
#}
|
||||
|
||||
#"service named start" is very slowly,sometimes hang in rhels6.4 after installation
|
||||
#a work around is to generate /etc/rndc-key during xCAT installation
|
||||
@ -2195,14 +2213,16 @@ sub startnamedonboot
|
||||
system("rndc-confgen -a -r /dev/urandom");
|
||||
}
|
||||
|
||||
my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
#my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
#if ($::RUNCMD_RC != 0)
|
||||
my $ret=xCAT::Utils->enableservice("named");
|
||||
if($ret!=0)
|
||||
{
|
||||
xCAT::MsgUtils->message("E", "Could not enable $serv.");
|
||||
xCAT::MsgUtils->message("E", "Could not enable dns server.");
|
||||
}
|
||||
else
|
||||
{
|
||||
xCAT::MsgUtils->message("I", "$serv has been enabled on boot.");
|
||||
xCAT::MsgUtils->message("I", "dns server has been enabled on boot.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user