tftp start on ubuntu
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13679 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
01461cdc50
commit
27542f3df8
@ -1366,8 +1366,8 @@ sub setup_HTTP
|
||||
#-----------------------------------------------------------------------------
|
||||
sub enable_TFTPhpa
|
||||
{
|
||||
# Check whether the tftp-hpa has been installed
|
||||
unless (-x "/usr/sbin/in.tftpd" and -e "/etc/xinetd.d/tftp") {
|
||||
# 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" )) {
|
||||
xCAT::MsgUtils->message("S", "ERROR: The tftpd was not installed, enable the tftp failed.");
|
||||
return 1;
|
||||
}
|
||||
@ -1386,55 +1386,8 @@ sub enable_TFTPhpa
|
||||
mkdir($tftpdir);
|
||||
}
|
||||
|
||||
if (! open (FILE, "</etc/xinetd.d/tftp")) {
|
||||
xCAT::MsgUtils->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 (<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/) {
|
||||
# enable the tftp by handling the entry 'disable = xx'
|
||||
my $newcfg = $_;
|
||||
$newcfg =~ s/=.*$/= yes/;
|
||||
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.");
|
||||
@ -1445,33 +1398,83 @@ sub enable_TFTPhpa
|
||||
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");
|
||||
my $distro = xCAT::Utils->osver();
|
||||
if ($distro !~ /ubuntu.*/i){
|
||||
if (! open (FILE, "</etc/xinetd.d/tftp")) {
|
||||
xCAT::MsgUtils->message("S", "ERROR: Cannot open /etc/xinetd.d/tftp.");
|
||||
return 1;
|
||||
}
|
||||
print FILE @newcfgfile;
|
||||
|
||||
# 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/) {
|
||||
# enable the tftp by handling the entry 'disable = xx'
|
||||
my $newcfg = $_;
|
||||
$newcfg =~ s/=.*$/= yes/;
|
||||
push @newcfgfile, $newcfg;
|
||||
$recfg = 1;
|
||||
} else {
|
||||
push @newcfgfile, $_;
|
||||
}
|
||||
}
|
||||
close (FILE);
|
||||
my @output = xCAT::Utils->runcmd("service xinetd status", -1);
|
||||
if ($::RUNCMD_RC == 0) {
|
||||
|
||||
# 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) {
|
||||
if (grep(/running/, @output))
|
||||
{
|
||||
print ' '; # indent service output to separate it from the xcatd service output
|
||||
system "service xinetd stop";
|
||||
if ($? > 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("S",
|
||||
print ' '; # indent service output to separate it from the xcatd service output
|
||||
system "service xinetd stop";
|
||||
if ($? > 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("S",
|
||||
"Error on command: service xinetd stop\n");
|
||||
}
|
||||
system "service xinetd start";
|
||||
if ($? > 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("S",
|
||||
}
|
||||
system "service xinetd start";
|
||||
if ($? > 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("S",
|
||||
"Error on command: service xinetd start\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# /usr/sbin/in.tftpd -V
|
||||
# tftp-hpa 0.49, with remap, with tcpwrappers
|
||||
#
|
||||
@ -1488,6 +1491,7 @@ sub enable_TFTPhpa
|
||||
# return 1;
|
||||
#}
|
||||
#xCAT::MsgUtils->message("S", " The tftp-hpa has been reconfigured.");
|
||||
}
|
||||
}
|
||||
my $protocols;
|
||||
my $v4only="-4 ";
|
||||
|
Loading…
Reference in New Issue
Block a user