From 8ff49f29a5f6172ffdb84d600c061823b3a035b8 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Fri, 18 Sep 2009 11:28:34 +0000 Subject: [PATCH] 2849809: Display message when running the postscript or the postscript does not exist git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4166 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/xcataixpost | 23 +++++++++++++++++++++++ xCAT/postscripts/xcatdsklspost | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/xCAT/postscripts/xcataixpost b/xCAT/postscripts/xcataixpost index 01236c588..f1d69d55b 100755 --- a/xCAT/postscripts/xcataixpost +++ b/xCAT/postscripts/xcataixpost @@ -198,14 +198,37 @@ if (-f $scriptname) #remove all the postscripts my $TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" $scriptname`; `echo "$TMP" > $scriptname`; + `echo "# postscripts-start-here" >> $scriptname`; #add requested postscripts in `echo "$POSTS" | tr "," "\n" >> $scriptname`; + `echo "# postscripts-end-here" >> $scriptname`; } + # use the run_ps subroutine to run the postscripts + my $TMP1=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\\(.*\\)/run_ps \\1/;s/run_ps *#/#/;s/run_ps *\$//" $scriptname`; + `echo " +# subroutine used to run postscripts +run_ps () { + if [[ -f \\\$1 ]]; then + echo \\"Running postscript: \\\$1\\" + OUTPUT=\\\`\\\$1 2>&1\\\` + if [[ -n \\\$OUTPUT ]]; then + echo \\"\\\$OUTPUT\\" + fi + else + echo \\"Postscript \\\$1 does NOT exist.\\" + fi +} +# subroutine end + +" > $scriptname`; + `echo "$TMP1" >> $scriptname`; + $nodesetstat=`grep "NODESETSTATE=" $scriptname|awk -F \= '{print \$2}'`; chomp($nodesetstat); $ENV{PATH}="/xcatpost:$ENV{PATH}"; &runcmd("cd /xcatpost;$scriptname"); + print $::outref; } else { print "$::sdate xcataixpost: Could not find post script for $::shorthost.\n"; print $::LOG_FILE "$::sdate xcataixpost: Could not find post script for $::shorthost.\n"; diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index 43572958e..e38e54c71 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -130,8 +130,10 @@ if [ $# -gt 1 ]; then #remove all the postscripts TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` echo "$TMP" > /tmp/mypostscript + echo "# postscripts-start-here\n" >> /tmp/mypostscript #add requested postscripts in echo "$POSTS" | tr "," "\n" >> /tmp/mypostscript + echo "# postscripts-end-here\n" >> /tmp/mypostscript fi #ADDSITEYUM is set by post.rh and post.rh.iscsi for full installtion @@ -143,6 +145,27 @@ fi #MYCONT=`cat /tmp/mypostscript` #echo "$MYCONT" +# use the run_ps subroutine to run the postscripts +TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` +echo " +# subroutine used to run postscripts +run_ps () { + if [[ -f \$1 ]]; then + echo \"Running postscript: \$1\" + OUTPUT=\`\$1 2>&1\` + if [[ -n \$OUTPUT ]]; then + echo \"\$OUTPUT\" + fi + else + echo \"Postscript \$1 does NOT exist.\" + fi +} +# subroutine end + +" > /tmp/mypostscript +echo "$TMP" >> /tmp/mypostscript + + if [ $# -eq 0 ]; then #notify the server that we are done with netbooting CNS=`grep NODESTATUS= /tmp/mypostscript |awk -F = '{print $2}'`