From ec778af056152f328d51f7159f87dd3e5678216e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 14 Aug 2018 15:56:10 -0400 Subject: [PATCH] Handle SLE 15 tftp server configuration --- xCAT-server/lib/xcat/plugins/AAsn.pm | 37 +++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index d7c63fa02..4656230f3 100755 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -1343,6 +1343,9 @@ sub stop_TFTP my $distro=xCAT::Utils->osver(); # 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")) { + if (-e "/usr/lib/systemd/system/tftp.socket") { + return 0; + } xCAT::MsgUtils->message("S", "ERROR: The tftpd was not installed, enable the tftp failed."); return 1; } @@ -1436,12 +1439,41 @@ sub enable_TFTP } my $distro = xCAT::Utils->osver(); - if ($distro !~ /ubuntu.*/i && $distro !~ /debian.*/i) { + if ($distro !~ /ubuntu.*/i && $distro !~ /debian.*/i && -e "/etc/sysconfig/tftp") { + if (!open(FILE, "message("S", "ERROR: Cannot open /etc/xinetd.d/tftp."); + return 1; + } + my @newconfig = (); + while () { + if (/^TFTP_DIRECTORY/) { + if (m!"$tftpdir"!) { + @newconfig = (); + last; + } else { + s!=.*!="$tftpdir"! + } + } + push @newconfig, $_; + } + close(FILE); + if (@newconfig) { + my $newconf; + open($newconf, ">/etc/sysconfig/tftp"); + foreach (@newconfig) { + print $newconf $_; + } + close($newconf); + } + system("systemctl enable tftp.socket"); + system("systemctl start tftp.socket"); + return 0; + } + if ($distro !~ /ubuntu.*/i && $distro !~ /debian.*/i && -e "/etc/xinet.d/tftp") { 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; @@ -1458,7 +1490,6 @@ sub enable_TFTP 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) {