From 2ddad2d1dfba4d3d7942f89ae57d5b0d669d5658 Mon Sep 17 00:00:00 2001 From: mxi1 Date: Wed, 7 Apr 2010 06:16:51 +0000 Subject: [PATCH] if the nfs directory is set on the service node, but is not added into /etc/exports, then will be added into /etc/exports when running "nodeset install"; git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5695 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/anaconda.pm | 23 +++++++++++++++++++++++ xCAT-server/lib/xcat/plugins/sles.pm | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index a7aa1fd58..2496a7d90 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -1260,6 +1260,16 @@ sub setupNFSTree { xCAT::Utils->runcmd($cmd, 0); # exportfs can export this directory immediately $callback->({data=>["now $nfsdirectory is exported!"]}); + $cmd = "cat /etc/exports"; + @entries = xCAT::Utils->runcmd($cmd, 0); + if(my $entry = grep /\Q$nfsdirectory\E/, @entries) { + # nothing to do + }else { + # if no entry in /etc/exports, one entry with default options will be added + $cmd = qq{echo "$nfsdirectory *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports}; + xCAT::Utils->runcmd($cmd, 0); + $callback->({data=>["$nfsdirectory is added to /etc/exports with default option"]}); + } } } } @@ -1293,6 +1303,19 @@ sub setupStatemnt { $cmd = "/usr/sbin/exportfs :$nfsdirectory -o rw,no_root_squash,sync,no_subtree_check"; xCAT::Utils->runcmd($cmd, 0); $callback->({data=>["now $nfsdirectory is exported!"]}); + # add the directory into /etc/exports if not exist + $cmd = "cat /etc/exports"; + @entries = xCAT::Utils->runcmd($cmd, 0); + if(my $entry = grep /\Q$nfsdirectory\E/, @entries) { + if ($entry =~ m/rw/) { + # nothing to do + } else { + $callback->({data => ["The $nfsdirectory should be with rw option in /etc/exports"]}); + } + } else { + xCAT::Utils->runcmd(qq{echo "$nfsdirectory *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports}, 0); + $callback->({data => ["$nfsdirectory is added into /etc/exports with default options"]}); + } } } } diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index bd5d1c5b3..15e53778b 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1184,6 +1184,16 @@ sub setupNFSTree { xCAT::Utils->runcmd($cmd, 0); # exportfs can export this directory immediately $callback->({data=>["now $nfsdirectory is exported!"]}); + $cmd = "cat /etc/exports"; + @entries = xCAT::Utils->runcmd($cmd, 0); + if(my $entry = grep /\Q$nfsdirectory\E/, @entries) { + # nothing to do + } else { + #if there's no entry in /etc/exports, one with default option is added + $cmd = qq{echo "$nfsdirectory *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports}; + xCAT::Utils->runcmd($cmd, 0); + $callback->({data=>["$nfsdirectory is added into /etc/exports with default option"]}); + } } } } @@ -1216,6 +1226,17 @@ sub setupStatemnt { $cmd = "/usr/sbin/exportfs :$nfsdirectory -o rw,no_root_squash,sync,no_subtree_check"; xCAT::Utils->runcmd($cmd, 0); $callback->({data=>["now $nfsdirectory is exported!"]}); + # add the directory into /etc/exports if not exist + $cmd = "cat /etc/exports"; + @entries = xCAT::Utils->runcmd($cmd, 0); + if(my $entry = grep /\Q$nfsdirectory\E/, @entries) { + if ($entry =~ m/rw/) { + }esle { + $callback->({data=>["The $nfsdirectory should be with rw option in /etc/exports"]}); + } + }else { + xCAT::Utils->runcmd(qq{echo "$nfsdirectory *(rw,no_root_squash,sync,no_subtree_check)" >>/etc/exports}, 0); + } } }