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
This commit is contained in:
daniceexi 2009-09-18 11:28:34 +00:00
parent fbc8875c41
commit 8ff49f29a5
2 changed files with 46 additions and 0 deletions

View File

@ -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";

View File

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