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}'`