From 1183c25a698a00c8fb7cb0d816868e7dcec7c0a3 Mon Sep 17 00:00:00 2001 From: ligc Date: Mon, 4 Jul 2011 08:58:30 +0000 Subject: [PATCH] add support for cleaning up xcatpost git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10004 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Schema.pm | 3 +++ xCAT-server/sbin/xcatconfig | 1 + xCAT/postscripts/xcataixpost | 5 ++++- xCAT/postscripts/xcatdsklspost | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index fe958de12..9719bfb45 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -765,6 +765,9 @@ site => { " For example: tabdump,nodels,lsdef will not log those cmds.\n". " ALL will not log any cmds.\n\n". " blademaxp: The maximum number of processes for blade hardware control.\n\n". + " cleanupxcatpost: (yes/1 or no/0). Set to 'yes' or '1' to clean up the /xcatpost directory\n". + " on the stateless and statelite nodes after the postscripts are run.\n". + " Default is no.\n\n". " consoleondemand: When set to 'yes', conserver connects and creates the console\n". " output only when the user opens the console. Default is no on\n". " Linux, yes on AIX.\n\n". diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 5b6157a68..3ab44e122 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -976,6 +976,7 @@ sub initDB $chtabcmds .= "$::XCATROOT/sbin/chtab key=sshbetweennodes site.value=ALLGROUPS;"; $chtabcmds .= "$::XCATROOT/sbin/chtab key=dnshandler site.value=ddns;"; $chtabcmds .= "$::XCATROOT/sbin/chtab key=vsftp site.value=y;"; + $chtabcmds .= "$::XCATROOT/sbin/chtab key=cleanupxcatpost site.value=no;"; if ($::osname eq 'AIX') { diff --git a/xCAT/postscripts/xcataixpost b/xCAT/postscripts/xcataixpost index be6f2294f..71d9369e9 100755 --- a/xCAT/postscripts/xcataixpost +++ b/xCAT/postscripts/xcataixpost @@ -349,7 +349,10 @@ if ($nodesetstat eq 'standalone') { } } } - +$cleanupxcatpost = `grep "CLEANUPXCATPOST=" $scriptname|awk -F \= '{print \$2}'`; +if ((!$?) && ($cleanupxcatpost =~ /\'1\'|\'yes\'/i)) { + &runcmd("cd /; rm -rf /xcatpost/*"); +} close($::LOG_FILE); exit 0; diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index 4c62d472c..69df5271f 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -335,6 +335,13 @@ fi DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' /tmp/mypostscript` echo "$DHCP_TMP" > /tmp/mypostscript +CLEANUPXCATPOST=`grep CLEANUPXCATPOST= /tmp/mypostscript |awk -F = '{print $2}'` +if [ "$CLEANUPXCATPOST" = "'1'" ] || [ "$CLEANUPXCATPOST" = "'yes'" ]; then + echo "cd /" >> /tmp/mypostscript + # /xcatpost might be read-only for statelite nodes + echo "rm -rf /xcatpost/*" >> /tmp/mypostscript +fi + chmod +x /tmp/mypostscript if [ -x /tmp/mypostscript ];then /tmp/mypostscript