2008-05-12 21:34:15 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#-------------------------------------------------------
|
|
|
|
package xCAT_plugin::AAsn;
|
2009-04-24 16:47:23 +00:00
|
|
|
use strict;
|
2008-05-12 21:34:15 +00:00
|
|
|
use xCAT::Table;
|
|
|
|
|
|
|
|
use xCAT::Utils;
|
2012-08-09 04:07:40 +00:00
|
|
|
use xCAT::TableUtils;
|
2010-05-27 15:13:26 +00:00
|
|
|
use xCAT::NetworkUtils;
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
use xCAT::MsgUtils;
|
2009-03-02 14:27:10 +00:00
|
|
|
use xCAT_plugin::dhcp;
|
|
|
|
use xCAT_plugin::conserver;
|
2008-05-12 21:34:15 +00:00
|
|
|
use File::Path;
|
|
|
|
use Getopt::Long;
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2009-03-02 14:27:10 +00:00
|
|
|
=head1 AAsn
|
|
|
|
|
|
|
|
This is the Service Node Plugin, although it does perform a few functions on
|
|
|
|
the Management Node.
|
|
|
|
It reads the servicenode table for the service node it is running on,
|
|
|
|
and run the appropriate
|
|
|
|
setup routine for each service that is designated to be setup in the
|
|
|
|
servicenode table for this service node. Some functions are only done for
|
|
|
|
Linux.
|
|
|
|
A few functions are done not based on the servicenode table. For example:
|
2008-05-22 13:01:40 +00:00
|
|
|
|
2008-09-09 12:31:27 +00:00
|
|
|
on a Linux Service Node
|
2010-03-29 16:33:43 +00:00
|
|
|
if site.installloc set
|
|
|
|
mounts /install
|
|
|
|
if site.installloc not set
|
|
|
|
creates /install if needed
|
|
|
|
sets up nfs
|
|
|
|
exports /install
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2008-05-22 13:01:40 +00:00
|
|
|
=head3 handled_commands
|
2008-05-12 21:34:15 +00:00
|
|
|
|
2009-03-02 14:27:10 +00:00
|
|
|
If bypassmode then exit
|
|
|
|
If xcat daemon reload then exit
|
|
|
|
|
2008-05-12 21:34:15 +00:00
|
|
|
Check to see if on a Service Node
|
2009-03-02 14:27:10 +00:00
|
|
|
If Linux
|
2010-03-29 16:33:43 +00:00
|
|
|
Call setupInstallloc
|
2009-03-02 14:27:10 +00:00
|
|
|
If this is a service Node
|
|
|
|
Read Service Node Table
|
|
|
|
For each service returned to be setup
|
|
|
|
Call the appropriate setup_service routine
|
|
|
|
else if on the Management Node
|
|
|
|
Do any Management Node setup of services needed
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2010-03-29 16:33:43 +00:00
|
|
|
sub handled_commands { return; }
|
|
|
|
|
|
|
|
sub init_plugin
|
2008-05-12 21:34:15 +00:00
|
|
|
{
|
2009-03-28 05:57:08 +00:00
|
|
|
my $doreq = shift;
|
2009-03-28 04:49:49 +00:00
|
|
|
|
2008-05-19 18:15:48 +00:00
|
|
|
# If called in XCATBYPASS mode, don't do any setup
|
2009-03-02 14:27:10 +00:00
|
|
|
if ($ENV{'XCATBYPASS'})
|
|
|
|
{
|
|
|
|
return 0;
|
2008-09-09 12:31:27 +00:00
|
|
|
}
|
|
|
|
|
2009-03-02 14:27:10 +00:00
|
|
|
# If a xcat daemon reload, don't do any setup
|
|
|
|
if ($ENV{'XCATRELOAD'})
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2008-05-19 18:15:48 +00:00
|
|
|
|
2008-05-12 21:34:15 +00:00
|
|
|
my $rc = 0;
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
#On the Servicenodes or the Management node
|
|
|
|
if (((xCAT::Utils->isServiceNode()) && ( -s "/etc/xcat/cfgloc"))
|
|
|
|
|| (xCAT::Utils->isMN()))
|
2008-05-12 21:34:15 +00:00
|
|
|
{
|
2012-08-09 04:07:40 +00:00
|
|
|
my @nodeinfo = xCAT::NetworkUtils->determinehostname;
|
2008-05-12 21:34:15 +00:00
|
|
|
my $nodename = pop @nodeinfo; # get hostname
|
|
|
|
my @nodeipaddr = @nodeinfo; # get ip addresses
|
2009-03-02 14:27:10 +00:00
|
|
|
my $service;
|
2013-02-28 21:06:08 +00:00
|
|
|
# if a linux servicenode
|
|
|
|
if ((xCAT::Utils->isLinux())&& (xCAT::Utils->isServiceNode()))
|
2008-05-12 21:34:15 +00:00
|
|
|
{
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
# service needed on Linux Service Node
|
2010-03-29 16:33:43 +00:00
|
|
|
$service = "setupInstallloc";
|
2013-02-28 21:06:08 +00:00
|
|
|
&setupInstallloc($nodename);
|
2009-03-02 14:27:10 +00:00
|
|
|
$service = "ssh";
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
&setup_SSH(); # setup SSH
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# read the service node table
|
|
|
|
# for a list of all functions to setup for this service node
|
|
|
|
#
|
2013-02-28 21:06:08 +00:00
|
|
|
my $servicelist = xCAT::ServiceNodeUtils->isServiceReq($nodename, \@nodeipaddr);
|
2011-07-22 10:15:44 +00:00
|
|
|
my $service;
|
2009-03-02 14:27:10 +00:00
|
|
|
if ($::RUNCMD_RC == 0)
|
|
|
|
{
|
|
|
|
if (xCAT::Utils->isLinux())
|
|
|
|
{ #run only the following only on Linux
|
|
|
|
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
if ($servicelist->{"ftpserver"} == 1)
|
2009-03-02 14:27:10 +00:00
|
|
|
{
|
2013-02-28 21:06:08 +00:00
|
|
|
&setup_FTP(); # setup vsftpd
|
2009-03-02 14:27:10 +00:00
|
|
|
}
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
if ($servicelist->{"ldapserver"} == 1)
|
2009-03-02 14:27:10 +00:00
|
|
|
{
|
2013-02-28 21:06:08 +00:00
|
|
|
&setup_LDAP(); # setup LDAP
|
2009-03-02 14:27:10 +00:00
|
|
|
}
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
if ($servicelist->{"tftpserver"} == 1)
|
2009-03-02 14:27:10 +00:00
|
|
|
{
|
2013-02-28 21:06:08 +00:00
|
|
|
if (xCAT::Utils->isServiceNode()) { # service node
|
|
|
|
&setup_TFTP($nodename, $doreq); # setup TFTP
|
|
|
|
} else { # management node
|
|
|
|
&enable_TFTPhpa();
|
|
|
|
}
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
}
|
2009-03-26 15:01:53 +00:00
|
|
|
|
2009-03-02 14:27:10 +00:00
|
|
|
} # end Linux only
|
|
|
|
#
|
|
|
|
# setup these services for AIX or Linux
|
|
|
|
#
|
2013-02-28 21:06:08 +00:00
|
|
|
if ($servicelist->{"conserver"} == 1)
|
2011-07-22 10:15:44 +00:00
|
|
|
{
|
|
|
|
if (xCAT::Utils->isLinux())
|
|
|
|
{ #run only the following only on Linux
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
&setup_CONS($nodename); # setup conserver
|
2011-07-22 10:15:44 +00:00
|
|
|
} else { #AIX
|
2013-02-28 21:06:08 +00:00
|
|
|
$rc=xCAT::Utils->setupAIXconserver();
|
2011-07-22 10:15:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2013-02-28 21:06:08 +00:00
|
|
|
if ($servicelist->{"nameserver"} == 1)
|
2009-03-02 14:27:10 +00:00
|
|
|
{
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
&setup_DNS(); # setup DNS
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
}
|
2013-02-28 21:06:08 +00:00
|
|
|
if ($servicelist->{"nfsserver"} == 1)
|
2009-03-02 14:27:10 +00:00
|
|
|
{
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
&setup_NFS($nodename); # setup NFS
|
2010-03-29 16:33:43 +00:00
|
|
|
|
|
|
|
# The nfsserver field in servicenode table
|
2009-06-09 01:16:04 +00:00
|
|
|
# will also setup http service for Linux
|
|
|
|
if (xCAT::Utils->isLinux())
|
|
|
|
{
|
2013-02-28 21:06:08 +00:00
|
|
|
&setup_HTTP($nodename); # setup HTTP
|
2009-06-09 01:16:04 +00:00
|
|
|
}
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
}
|
2013-02-28 21:06:08 +00:00
|
|
|
if ($servicelist->{"ipforward"} == 1)
|
|
|
|
{
|
|
|
|
# enable ip forwarding
|
|
|
|
xCAT::NetworkUtils->setup_ip_forwarding(1);
|
|
|
|
}
|
2010-03-29 16:33:43 +00:00
|
|
|
|
2009-03-26 15:01:53 +00:00
|
|
|
#
|
2013-02-28 21:06:08 +00:00
|
|
|
# setup dhcp only on Linux and do it last
|
2009-03-26 15:01:53 +00:00
|
|
|
#
|
2010-03-29 16:33:43 +00:00
|
|
|
if (xCAT::Utils->isLinux())
|
|
|
|
{
|
2013-02-28 21:06:08 +00:00
|
|
|
if ($servicelist->{"dhcpserver"} == 1)
|
2009-03-26 15:01:53 +00:00
|
|
|
{
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
&setup_DHCP($nodename); # setup DHCP
|
2009-03-26 15:01:53 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-02 14:27:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ # error from servicenode tbl read
|
|
|
|
xCAT::MsgUtils->message("S",
|
|
|
|
"AAsn.pm:Error reading the servicenode table.");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2008-05-12 21:34:15 +00:00
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2008-05-22 13:01:40 +00:00
|
|
|
=head3 process_request
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
Process the command
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub process_request
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
2010-03-29 16:33:43 +00:00
|
|
|
=head3 setupInstallloc
|
2008-05-12 21:34:15 +00:00
|
|
|
|
2008-05-22 13:01:40 +00:00
|
|
|
if site.installloc attribute set
|
2010-03-29 16:33:43 +00:00
|
|
|
If the installdir directory is exported, unexport it
|
|
|
|
mount the installdir directory from the installloc location
|
|
|
|
if site.installoc not set and we are on a Stateful install
|
|
|
|
If installdir mounted, unmount it
|
|
|
|
If installdir directory not created, create it
|
|
|
|
setup NFS
|
|
|
|
export the installdir directory
|
|
|
|
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
2010-03-29 16:33:43 +00:00
|
|
|
sub setupInstallloc
|
2008-05-12 21:34:15 +00:00
|
|
|
{
|
|
|
|
my ($nodename) = @_;
|
|
|
|
my $rc = 0;
|
2012-08-09 04:07:40 +00:00
|
|
|
my $installdir = xCAT::TableUtils->getInstallDir();
|
2010-03-29 16:33:43 +00:00
|
|
|
my $installloc;
|
2009-07-06 13:47:15 +00:00
|
|
|
my $newinstallloc;
|
2010-03-29 16:33:43 +00:00
|
|
|
|
2008-05-12 21:34:15 +00:00
|
|
|
# read DB for nodeinfo
|
|
|
|
my $master;
|
|
|
|
my $os;
|
|
|
|
my $arch;
|
|
|
|
my $nomount = 0;
|
|
|
|
|
2012-08-09 04:07:40 +00:00
|
|
|
my $retdata = xCAT::ServiceNodeUtils->readSNInfo($nodename);
|
2009-10-05 20:48:35 +00:00
|
|
|
if (ref $retdata and $retdata->{'arch'})
|
2010-03-29 16:33:43 +00:00
|
|
|
{ # no error
|
2008-05-12 21:34:15 +00:00
|
|
|
$master = $retdata->{'master'}; # management node
|
|
|
|
$os = $retdata->{'os'};
|
|
|
|
$arch = $retdata->{'arch'};
|
|
|
|
|
|
|
|
# read install directory and install location from database,
|
|
|
|
# if they exists
|
2012-08-09 04:07:40 +00:00
|
|
|
my @installlocation = xCAT::TableUtils->get_site_attribute("installloc");
|
2008-05-12 21:34:15 +00:00
|
|
|
my $hostname;
|
|
|
|
my $path;
|
2008-05-22 13:01:40 +00:00
|
|
|
if ($installlocation[0])
|
2008-05-12 21:34:15 +00:00
|
|
|
{
|
2009-03-02 14:27:10 +00:00
|
|
|
if (grep /:/, $installlocation[0])
|
|
|
|
{
|
2009-07-06 13:47:15 +00:00
|
|
|
my ($hostname, $newinstallloc) = split ":", $installlocation[0];
|
2009-03-02 14:27:10 +00:00
|
|
|
if ($hostname)
|
|
|
|
{ # hostname set in /installloc attribute
|
2010-03-29 16:33:43 +00:00
|
|
|
$master = $hostname; # set name for mount
|
|
|
|
$installloc = $newinstallloc; #set path for mount point
|
2009-03-02 14:27:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$installloc = $installlocation[0];
|
2008-05-12 21:34:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-03-29 16:33:43 +00:00
|
|
|
{ # if no installloc attribute then we do not mount
|
2008-05-12 21:34:15 +00:00
|
|
|
$nomount = 1;
|
|
|
|
}
|
|
|
|
|
2010-03-29 16:33:43 +00:00
|
|
|
if ($nomount == 0) # we do have installloc attribute
|
|
|
|
{
|
|
|
|
|
|
|
|
# mount the install directory from the installloc location
|
|
|
|
# make the directory to mount on
|
2008-05-12 21:34:15 +00:00
|
|
|
if (!(-e $installdir))
|
|
|
|
{
|
|
|
|
mkpath($installdir);
|
|
|
|
}
|
|
|
|
|
2010-03-29 16:33:43 +00:00
|
|
|
# check if exported, and unexport it
|
|
|
|
my $cmd = "/bin/cat /etc/exports | grep '$installdir'";
|
|
|
|
my $outref = xCAT::Utils->runcmd("$cmd", -1);
|
|
|
|
if ($::RUNCMD_RC == 0) # it is exported
|
|
|
|
{
|
|
|
|
|
|
|
|
# remove from /etc/exports
|
|
|
|
my $sedcmd = "sed \\";
|
|
|
|
$sedcmd .= "$installdir/d /etc/exports > /etc/exports.tmp";
|
|
|
|
system $sedcmd;
|
|
|
|
if ($? > 0)
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", "Error $cmd");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$cmd = "cp /etc/exports.tmp /etc/exports";
|
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", "Error $cmd");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# restart nfs
|
|
|
|
&setup_NFS($nodename);
|
|
|
|
|
|
|
|
$cmd = " exportfs -a";
|
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
|
|
|
{ # error
|
|
|
|
$rc = 1;
|
|
|
|
xCAT::MsgUtils->message("S", "Error $cmd");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-05-12 21:34:15 +00:00
|
|
|
# check to see if install already mounted
|
|
|
|
|
|
|
|
my $mounted = xCAT::Utils->isMounted($installdir);
|
|
|
|
if ($mounted == 0)
|
2010-03-29 16:33:43 +00:00
|
|
|
{ # not mounted
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
# need to mount the directory
|
2011-10-24 09:44:22 +00:00
|
|
|
my $cmd;
|
2012-08-09 04:07:40 +00:00
|
|
|
my @nfsv4 = xCAT::TableUtils->get_site_attribute("useNFSv4onAIX");
|
2011-10-24 09:44:22 +00:00
|
|
|
if ($nfsv4[0] && ($nfsv4[0] =~ /1|Yes|yes|YES|Y|y/))
|
|
|
|
{
|
|
|
|
$cmd = "mount -o vers=4,rw,nolock $master:$installloc $installdir";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$cmd = "mount -o rw,nolock $master:$installloc $installdir";
|
2011-10-26 06:46:45 +00:00
|
|
|
}
|
2008-05-12 21:34:15 +00:00
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
2010-03-29 16:33:43 +00:00
|
|
|
{ # error
|
2008-05-12 21:34:15 +00:00
|
|
|
$rc = 1;
|
|
|
|
xCAT::MsgUtils->message("S", "Error $cmd");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-29 16:33:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
|
2010-04-21 13:02:22 +00:00
|
|
|
# installloc not set so we will export /install on the SN, if Stateful
|
2010-03-29 16:33:43 +00:00
|
|
|
if (xCAT::Utils->isStateful())
|
|
|
|
{
|
|
|
|
|
|
|
|
# no installloc attribute, create and export installdir
|
|
|
|
# check to see if installdir is mounted
|
|
|
|
my $mounted = xCAT::Utils->isMounted($installdir);
|
|
|
|
if ($mounted == 1)
|
|
|
|
{
|
|
|
|
|
|
|
|
# need to unmount the directory
|
|
|
|
my $cmd = "umount $installdir";
|
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
|
|
|
{ # error
|
|
|
|
$rc = 1;
|
|
|
|
xCAT::MsgUtils->message("S", "Error $cmd");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# if it does not exist,need to make the installdir directory
|
|
|
|
if (!(-e $installdir))
|
|
|
|
{
|
|
|
|
mkpath($installdir);
|
|
|
|
}
|
|
|
|
|
|
|
|
# export the installdir
|
|
|
|
#
|
|
|
|
# add /install to /etc/exports - if needed
|
|
|
|
#
|
|
|
|
|
|
|
|
my $cmd = "/bin/cat /etc/exports | grep '$installdir'";
|
|
|
|
my $outref = xCAT::Utils->runcmd("$cmd", -1);
|
|
|
|
my $changed_exports;
|
|
|
|
if ($::RUNCMD_RC != 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
# ok - then add this entry
|
|
|
|
my $cmd =
|
2010-04-01 13:27:32 +00:00
|
|
|
"/bin/echo '$installdir *(rw,no_root_squash,sync,no_subtree_check)' >> /etc/exports";
|
2010-03-29 16:33:43 +00:00
|
|
|
my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
|
|
|
if ($::RUNCMD_RC != 0)
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message('S',
|
|
|
|
"Could not update the /etc/exports file.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$changed_exports++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($changed_exports)
|
|
|
|
{
|
|
|
|
|
|
|
|
# restart nfs
|
|
|
|
&setup_NFS($nodename);
|
|
|
|
|
|
|
|
my $cmd = "/usr/sbin/exportfs -a";
|
|
|
|
my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
|
|
|
if ($::RUNCMD_RC != 0)
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message('S', "Error with $cmd.");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-12 21:34:15 +00:00
|
|
|
}
|
|
|
|
else
|
2010-03-29 16:33:43 +00:00
|
|
|
{ # error reading Db
|
2008-05-12 21:34:15 +00:00
|
|
|
$rc = 1;
|
|
|
|
}
|
2010-03-29 16:33:43 +00:00
|
|
|
if ($rc == 0)
|
2008-05-12 21:34:15 +00:00
|
|
|
{
|
|
|
|
|
2010-03-29 16:33:43 +00:00
|
|
|
# update fstab
|
2009-04-24 16:47:23 +00:00
|
|
|
my $cmd = "grep $master:$installloc $installdir /etc/fstab ";
|
2008-05-12 21:34:15 +00:00
|
|
|
xCAT::Utils->runcmd($cmd, -1);
|
|
|
|
if ($::RUNCMD_RC != 0)
|
|
|
|
{
|
2010-03-29 16:33:43 +00:00
|
|
|
if ($nomount == 0) # then add the entry
|
|
|
|
{
|
|
|
|
`echo "$master:$installloc $installdir nfs timeo=14,intr 1 2" >>/etc/fstab`;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ # fstab entry there
|
|
|
|
|
|
|
|
if ($nomount == 1)
|
|
|
|
{
|
|
|
|
|
|
|
|
# then remove the entry
|
|
|
|
my $sedcmd = "sed \\";
|
|
|
|
$sedcmd .= "$installdir/d /etc/fstab > /etc/fstab.tmp";
|
|
|
|
system $sedcmd;
|
|
|
|
if ($? > 0)
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", "Error $cmd");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$cmd = "cp /etc/fstab.tmp /etc/fstab";
|
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", "Error $cmd");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2008-05-12 21:34:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
2010-05-05 07:30:18 +00:00
|
|
|
|
2009-03-02 14:27:10 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_CONS
|
|
|
|
|
|
|
|
Sets up Conserver
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_CONS
|
|
|
|
{
|
|
|
|
my ($nodename) = @_;
|
|
|
|
my $rc = 0;
|
|
|
|
|
|
|
|
my $cmd;
|
2013-02-28 21:06:08 +00:00
|
|
|
my $cmdref;
|
|
|
|
$cmdref->{command}->[0] = "makeconservercf";
|
|
|
|
$cmdref->{arg}->[0] = "-l";
|
|
|
|
$cmdref->{cwd}->[0] = "/opt/xcat/sbin";
|
|
|
|
$cmdref->{svboot}->[0] = "yes";
|
|
|
|
no strict "refs";
|
|
|
|
my $modname = "conserver";
|
|
|
|
${"xCAT_plugin::" . $modname . "::"}{process_request}
|
2009-03-02 14:27:10 +00:00
|
|
|
->($cmdref, \&xCAT::Client::handle_response);
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
# start conserver. conserver needs 2 CA files to start
|
|
|
|
my $ca_file1 = "/etc/xcat/ca/ca-cert.pem";
|
|
|
|
my $ca_file2 = "/etc/xcat/cert/server-cred.pem";
|
|
|
|
if (!-e $ca_file1)
|
|
|
|
{
|
|
|
|
print
|
|
|
|
"conserver cannot be started because the file $ca_file1 cannot be found\n";
|
|
|
|
}
|
|
|
|
elsif (!-e $ca_file2)
|
|
|
|
{
|
|
|
|
print
|
|
|
|
"conserver cannot be started because the file $ca_file2 cannot be found\n";
|
2009-03-02 14:27:10 +00:00
|
|
|
}
|
|
|
|
else
|
2013-02-28 21:06:08 +00:00
|
|
|
{
|
|
|
|
my $rc = xCAT::Utils->startService("conserver");
|
|
|
|
if ($rc != 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2009-03-02 14:27:10 +00:00
|
|
|
}
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_DHCP
|
|
|
|
|
|
|
|
Sets up DHCP services
|
2013-02-28 21:06:08 +00:00
|
|
|
If on the Management node, just check if running and if not start it.
|
|
|
|
On Service nodes do full setup based on site.disjointdhcps setting
|
2009-03-02 14:27:10 +00:00
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_DHCP
|
|
|
|
{
|
|
|
|
my ($nodename) = @_;
|
|
|
|
my $rc = 0;
|
|
|
|
my $cmd;
|
2011-08-31 11:54:27 +00:00
|
|
|
my $snonly = 0;
|
2013-02-28 21:06:08 +00:00
|
|
|
# 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");
|
|
|
|
if ($rc != 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-31 11:54:27 +00:00
|
|
|
# read the disjointdhcps attribute to determine if we will setup
|
|
|
|
# dhcp for all nodes or just for the nodes service by this service node
|
2012-08-09 04:07:40 +00:00
|
|
|
my @hs = xCAT::TableUtils->get_site_attribute("disjointdhcps");
|
2012-05-18 08:49:11 +00:00
|
|
|
my $tmp = $hs[0];
|
|
|
|
if(defined($tmp)) {
|
|
|
|
$snonly = $tmp;
|
2011-08-31 11:54:27 +00:00
|
|
|
}
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
# run makedhcp
|
2009-04-24 16:47:23 +00:00
|
|
|
my $XCATROOT = "/opt/xcat"; # default
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
if ($ENV{'XCATROOT'})
|
|
|
|
{
|
|
|
|
$XCATROOT = $ENV{'XCATROOT'};
|
|
|
|
}
|
|
|
|
my $cmdref;
|
|
|
|
$cmdref->{command}->[0] = "makedhcp";
|
2011-08-31 11:54:27 +00:00
|
|
|
$cmdref->{arg}->[0] = "-n";
|
2009-03-02 14:27:10 +00:00
|
|
|
$cmdref->{cwd}->[0] = "/opt/xcat/sbin";
|
2010-03-29 16:33:43 +00:00
|
|
|
no strict "refs";
|
2009-03-02 14:27:10 +00:00
|
|
|
my $modname = "dhcp";
|
|
|
|
${"xCAT_plugin::" . $modname . "::"}{process_request}
|
|
|
|
->($cmdref, \&xCAT::Client::handle_response);
|
|
|
|
|
2011-10-06 17:45:08 +00:00
|
|
|
my $distro = xCAT::Utils->osver();
|
|
|
|
my $serv = "dhcpd";
|
2013-01-07 03:26:25 +00:00
|
|
|
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
|
|
|
|
$serv = "isc-dhcp-server";
|
2011-10-06 17:45:08 +00:00
|
|
|
}
|
2011-08-15 00:30:40 +00:00
|
|
|
|
|
|
|
my $rc = xCAT::Utils->startService($serv);
|
2009-03-02 14:27:10 +00:00
|
|
|
if ($rc != 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2011-08-31 11:54:27 +00:00
|
|
|
|
|
|
|
# setup DHCP
|
|
|
|
#
|
2013-11-06 09:28:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
# clean up $::opt_n which set by last makedhcp context and conlicts with -a below.
|
|
|
|
undef $::opt_n;
|
|
|
|
|
|
|
|
|
2009-03-02 14:27:10 +00:00
|
|
|
my $modname = "dhcp";
|
2011-08-31 11:54:27 +00:00
|
|
|
if ($snonly != 1) { # setup dhcp for all nodes
|
|
|
|
$cmdref;
|
|
|
|
$cmdref->{command}->[0] = "makedhcp";
|
|
|
|
$cmdref->{arg}->[0] = "-a";
|
|
|
|
$cmdref->{cwd}->[0] = "/opt/xcat/sbin";
|
|
|
|
|
|
|
|
} else { # setup dhcp just for the nodes owned by the SN
|
|
|
|
# determine my name
|
|
|
|
# get servicenodes and their nodes
|
|
|
|
# find the list of nodes serviced
|
2012-08-09 04:07:40 +00:00
|
|
|
my @hostinfo=xCAT::NetworkUtils->determinehostname();
|
|
|
|
my $sn_hash =xCAT::ServiceNodeUtils->getSNandNodes();
|
2011-08-31 11:54:27 +00:00
|
|
|
my @nodes;
|
|
|
|
my %iphash=();
|
|
|
|
my $snkey;
|
|
|
|
$cmdref;
|
|
|
|
foreach $snkey (keys %$sn_hash) { # find the service node
|
|
|
|
if (grep(/$snkey/, @hostinfo)) {
|
|
|
|
push @nodes, @{$sn_hash->{$snkey}};
|
|
|
|
$cmdref->{node} = $sn_hash->{$snkey};
|
|
|
|
$cmdref->{'_xcatdest'} = $snkey;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (@nodes) {
|
|
|
|
my $nodelist;
|
|
|
|
foreach my $n (@nodes) {
|
|
|
|
$nodelist .= $n;
|
|
|
|
$nodelist .= ",";
|
|
|
|
}
|
|
|
|
chop $nodelist;
|
|
|
|
$cmdref->{arg}->[0] = ();
|
|
|
|
$cmdref->{command}->[0] = "makedhcp";
|
|
|
|
$cmdref->{noderange}->[0] = "$nodelist";
|
|
|
|
$cmdref->{cwd}->[0] = "/opt/xcat/sbin";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
${"xCAT_plugin::" . $modname . "::"}{process_request}
|
|
|
|
->($cmdref, \&xCAT::Client::handle_response);
|
2009-03-02 14:27:10 +00:00
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_FTP
|
|
|
|
|
2012-02-20 21:52:34 +00:00
|
|
|
Sets up FTP services (vsftp)
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_FTP
|
|
|
|
{
|
|
|
|
my $rc = 0;
|
|
|
|
my $cmd;
|
2009-04-24 16:47:23 +00:00
|
|
|
my $XCATROOT = "/opt/xcat"; # default
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
if ($ENV{'XCATROOT'})
|
|
|
|
{
|
|
|
|
$XCATROOT = $ENV{'XCATROOT'};
|
|
|
|
}
|
|
|
|
|
|
|
|
# change ftp user id home directory to installdir
|
|
|
|
# link installdir
|
|
|
|
# restart the daemon
|
2012-08-09 04:07:40 +00:00
|
|
|
my $installdir = xCAT::TableUtils->getInstallDir();
|
2010-03-29 16:33:43 +00:00
|
|
|
if (!(-e $installdir)) # make it
|
2009-03-02 14:27:10 +00:00
|
|
|
{
|
|
|
|
mkpath($installdir);
|
|
|
|
}
|
2010-03-08 18:22:24 +00:00
|
|
|
$cmd = "usermod -d $installdir ftp 2>&1";
|
2009-03-02 14:27:10 +00:00
|
|
|
my $outref = xCAT::Utils->runcmd($cmd, 0);
|
|
|
|
if ($::RUNCMD_RC)
|
|
|
|
{
|
|
|
|
|
|
|
|
xCAT::MsgUtils->message("S", "Error from command:$cmd");
|
|
|
|
}
|
|
|
|
|
2012-02-20 21:52:34 +00:00
|
|
|
# start ftp
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
my $rc = xCAT::Utils->startService("vsftpd");
|
|
|
|
if ($rc != 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_DNS
|
|
|
|
|
|
|
|
Sets up Domain Name service
|
|
|
|
http://www.adminschoice.com/docs/domain_name_service.htm#Introduction
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_DNS
|
|
|
|
{
|
|
|
|
|
2010-04-07 11:13:42 +00:00
|
|
|
my $XCATROOT = "/opt/xcat"; # default
|
|
|
|
|
|
|
|
if ($ENV{'XCATROOT'})
|
|
|
|
{
|
|
|
|
$XCATROOT = $ENV{'XCATROOT'};
|
|
|
|
}
|
2010-04-21 13:02:22 +00:00
|
|
|
|
2009-03-02 14:27:10 +00:00
|
|
|
# setup the named.conf file
|
2010-04-07 11:13:42 +00:00
|
|
|
system("$XCATROOT/sbin/makenamed.conf");
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
# turn DNS on
|
2011-10-06 17:45:08 +00:00
|
|
|
|
|
|
|
my $distro = xCAT::Utils->osver();
|
|
|
|
my $serv = "named";
|
2013-01-07 03:26:25 +00:00
|
|
|
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
|
2011-10-06 17:45:08 +00:00
|
|
|
$serv = "bind9";
|
|
|
|
}
|
|
|
|
|
2011-08-15 00:30:40 +00:00
|
|
|
my $rc = xCAT::Utils->startService($serv);
|
2009-03-02 14:27:10 +00:00
|
|
|
if ($rc != 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-02-21 02:04:35 +00:00
|
|
|
# start named on boot
|
|
|
|
if (xCAT::Utils->isAIX())
|
|
|
|
{
|
|
|
|
#/etc/inittab
|
|
|
|
my $cmd = "/usr/sbin/lsitab named > /dev/null 2>&1";
|
|
|
|
my $rc = system("$cmd") >>8;
|
|
|
|
if ($rc != 0)
|
|
|
|
{
|
|
|
|
#add new entry
|
|
|
|
my $mkcmd = qq~/usr/sbin/mkitab "named:2:once:/usr/sbin/named > /dev/console 2>&1"~;
|
|
|
|
system("$mkcmd");
|
|
|
|
xCAT::MsgUtils->message("SI", " named has been enabled on boot.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#chkconfig
|
|
|
|
my $cmd = "/sbin/chkconfig $serv on";
|
|
|
|
my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
|
|
|
if ($::RUNCMD_RC != 0)
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message("SE", " Error: Could not enable $serv.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message("SI", " $serv has been enabled on boot.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-02 14:27:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_LDAP
|
|
|
|
|
|
|
|
Sets up LDAP
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_LDAP
|
|
|
|
{
|
|
|
|
|
|
|
|
my $rc = xCAT::Utils->startService("ldap");
|
|
|
|
if ($rc != 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_NFS
|
|
|
|
|
|
|
|
Sets up NFS services on Service Node for AIX and Linux
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_NFS
|
|
|
|
{
|
|
|
|
my ($nodename) = @_;
|
|
|
|
my $rc = 0;
|
|
|
|
|
|
|
|
# make sure nfs is restarted
|
|
|
|
my $rc = 0;
|
|
|
|
if (xCAT::Utils->isLinux())
|
|
|
|
{
|
2010-03-29 16:33:43 +00:00
|
|
|
my $os = xCAT::Utils->osver();
|
|
|
|
if ($os =~ /sles.*/)
|
|
|
|
{
|
|
|
|
$rc = xCAT::Utils->startService("nfs");
|
|
|
|
$rc = xCAT::Utils->startService("nfsserver");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$rc = xCAT::Utils->startService("nfs");
|
|
|
|
}
|
2009-03-02 14:27:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ #AIX
|
|
|
|
$rc = xCAT::Utils->startService("nfsd");
|
|
|
|
}
|
|
|
|
if ($rc != 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_NTPsn
|
|
|
|
|
|
|
|
Sets up NTP services on service node
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_NTPsn
|
|
|
|
{
|
|
|
|
my ($nodename) = @_;
|
|
|
|
my $rc = 0;
|
|
|
|
my $cmd;
|
|
|
|
my $master;
|
|
|
|
my $os;
|
|
|
|
my $arch;
|
|
|
|
my $ntpcfg = "/etc/ntp.conf";
|
|
|
|
|
|
|
|
# read DB for nodeinfo
|
2012-08-09 04:07:40 +00:00
|
|
|
my $retdata = xCAT::ServiceNodeUtils->readSNInfo($nodename);
|
2009-03-02 14:27:10 +00:00
|
|
|
$master = $retdata->{'master'};
|
|
|
|
$os = $retdata->{'os'};
|
|
|
|
$arch = $retdata->{'arch'};
|
|
|
|
if (!($arch))
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", " Error reading service node info.");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# backup the existing config file
|
|
|
|
$rc = &backup_NTPconf();
|
|
|
|
if ($rc == 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
# create config file
|
|
|
|
open(CFGFILE, ">$ntpcfg")
|
|
|
|
or xCAT::MsgUtils->message('SE',
|
2010-03-29 16:33:43 +00:00
|
|
|
"Cannot open $ntpcfg for NTP update. \n");
|
2009-03-02 14:27:10 +00:00
|
|
|
print CFGFILE "server ";
|
|
|
|
print CFGFILE $master;
|
|
|
|
print CFGFILE "\n";
|
|
|
|
print CFGFILE "driftfile /var/lib/ntp/drift\n";
|
|
|
|
print CFGFILE "restrict 127.0.0.1\n";
|
|
|
|
close CFGFILE;
|
|
|
|
|
|
|
|
$rc = &start_NTP(); # restart ntp
|
|
|
|
}
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_NTPmn
|
|
|
|
|
|
|
|
Sets up NTP services on Management Node
|
|
|
|
Get ntpservers from site table. If they do not exist, warn cannot setup NTP
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_NTPmn
|
|
|
|
{
|
|
|
|
my $rc = 0;
|
|
|
|
my $ntpcfg = "/etc/ntp.conf";
|
|
|
|
|
|
|
|
# get timeservers from site table
|
2012-08-09 04:07:40 +00:00
|
|
|
my @ntpservers = xCAT::TableUtils->get_site_attribute("ntpservers");
|
2009-03-02 14:27:10 +00:00
|
|
|
if ($ntpservers[0])
|
|
|
|
{
|
|
|
|
|
|
|
|
# backup the existing config file
|
|
|
|
$rc = &backup_NTPconf();
|
|
|
|
if ($rc == 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
# add server names
|
|
|
|
open(CFGFILE, ">$ntpcfg")
|
|
|
|
or xCAT::MsgUtils->message('SE',
|
2010-03-29 16:33:43 +00:00
|
|
|
"Cannot open $ntpcfg for NTP update. \n");
|
2009-03-02 14:27:10 +00:00
|
|
|
my @servers = split ',', $ntpservers[0];
|
|
|
|
foreach my $addr (@servers)
|
|
|
|
{
|
|
|
|
print CFGFILE "server ";
|
|
|
|
print CFGFILE $addr;
|
|
|
|
print CFGFILE "\n";
|
|
|
|
}
|
|
|
|
print CFGFILE "driftfile /var/lib/ntp/drift\n";
|
|
|
|
print CFGFILE "restrict 127.0.0.1\n";
|
|
|
|
close CFGFILE;
|
|
|
|
|
|
|
|
$rc = &start_NTP(); # restart ntp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ # no servers defined
|
|
|
|
xCAT::MsgUtils->message(
|
|
|
|
"S",
|
|
|
|
"No NTP servers defined in the ntpservers attribute in the site table.\n"
|
|
|
|
);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 start_NTP
|
|
|
|
|
|
|
|
Starts daemon
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub start_NTP
|
|
|
|
{
|
|
|
|
|
|
|
|
my $rc = xCAT::Utils->startService("ntpd");
|
|
|
|
if ($rc != 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 backup_NTPconf
|
|
|
|
|
|
|
|
backup configuration
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub backup_NTPconf
|
|
|
|
{
|
|
|
|
my $ntpcfg = "/etc/ntp.conf";
|
|
|
|
my $ntpcfgbackup = "/etc/ntp.conf.orig";
|
|
|
|
my $ntpxcatcfgbackup = "/etc/ntp.conf.xcatbackup";
|
|
|
|
if (!-e $ntpcfgbackup)
|
|
|
|
{ # if original backup does not already exist
|
|
|
|
my $cmd = "mv $ntpcfg $ntpcfgbackup";
|
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message("S", "Error from command:$cmd");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ # backup xcat cfg
|
|
|
|
my $cmd = "mv $ntpcfg $ntpxcatcfgbackup";
|
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message("S", "Error from command:$cmd");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_SSH
|
|
|
|
|
|
|
|
Sets up SSH default configuration for root
|
|
|
|
Turns strict host checking off
|
|
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_SSH
|
|
|
|
{
|
|
|
|
|
|
|
|
my $configfile;
|
|
|
|
my $cmd;
|
|
|
|
my $configinfo;
|
|
|
|
my $sshdir;
|
|
|
|
my $cmd;
|
|
|
|
|
|
|
|
# build the $HOMEROOT/.ssh/config
|
|
|
|
if (xCAT::Utils->isLinux())
|
|
|
|
{
|
|
|
|
$configfile = "/root/.ssh/config";
|
|
|
|
$sshdir = "/root/.ssh";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ #AIX
|
|
|
|
$configfile = "/.ssh/config";
|
|
|
|
$sshdir = "/.ssh";
|
|
|
|
}
|
|
|
|
if (!(-e $sshdir))
|
|
|
|
{ # directory does not exits
|
|
|
|
mkdir($sshdir, 0700);
|
|
|
|
}
|
|
|
|
$configinfo = "StrictHostKeyChecking no";
|
|
|
|
|
|
|
|
if (-e $configfile)
|
|
|
|
{
|
|
|
|
$cmd = "grep StrictHostKeyChecking $configfile";
|
|
|
|
xCAT::Utils->runcmd($cmd, -1);
|
|
|
|
if ($::RUNCMD_RC != 0)
|
|
|
|
{ # not there
|
|
|
|
$cmd = "echo $configinfo >> $configfile";
|
|
|
|
my @output = xCAT::Utils->runcmd($cmd, 0);
|
|
|
|
if ($::RUNCMD_RC != 0)
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", "Error on $cmd, @output");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else # file does not exist
|
|
|
|
{
|
|
|
|
$cmd = "echo $configinfo >> $configfile";
|
|
|
|
my @output = xCAT::Utils->runcmd($cmd, 0);
|
|
|
|
if ($::RUNCMD_RC != 0)
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", "Error on $cmd, @output");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chmod 0600, $configfile;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_TFTP
|
|
|
|
|
2013-02-28 21:06:08 +00:00
|
|
|
Sets up TFTP services
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_TFTP
|
|
|
|
{
|
2009-03-28 05:57:08 +00:00
|
|
|
my ($nodename, $doreq) = @_;
|
|
|
|
|
2010-03-29 16:33:43 +00:00
|
|
|
my $rc = 0;
|
2009-03-02 14:27:10 +00:00
|
|
|
my $cmd;
|
|
|
|
my $master;
|
|
|
|
my $os;
|
|
|
|
my $arch;
|
2010-03-29 16:33:43 +00:00
|
|
|
my $XCATROOT = "/opt/xcat"; # default
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
if ($ENV{'XCATROOT'})
|
|
|
|
{
|
|
|
|
$XCATROOT = $ENV{'XCATROOT'};
|
|
|
|
}
|
|
|
|
|
|
|
|
# read DB for nodeinfo
|
2012-08-09 04:07:40 +00:00
|
|
|
my $retdata = xCAT::ServiceNodeUtils->readSNInfo($nodename);
|
2013-04-05 20:51:06 +00:00
|
|
|
if (not ref $retdata)
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", " Error reading service node arch.");
|
|
|
|
return 1;
|
|
|
|
}
|
2009-03-02 14:27:10 +00:00
|
|
|
$master = $retdata->{'master'};
|
|
|
|
$os = $retdata->{'os'};
|
|
|
|
$arch = $retdata->{'arch'};
|
|
|
|
if (!($arch))
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", " Error reading service node arch.");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-11-30 09:37:44 +00:00
|
|
|
# check to see if tftp is installed
|
2009-03-02 14:27:10 +00:00
|
|
|
$cmd = "/usr/sbin/in.tftpd -V";
|
|
|
|
my @output = xCAT::Utils->runcmd($cmd, -1);
|
|
|
|
if ($::RUNCMD_RC != 0)
|
|
|
|
{ # not installed
|
2010-04-21 13:02:22 +00:00
|
|
|
xCAT::MsgUtils->message("S", "atftp is not installed, ok for Power5");
|
2009-03-02 14:27:10 +00:00
|
|
|
}
|
2009-04-24 16:47:23 +00:00
|
|
|
my $tftpdir;
|
2010-04-21 13:02:22 +00:00
|
|
|
my $mountdirectory = "1"; # default to mount tftpdir
|
|
|
|
my $tftphost = $master; # default to master
|
|
|
|
# read sharedtftp attribute from site table, if exist
|
2012-05-18 08:49:11 +00:00
|
|
|
#my $stab = xCAT::Table->new('site');
|
|
|
|
#my $sharedtftp = $stab->getAttribs({key => 'sharedtftp'}, 'value');
|
2012-08-09 04:07:40 +00:00
|
|
|
my @ss = xCAT::TableUtils->get_site_attribute("sharedtftp");
|
2012-05-18 08:49:11 +00:00
|
|
|
my $sharedtftp = $ss[0];
|
|
|
|
if ( defined($sharedtftp) )
|
2009-03-02 14:27:10 +00:00
|
|
|
{
|
|
|
|
|
2012-05-18 08:49:11 +00:00
|
|
|
$tftphost = $sharedtftp; # either hostname or yes/no
|
2010-04-21 13:02:22 +00:00
|
|
|
$mountdirectory = $tftphost;
|
|
|
|
$mountdirectory =~ tr/a-z/A-Z/; # convert to upper
|
|
|
|
if ( $mountdirectory ne "1"
|
|
|
|
&& $mountdirectory ne "YES"
|
|
|
|
&& $mountdirectory ne "0"
|
|
|
|
&& $mountdirectory ne "NO")
|
|
|
|
{ # then tftphost is hostname
|
|
|
|
# for the mount
|
|
|
|
$mountdirectory = "1"; # and we mount the directory
|
|
|
|
}
|
|
|
|
else
|
2009-03-12 19:48:52 +00:00
|
|
|
{
|
2010-04-21 13:02:22 +00:00
|
|
|
$tftphost = $master; # will mount master,if req
|
2009-03-12 19:48:52 +00:00
|
|
|
}
|
2010-03-29 16:33:43 +00:00
|
|
|
|
2010-04-21 13:02:22 +00:00
|
|
|
}
|
2012-05-18 08:49:11 +00:00
|
|
|
#$stab->close;
|
2010-04-21 13:02:22 +00:00
|
|
|
|
|
|
|
# read tftpdir directory from database
|
2012-08-09 04:07:40 +00:00
|
|
|
$tftpdir = xCAT::TableUtils->getTftpDir();
|
2010-04-21 13:02:22 +00:00
|
|
|
if (!(-e $tftpdir))
|
|
|
|
{
|
|
|
|
mkdir($tftpdir);
|
|
|
|
}
|
|
|
|
|
|
|
|
# if request to mount
|
|
|
|
if ($mountdirectory eq "1" || $mountdirectory eq "YES")
|
|
|
|
{
|
|
|
|
|
|
|
|
# check to see if tftp directory already mounted
|
|
|
|
my $mounted = xCAT::Utils->isMounted($tftpdir);
|
|
|
|
if ($mounted == 0) # not already mounted
|
|
|
|
{
|
|
|
|
|
|
|
|
# need to mount the directory
|
2011-10-24 09:44:22 +00:00
|
|
|
my $cmd;
|
2012-08-09 04:07:40 +00:00
|
|
|
my @nfsv4 = xCAT::TableUtils->get_site_attribute("useNFSv4onAIX");
|
2011-10-24 09:44:22 +00:00
|
|
|
if ($nfsv4[0] && ($nfsv4[0] =~ /1|Yes|yes|YES|Y|y/))
|
|
|
|
{
|
|
|
|
$cmd = " mount -o vers=4,rw,nolock $tftphost:$tftpdir $tftpdir";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$cmd = " mount -o rw,nolock $tftphost:$tftpdir $tftpdir";
|
|
|
|
}
|
2010-04-21 13:02:22 +00:00
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
|
|
|
{ # error
|
|
|
|
$rc = 1;
|
|
|
|
xCAT::MsgUtils->message("S", "Error $cmd");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ #if not mounting, have to regenerate....
|
|
|
|
my $cmdref;
|
2013-01-18 17:26:23 +00:00
|
|
|
# mknb is now run in xCATsn.spec
|
|
|
|
#use xCAT_plugin::mknb;
|
|
|
|
#for my $architecture ("ppc64", "x86", "x86_64")
|
|
|
|
#{
|
|
|
|
# unless (-d "$::XCATROOT/share/xcat/netboot/$architecture")
|
|
|
|
# {
|
|
|
|
# next;
|
|
|
|
# }
|
|
|
|
# $cmdref->{command}->[0] = "mknb";
|
|
|
|
# $cmdref->{arg}->[0] = $architecture;
|
|
|
|
# $doreq->($cmdref, \&xCAT::Client::handle_response);
|
|
|
|
#}
|
2009-03-02 14:27:10 +00:00
|
|
|
|
2010-04-21 13:02:22 +00:00
|
|
|
#now, run nodeset enact on
|
|
|
|
my $mactab = xCAT::Table->new('mac');
|
|
|
|
my $hmtab = xCAT::Table->new('noderes');
|
|
|
|
if ($mactab and $hmtab)
|
2009-03-02 14:27:10 +00:00
|
|
|
{
|
2010-04-21 13:02:22 +00:00
|
|
|
my @mentries = ($mactab->getAllNodeAttribs([qw(node mac)]));
|
2009-03-02 14:27:10 +00:00
|
|
|
|
2010-04-21 13:02:22 +00:00
|
|
|
#nodeset fails if no mac entry, filter on discovered nodes first
|
|
|
|
my %netmethods;
|
|
|
|
my @tnodes;
|
|
|
|
foreach (@mentries)
|
2009-03-12 19:48:52 +00:00
|
|
|
{
|
2010-04-21 13:02:22 +00:00
|
|
|
unless (defined $_->{mac}) { next; }
|
|
|
|
push @tnodes, $_->{node};
|
2009-03-02 14:27:10 +00:00
|
|
|
}
|
2010-04-21 13:02:22 +00:00
|
|
|
my %hmhash =
|
|
|
|
%{$hmtab->getNodesAttribs(\@tnodes, [qw(node netboot)])};
|
|
|
|
foreach (@tnodes)
|
2010-03-29 16:33:43 +00:00
|
|
|
{
|
2010-04-21 13:02:22 +00:00
|
|
|
if ($hmhash{$_}->[0]->{netboot})
|
2010-03-29 16:33:43 +00:00
|
|
|
{
|
2010-04-21 13:02:22 +00:00
|
|
|
push @{$netmethods{$hmhash{$_}->[0]->{netboot}}}, $_;
|
2009-04-09 13:21:02 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-21 13:02:22 +00:00
|
|
|
$cmdref->{command}->[0] = "nodeset";
|
|
|
|
$cmdref->{inittime}->[0] = "1";
|
|
|
|
$cmdref->{arg}->[0] = "enact";
|
|
|
|
$cmdref->{cwd}->[0] = "/opt/xcat/sbin";
|
|
|
|
my $plugins_dir = $::XCATROOT . '/lib/perl/xCAT_plugin';
|
|
|
|
foreach my $modname (keys %netmethods)
|
2010-03-29 16:33:43 +00:00
|
|
|
{
|
2010-04-21 13:02:22 +00:00
|
|
|
$cmdref->{node} = $netmethods{$modname};
|
|
|
|
$doreq->($cmdref, \&xCAT::Client::handle_response);
|
2009-03-28 04:25:03 +00:00
|
|
|
}
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2010-04-21 13:02:22 +00:00
|
|
|
|
2011-11-30 09:37:44 +00:00
|
|
|
# enable the tftp-hpa
|
2011-12-01 01:08:03 +00:00
|
|
|
$rc = enable_TFTPhpa();
|
2009-03-02 14:27:10 +00:00
|
|
|
|
|
|
|
if ($rc == 0)
|
|
|
|
{
|
|
|
|
|
2009-03-12 19:48:52 +00:00
|
|
|
if ($mountdirectory eq "1" || $mountdirectory eq "YES")
|
2009-03-02 14:27:10 +00:00
|
|
|
{
|
|
|
|
|
2009-03-12 19:48:52 +00:00
|
|
|
# update fstab so that it will restart on reboot
|
|
|
|
$cmd =
|
2010-04-21 13:02:22 +00:00
|
|
|
"fgrep \"$tftphost:$tftpdir $tftpdir nfs timeo=14,intr 1 2\" /etc/fstab";
|
2009-03-12 19:48:52 +00:00
|
|
|
xCAT::Utils->runcmd($cmd, -1);
|
|
|
|
if ($::RUNCMD_RC != 0) # not already there
|
|
|
|
{
|
|
|
|
|
2010-04-21 13:02:22 +00:00
|
|
|
`echo "$tftphost:$tftpdir $tftpdir nfs timeo=14,intr 1 2" >>/etc/fstab`;
|
2009-03-12 19:48:52 +00:00
|
|
|
}
|
2009-03-02 14:27:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $rc;
|
|
|
|
|
|
|
|
}
|
2009-06-09 01:16:04 +00:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_HTTP
|
|
|
|
|
|
|
|
Sets up HTTP services on Service Node for Linux
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_HTTP
|
|
|
|
{
|
|
|
|
my ($nodename) = @_;
|
|
|
|
my $rc = 0;
|
|
|
|
|
|
|
|
if (xCAT::Utils->isLinux())
|
|
|
|
{
|
|
|
|
my $os = xCAT::Utils->osver();
|
2010-03-29 16:33:43 +00:00
|
|
|
if ($os =~ /sles.*/)
|
|
|
|
{
|
|
|
|
$rc = xCAT::Utils->startService("apache2");
|
2009-06-09 01:16:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$rc = xCAT::Utils->startService("httpd");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
2011-11-30 09:37:44 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#=head3 enable_TFTPhpa
|
|
|
|
#
|
|
|
|
# Configure and enable the tftp-hpa in the xinetd.
|
|
|
|
#
|
|
|
|
#=cut
|
|
|
|
#
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub enable_TFTPhpa
|
|
|
|
{
|
2012-08-31 06:44:44 +00:00
|
|
|
# Check whether the tftp-hpa has been installed, the ubuntu tftpd-hpa configure file is under /etc/default
|
|
|
|
unless (-x "/usr/sbin/in.tftpd" and ( -e "/etc/xinetd.d/tftp" or -e "/etc/default/tftpd-hpa" )) {
|
2011-11-30 09:37:44 +00:00
|
|
|
xCAT::MsgUtils->message("S", "ERROR: The tftpd was not installed, enable the tftp failed.");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-12-30 07:36:58 +00:00
|
|
|
# kill the process of atftp if it's there
|
|
|
|
my @output = xCAT::Utils->runcmd("ps -ef | grep atftpd | grep -v grep", -1);
|
|
|
|
foreach my $ps (@output) {
|
|
|
|
$ps =~ s/^\s+//; # strip any leading spaces
|
|
|
|
my ($uid, $pid, $ppid, $desc) = split /\s+/, $ps;
|
|
|
|
system("kill -9 $pid >/dev/null 2>&1");
|
|
|
|
}
|
|
|
|
|
2011-11-30 09:37:44 +00:00
|
|
|
# read tftpdir directory from database
|
2012-08-09 04:07:40 +00:00
|
|
|
my $tftpdir = xCAT::TableUtils->getTftpDir();
|
2011-11-30 09:37:44 +00:00
|
|
|
if (!(-e $tftpdir)) {
|
|
|
|
mkdir($tftpdir);
|
|
|
|
}
|
|
|
|
|
|
|
|
# The location of tftp mapfile
|
|
|
|
my $mapfile = "/etc/tftpmapfile4xcat.conf";
|
|
|
|
if (! -e "$mapfile") {
|
|
|
|
if (! open (MAPFILE, ">$mapfile")) {
|
|
|
|
xCAT::MsgUtils->message("S", "ERROR: Cannot open $mapfile.");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
# replace the \ with /
|
|
|
|
print MAPFILE 'rg (\\\) \/';
|
|
|
|
close (MAPFILE);
|
|
|
|
}
|
|
|
|
|
2012-08-31 06:44:44 +00:00
|
|
|
my $distro = xCAT::Utils->osver();
|
2013-01-07 03:26:25 +00:00
|
|
|
if ($distro !~ /ubuntu.*/i && $distro !~ /debian.*/i ){
|
2012-08-31 06:44:44 +00:00
|
|
|
if (! open (FILE, "</etc/xinetd.d/tftp")) {
|
|
|
|
xCAT::MsgUtils->message("S", "ERROR: Cannot open /etc/xinetd.d/tftp.");
|
2011-11-30 09:37:44 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2012-08-31 06:44:44 +00:00
|
|
|
|
|
|
|
# The location of tftp mapfile
|
|
|
|
my $mapfile = "/etc/tftpmapfile4xcat.conf";
|
|
|
|
my $recfg = 0;
|
|
|
|
my @newcfgfile;
|
|
|
|
# Check whether need to reconfigure the /etc/xinetd.d/tftp
|
|
|
|
while (<FILE>) {
|
|
|
|
# check the configuration of 'server_args = -s /xx -m xx' entry
|
|
|
|
if (/^\s*server_args\s*=(.*)$/) {
|
|
|
|
my $cfg_args = $1;
|
|
|
|
# handle the -s option for the location of tftp root dir
|
|
|
|
if ($cfg_args =~ /-s\s+([^\s]*)/) {
|
|
|
|
my $cfgdir = $1;
|
|
|
|
$cfgdir =~ s/\$//;
|
|
|
|
$tftpdir =~ s/\$//;
|
|
|
|
# make sure the tftp dir should comes from the site.tftpdir
|
|
|
|
if ($cfgdir ne $tftpdir) {
|
|
|
|
$recfg = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# handle the -m option for the mapfile
|
|
|
|
if ($cfg_args !~ /-m\s+([^\s]*)/) {
|
|
|
|
$recfg = 1;
|
|
|
|
}
|
|
|
|
if ($recfg) {
|
|
|
|
# regenerate the entry for server_args
|
|
|
|
my $newcfg = $_;
|
|
|
|
$newcfg =~ s/=.*$/= -s $tftpdir -m $mapfile/;
|
|
|
|
push @newcfgfile, $newcfg;
|
|
|
|
} else {
|
|
|
|
push @newcfgfile, $_;
|
|
|
|
}
|
|
|
|
} elsif (/^\s*disable\s*=/ && !/^\s*disable\s*=\s*yes/) {
|
2012-09-14 12:40:18 +00:00
|
|
|
# disable the tftp by handling the entry 'disable = yes'
|
2012-08-31 06:44:44 +00:00
|
|
|
my $newcfg = $_;
|
|
|
|
$newcfg =~ s/=.*$/= yes/;
|
|
|
|
push @newcfgfile, $newcfg;
|
|
|
|
$recfg = 1;
|
|
|
|
} else {
|
|
|
|
push @newcfgfile, $_;
|
|
|
|
}
|
|
|
|
}
|
2011-11-30 09:37:44 +00:00
|
|
|
close (FILE);
|
2012-08-31 06:44:44 +00:00
|
|
|
|
|
|
|
# reconfigure the /etc/xinetd.d/tftp
|
|
|
|
if ($recfg) {
|
|
|
|
if (! open (FILE, ">/etc/xinetd.d/tftp")) {
|
|
|
|
xCAT::MsgUtils->message("S", "ERROR: Cannot open /etc/xinetd.d/tftp");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
print FILE @newcfgfile;
|
|
|
|
close (FILE);
|
|
|
|
my @output = xCAT::Utils->runcmd("service xinetd status", -1);
|
|
|
|
if ($::RUNCMD_RC == 0) {
|
2012-03-15 15:19:40 +00:00
|
|
|
if (grep(/running/, @output))
|
|
|
|
{
|
2012-08-31 06:44:44 +00:00
|
|
|
print ' '; # indent service output to separate it from the xcatd service output
|
|
|
|
system "service xinetd stop";
|
|
|
|
if ($? > 0)
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S",
|
2012-03-15 15:19:40 +00:00
|
|
|
"Error on command: service xinetd stop\n");
|
2012-08-31 06:44:44 +00:00
|
|
|
}
|
|
|
|
system "service xinetd start";
|
|
|
|
if ($? > 0)
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S",
|
2012-03-15 15:19:40 +00:00
|
|
|
"Error on command: service xinetd start\n");
|
2012-08-31 06:44:44 +00:00
|
|
|
}
|
2012-03-15 15:19:40 +00:00
|
|
|
}
|
2012-08-31 06:44:44 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-30 09:37:44 +00:00
|
|
|
}
|
2012-09-14 12:40:18 +00:00
|
|
|
|
|
|
|
# get the version of TCP/IP protocol
|
2012-03-21 16:01:15 +00:00
|
|
|
my $protocols;
|
|
|
|
my $v4only="-4 ";
|
2012-12-05 02:58:48 +00:00
|
|
|
if (xCAT::Utils->osver() =~ /^sle[sc]10/) {
|
|
|
|
$v4only = "";
|
|
|
|
}
|
|
|
|
|
2012-03-21 16:01:15 +00:00
|
|
|
open($protocols,"<","/proc/net/protocols");
|
|
|
|
if ($protocols) {
|
|
|
|
my $line;
|
|
|
|
while ($line = <$protocols>) {
|
|
|
|
if ($line =~ /^TCPv6/) {
|
|
|
|
$v4only="";
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$v4only="";
|
|
|
|
}
|
2012-09-14 12:40:18 +00:00
|
|
|
|
|
|
|
# get the tftpflags which set by customer
|
2012-09-16 10:23:47 +00:00
|
|
|
my $tftpflags = xCAT::TableUtils->get_site_attribute("tftpflags");
|
2012-09-14 12:40:18 +00:00
|
|
|
my $startcmd = "/usr/sbin/in.tftpd $v4only -v -l -s $tftpdir -m /etc/tftpmapfile4xcat.conf";
|
|
|
|
if ($tftpflags) {
|
|
|
|
$startcmd = "/usr/sbin/in.tftpd $v4only $tftpflags";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 15:46:54 +00:00
|
|
|
if (-x "/usr/sbin/in.tftpd") {
|
|
|
|
system("killall in.tftpd"); #xinetd can leave behind blocking tftp servers even if it won't start new ones
|
2012-10-15 01:51:15 +00:00
|
|
|
if ($distro =~ /ubuntu.*/i){
|
2012-10-30 12:46:45 +00:00
|
|
|
sleep 1;
|
|
|
|
my @checkproc=`ps axf|grep -v grep|grep in.tftpd`;
|
|
|
|
if (@checkproc){
|
|
|
|
system("stop tftpd-hpa");
|
|
|
|
}
|
2012-10-09 06:52:12 +00:00
|
|
|
}
|
2013-01-07 03:26:25 +00:00
|
|
|
|
|
|
|
if ($distro =~ /debian.*/i){
|
|
|
|
sleep 1;
|
|
|
|
my @checkproc=`ps axf|grep -v grep|grep in.tftpd`;
|
|
|
|
if (@checkproc){
|
|
|
|
system("service tftpd-hpa stop");
|
|
|
|
}
|
|
|
|
}
|
2012-10-15 01:51:15 +00:00
|
|
|
my @tftpprocs=`ps axf|grep -v grep|grep in.tftpd`;
|
2012-03-15 15:46:54 +00:00
|
|
|
while (@tftpprocs) {
|
|
|
|
sleep 0.1;
|
|
|
|
}
|
2012-09-14 12:40:18 +00:00
|
|
|
system("$startcmd");
|
2012-03-15 15:46:54 +00:00
|
|
|
}
|
2011-11-30 09:37:44 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-18 20:38:50 +00:00
|
|
|
|
2008-05-12 21:34:15 +00:00
|
|
|
1;
|