From 94f6e16af6e244e97a53d34d383c9cf0e2e5abef Mon Sep 17 00:00:00 2001 From: wuzhy Date: Fri, 9 Apr 2010 06:12:40 +0000 Subject: [PATCH] log the stdout & stderr of each postscript to the local log file on each compute node git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5728 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/xcataixpost | 9 ++++++--- xCAT/postscripts/xcatdsklspost | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/xCAT/postscripts/xcataixpost b/xCAT/postscripts/xcataixpost index b284ed297..7cb5876c0 100755 --- a/xCAT/postscripts/xcataixpost +++ b/xCAT/postscripts/xcataixpost @@ -259,17 +259,20 @@ if (-f $scriptname) `echo " # subroutine used to run postscripts run_ps () { + logdir=\\"/var/log/xcat\\" + \\\`mkdir -p \\\$logdir\\\` + logfile=\\"/var/log/xcat/xcat.log\\" + if [[ -f \\\$1 ]]; then echo \\"Running postscript: \\\$1\\" - print $::LOG_FILE "$::sdate xcataixpost: Running postscript: $1\n"; OUTPUT=\\\`./\\\$1 2>&1\\\` if [[ -n \\\$OUTPUT ]]; then echo \\"\\\$OUTPUT\\" - print $::LOG_FILE "$::sdate xcataixpost: output=$output\n"; + echo \\"Postscript \\\$1: \\\$OUTPUT\\" >> \\\$logfile fi else echo \\"Postscript \\\$1 does NOT exist.\\" - print $::LOG_FILE "$::sdate xcataixpost: $1 does NOT exist.\n"; + echo \\"Postscript \\\$1 does NOT exist.\\" >> \\\$logfile fi } # subroutine end diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index fc052087e..817b574a5 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -308,15 +308,21 @@ fi 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 () { +run_ps () { + logdir=\"var/log/xcat\" + \`mkdir -p \$logdir\` + logfile=\"var/log/xcat/xcat.log\" + if [[ -f \$1 ]]; then echo \"Running postscript: \$1\" OUTPUT=\`./\$1 2>&1\` if [[ -n \$OUTPUT ]]; then echo \"\$OUTPUT\" + echo \"Postscript \$1: $OUTPUT\"\ >> \$logfile fi else echo \"Postscript \$1 does NOT exist.\" + echo \"Postscript \$1 does NOT exist.\" >> \$logfile fi } # subroutine end