Switch to setting up atftp
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@607 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
68ebcbe429
commit
383e2c5eed
@ -19,9 +19,8 @@ use Getopt::Long;
|
||||
|
||||
=head3 handled_commands
|
||||
|
||||
Check to see if on a Service Node
|
||||
Check database to see if this node is a TFTP server
|
||||
Call setup_TFTP
|
||||
This runs on Service Node and on Management Server
|
||||
Call setup_TFTP (actually setting up atftp)
|
||||
|
||||
=cut
|
||||
|
||||
@ -29,24 +28,30 @@ Call setup_TFTP
|
||||
|
||||
sub handled_commands
|
||||
{
|
||||
my $rc = 0;
|
||||
my @nodeinfo = xCAT::Utils->determinehostname;
|
||||
my $nodename = $nodeinfo[0];
|
||||
my $nodeipaddr = $nodeinfo[1];
|
||||
my $service = "tftpserver";
|
||||
my $rc = 0;
|
||||
my $setupTFTP = 1;
|
||||
|
||||
# setup atftp
|
||||
if (xCAT::Utils->isServiceNode())
|
||||
{
|
||||
my @nodeinfo = xCAT::Utils->determinehostname;
|
||||
my $nodename = $nodeinfo[0];
|
||||
my $nodeipaddr = $nodeinfo[1];
|
||||
my $service = "tftpserver";
|
||||
|
||||
# check to see if service required
|
||||
$rc = xCAT::Utils->isServiceReq($nodename, $service, $nodeipaddr);
|
||||
if ($rc == 1)
|
||||
if ($rc != 1) # service not required
|
||||
{
|
||||
|
||||
# service needed on this Service Node
|
||||
$rc = &setup_TFTP($nodename); # setup TFTP
|
||||
if ($rc == 0)
|
||||
{
|
||||
xCAT::Utils->update_xCATSN($service);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
$rc = &setup_TFTP($nodename); # setup TFTP
|
||||
if ($rc == 0)
|
||||
{
|
||||
if (xCAT::Utils->isServiceNode())
|
||||
{
|
||||
xCAT::Utils->update_xCATSN($service);
|
||||
}
|
||||
}
|
||||
return $rc;
|
||||
@ -70,11 +75,7 @@ sub process_request
|
||||
|
||||
=head3 setup_TFTP
|
||||
|
||||
Sets up TFTP services
|
||||
Check to see installed
|
||||
Enables in /etc/xinetd.d/tftp
|
||||
Makes /tftpboot directory
|
||||
Starts with xinetd
|
||||
Sets up TFTP services (using atftp)
|
||||
|
||||
=cut
|
||||
|
||||
@ -82,56 +83,116 @@ sub process_request
|
||||
sub setup_TFTP
|
||||
{
|
||||
my ($nodename) = @_;
|
||||
my $tftpdir = "/tftpboot"; # default
|
||||
my $msg = "Install: Setup TFTPD";
|
||||
my $rc = 0;
|
||||
my $tftpdir = "/tftpboot"; # default
|
||||
my $cmd;
|
||||
my $master;
|
||||
my $os;
|
||||
my $arch;
|
||||
$XCATROOT = "/opt/xcat"; # default
|
||||
|
||||
# check to see if tftp is installed
|
||||
if ($ENV{'XCATROOT'})
|
||||
{
|
||||
$XCATROOT = $ENV{'XCATROOT'};
|
||||
}
|
||||
|
||||
my $cmd = "/usr/sbin/in.tftpd -V";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if (xCAT::Utils->isServiceNode())
|
||||
{
|
||||
|
||||
# read DB for nodeinfo
|
||||
my $retdata = xCAT::Utils->readSNInfo($nodename);
|
||||
$master = $retdata->{'master'};
|
||||
$os = $retdata->{'os'};
|
||||
$arch = $retdata->{'arch'};
|
||||
if (!($arch))
|
||||
{ # error
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ # on MS
|
||||
if (-e "/etc/SuSE-release")
|
||||
{
|
||||
$os = "su";
|
||||
}
|
||||
else
|
||||
{
|
||||
$os = "rh";
|
||||
}
|
||||
}
|
||||
|
||||
# check to see if atftp is installed
|
||||
$cmd = "/usr/sbin/in.tftpd -V";
|
||||
my @output = xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{ # not installed
|
||||
xCAT::MsgUtils->message("S", "tftp is not installed");
|
||||
{ # not installed
|
||||
xCAT::MsgUtils->message("S", "atftp is not installed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
# read tftp directory from database, if it exists
|
||||
my @tftpdir1 = xCAT::Utils->get_site_attribute("tftpdir");
|
||||
if ($tftpdir1[0])
|
||||
{
|
||||
$tftpdir = $tftpdir1[0];
|
||||
}
|
||||
if (!(-e $tftpdir))
|
||||
{ # if it does not already exist
|
||||
mkdir($tftpdir); # creates the tftp directory
|
||||
}
|
||||
if (xCAT::Utils->isLinux())
|
||||
if ($output[0] =~ "atftp") # it is atftp
|
||||
{
|
||||
|
||||
# enable tftp
|
||||
|
||||
my $cmd = "chkconfig tftp on";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
# read tftp directory from database, if it exists
|
||||
my @tftpdir1 = xCAT::Utils->get_site_attribute("tftpdir");
|
||||
if ($tftpdir1[0])
|
||||
{
|
||||
xCAT::MsgUtils->message("S", "Error running $cmd");
|
||||
return 1;
|
||||
$tftpdir = $tftpdir1[0];
|
||||
}
|
||||
my $cmd = "/etc/rc.d/init.d/xinetd restart";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
mkdir($tftpdir);
|
||||
if (xCAT::Utils->isServiceNode())
|
||||
{
|
||||
xCAT::MsgUtils->message("S", "Error running $cmd");
|
||||
return 1;
|
||||
$cmd =
|
||||
"fgrep \"$master:$tftpdir $tftpdir nfs timeo=14,intr 1 2\" /etc/fstab";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) # not already there
|
||||
{
|
||||
|
||||
`echo "$master:$tftpdir $tftpdir nfs timeo=14,intr 1 2" >>/etc/fstab`;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else # AIX
|
||||
{
|
||||
if ($os =~ /su|sl/i) # sles
|
||||
{
|
||||
|
||||
# TBD AIX tftp may already be enabled
|
||||
# setup atftp
|
||||
|
||||
$cmd = "service tftpd restart";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
xCAT::MsgUtils->message("S", "Error from command:$cmd");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($os =~ /rh|fe/i) # redhat/fedora
|
||||
{
|
||||
|
||||
$cmd = "service tftpd restart";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
xCAT::MsgUtils->message("S", "Error from command:$cmd");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($os =~ /AIX/i)
|
||||
{
|
||||
|
||||
# TBD AIX
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
else
|
||||
{ # no ATFTP
|
||||
xCAT::MsgUtils->message("S", "atftp is not installed");
|
||||
return 1;
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user