From 8da0a2c9733d1c9364fbe17055c63e3b904332f4 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 12 Mar 2009 19:48:52 +0000 Subject: [PATCH] add check for sharedtftp in site table to the setup routine for TFTP, do not mount tftpboot if sharedtftp is 0 or no git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2885 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/AAsn.pm | 56 ++++++++++++++++++---------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index 8c5702092..48d13a04e 100644 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -844,7 +844,6 @@ sub setup_TFTP { my ($nodename) = @_; my $rc = 0; - my $tftpdir = "/tftpboot"; # default my $cmd; my $master; my $os; @@ -875,12 +874,22 @@ sub setup_TFTP xCAT::MsgUtils->message("S", "atftp is not installed"); return 1; } - if ($output[0] =~ "atftp") # it is atftp + my $mountdirectory = "1"; # default to mount tftpboot dir + if ($output[0] =~ "atftp") # it is atftp { + # read sharedtftp attribute from site table, if exist + my @sharedtftp = xCAT::Utils->get_site_attribute("sharedtftp"); + if (exists($sharedtftp[0])) + { + $mountdirectory = $sharedtftp[0]; + $mountdirectory =~ tr/a-z/A-Z/; # convert to upper + } + # read tftpdir directory from database + my $tftpdir = "/tftpboot"; # default my @tftpdir1 = xCAT::Utils->get_site_attribute("tftpdir"); - if ($tftpdir1[0]) + if (exists($tftpdir1[0])) { $tftpdir = $tftpdir1[0]; } @@ -889,18 +898,23 @@ sub setup_TFTP mkdir($tftpdir); } - # check to see if tftp directory already mounted - my $mounted = xCAT::Utils->isMounted($tftpdir); - if ($mounted == 0) # not already mounted + # if request to mount + if ($mountdirectory eq "1" || $mountdirectory eq "YES") { - # need to mount the directory - my $cmd = " mount -o rw,nolock $master:$tftpdir $tftpdir"; - system $cmd; - if ($? > 0) - { # error - $rc = 1; - xCAT::MsgUtils->message("S", "Error $cmd"); + # 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 + my $cmd = " mount -o rw,nolock $master:$tftpdir $tftpdir"; + system $cmd; + if ($? > 0) + { # error + $rc = 1; + xCAT::MsgUtils->message("S", "Error $cmd"); + } } } @@ -921,14 +935,18 @@ sub setup_TFTP if ($rc == 0) { - # update fstab so that it will restart on reboot - $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 + if ($mountdirectory eq "1" || $mountdirectory eq "YES") { - `echo "$master:$tftpdir $tftpdir nfs timeo=14,intr 1 2" >>/etc/fstab`; + # update fstab so that it will restart on reboot + $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`; + } } }