From 567d0a419c7a5442576d66226f6a457df1a7021a Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 30 Nov 2011 09:37:44 +0000 Subject: [PATCH] code drop for the item that replace the atftp-xcat with tftp/tftp-server from distro git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11077 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/AAsn.pm | 111 +++++++++++++++++++++++++-- xCAT/xCAT.spec | 4 +- xCATsn/xCATsn.spec | 4 +- 3 files changed, 109 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index 173f870e2..990e8ec3b 100644 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -276,6 +276,8 @@ sub init_plugin if ((!$tmp[0]) || ($tmp[0] !~ /0|NO|No|no|N|n/ )) { $rc = &setup_FTP(); # setup FTP } + #enable the tftp-hpa for MN + enable_TFTPhpa(); } } return $rc; @@ -1138,7 +1140,7 @@ sub setup_TFTP return 1; } - # check to see if atftp is installed + # check to see if tftp is installed $cmd = "/usr/sbin/in.tftpd -V"; my @output = xCAT::Utils->runcmd($cmd, -1); if ($::RUNCMD_RC != 0) @@ -1262,13 +1264,8 @@ sub setup_TFTP } } - # start atftp - my $rc = xCAT::Utils->startService("tftpd"); - if ($rc != 0) - { - xCAT::MsgUtils->message("S", " Failed to start tftpd."); - return 1; - } + # enable the tftp-hpa + enable_TFTPhpa(); if ($rc == 0) { @@ -1321,5 +1318,103 @@ sub setup_HTTP return $rc; } +#----------------------------------------------------------------------------- +# +#=head3 enable_TFTPhpa +# +# Configure and enable the tftp-hpa in the xinetd. +# +#=cut +# +#----------------------------------------------------------------------------- +sub enable_TFTPhpa +{ + # Check whether the tftp-hpa has been installed + if (! -e "/etc/xinetd.d/tftp") { + xCAT::MsgUtils->message("S", "ERROR: The tftpd was not installed, enable the tftp failed."); + return 1; + } + + # read tftpdir directory from database + my $tftpdir = xCAT::Utils->getTftpDir(); + if (!(-e $tftpdir)) { + mkdir($tftpdir); + } + + if (! open (FILE, "message("S", "ERROR: Cannot open /etc/xinetd.d/tftp."); + return 1; + } + + # 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 () { + if (/^\s*server_args\s*=(.*)$/) { + my $cfg_args = $1; + if ($cfg_args =~ /-s\s+([^\s]*)/) { + my $cfgdir = $1; + $cfgdir =~ s/\$//; + $tftpdir =~ s/\$//; + if ($cfgdir ne $tftpdir) { + $recfg = 1; + } + } + if ($cfg_args !~ /-m\s+([^\s]*)/) { + $recfg = 1; + } + if ($recfg) { + my $newcfg = $_; + $newcfg =~ s/=.*$/= -s $tftpdir -m $mapfile/; + push @newcfgfile, $newcfg; + } else { + push @newcfgfile, $_; + } + } elsif (/^\s*disable\s*=/ && !/^\s*disable\s*=\s*no/) { + my $newcfg = $_; + $newcfg =~ s/=.*$/= no/; + push @newcfgfile, $newcfg; + $recfg = 1; + } else { + push @newcfgfile, $_; + } + } + close (FILE); + + # recreate the mapfile + 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); + } + + # 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); + + # start xinetd + my $rc = xCAT::Utils->startService("xinetd"); + if ($rc != 0) + { + xCAT::MsgUtils->message("S", " Failed to start xinetd."); + return 1; + } + xCAT::MsgUtils->message("S", " The tftp-hpa has been reconfigured."); + } + + return 0; +} + 1; diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 4f03f8854..a96e021c2 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -29,7 +29,9 @@ Requires: dhcp httpd nfs-utils expect nmap fping bind perl-XML-Parser vsftpd # No additional requires for zLinux right now %else # yaboot-xcat is pulled in so any MN can manage ppc nodes -Requires: atftp-xcat conserver-xcat yaboot-xcat perl-Net-Telnet +Obsoletes: atftp-xcat +Requires: /etc/xinetd.d/tftp +Requires: conserver-xcat yaboot-xcat perl-Net-Telnet %endif %ifarch ppc64 Requires: perl-IO-Stty diff --git a/xCATsn/xCATsn.spec b/xCATsn/xCATsn.spec index c2ef827ab..fbb642412 100644 --- a/xCATsn/xCATsn.spec +++ b/xCATsn/xCATsn.spec @@ -32,7 +32,9 @@ Requires: perl-IO-Stty %ifarch s390x # No additional requires for zLinux right now %else -Requires: atftp-xcat conserver-xcat yaboot-xcat perl-Net-Telnet +Obsoletes: atftp-xcat +Requires: /etc/xinetd.d/tftp +Requires: conserver-xcat yaboot-xcat perl-Net-Telnet %endif %endif