From d716e740bc591b03ab2e53bb9ba41d41dae63720 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Sun, 27 Sep 2015 22:50:34 -0400 Subject: [PATCH] make the run_ps subroutine to be consistent in ubuntu.post xcat.post and xcatdsklspost --- xCAT-server/share/xcat/install/scripts/post.ubuntu | 10 +++++++--- xCAT-server/share/xcat/install/scripts/post.xcat | 12 ++++++++---- xCAT/postscripts/xcatdsklspost | 13 ++++++------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu b/xCAT-server/share/xcat/install/scripts/post.ubuntu index 515437953..935ea4be3 100755 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu @@ -152,9 +152,11 @@ return_value=0 # subroutine used to run postscripts run_ps () { local ret_local=0 + mkdir -p "\"/var/log/xcat\"" local logfile=\"/var/log/xcat/xcat.log\" - if [ -f \$1 ]; then + if [ -f \$1 ]; then + echo \"\`date\` Running postscript: \$*\" msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Running postscript: \$*\"" \"\$logfile\" if [ \"\$XCATDEBUGMODE\" = \"1\" ]; then bash -x ./\$@ 2>&1 | tee -a \$logfile @@ -163,12 +165,14 @@ run_ps () { ./\$@ 2>&1 | tee -a \$logfile ret_local=\${PIPESTATUS[0]} fi - msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` postscript \$* return with \$ret_local\"" \"\$logfile\" + if [ \"\$ret_local\" -ne \"0\" ]; then return_value=\$ret_local fi - + echo \"Postscript: \$* exited with code \$ret_local\" + msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` postscript \$* return with \$ret_local\"" \"\$logfile\" else + echo \"\`date\` Postscript \$1 does NOT exist.\" msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Postscript \$1 does NOT exist.\"" \"\$logfile\" return_value=-1 fi diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 40e0d7c63..85632056e 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -137,9 +137,11 @@ return_value=0 # subroutine used to run postscripts run_ps () { local ret_local=0 + mkdir -p "\"/var/log/xcat\"" local logfile=\"/var/log/xcat/xcat.log\" - if [ -f \$1 ]; then + if [ -f \$1 ]; then + echo \"\`date\` Running postscript: \$*\" msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Running postscript: \$*\"" \"\$logfile\" if [ \"\$XCATDEBUGMODE\" = \"1\" ]; then bash -x ./\$@ 2>&1 | tee -a \$logfile @@ -148,16 +150,18 @@ run_ps () { ./\$@ 2>&1 | tee -a \$logfile ret_local=\${PIPESTATUS[0]} fi - msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` postscript \$* return with \$ret_local\"" \"\$logfile\" + if [ \"\$ret_local\" -ne \"0\" ]; then return_value=\$ret_local fi - + echo \"Postscript: \$* exited with code \$ret_local\" + msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` postscript \$* return with \$ret_local\"" \"\$logfile\" else + echo \"\`date\` Postscript \$1 does NOT exist.\" msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Postscript \$1 does NOT exist.\"" \"\$logfile\" return_value=-1 fi - + return 0 } # subroutine end diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index ccd1b74d4..646ef18e3 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -822,13 +822,12 @@ return_value=0 # subroutine used to run postscripts run_ps () { local ret_local=0 - logdir=\"/var/log/xcat\" - mkdir -p \$logdir - logfile=\"/var/log/xcat/xcat.log\" - + mkdir -p "\"/var/log/xcat\"" + local logfile=\"/var/log/xcat/xcat.log\" + if [ -f \$1 ]; then echo \"\`date\` Running postscript: \$*\" - msgutil_r \$MASTER_IP \"debug\" \"\`date\` Running postscript: \$*\" \"\$logfile\" + msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Running postscript: \$*\"" \"\$logfile\" if [ \"\$XCATDEBUGMODE\" = \"1\" ]; then bash -x ./\$@ 2>&1 | tee -a \$logfile ret_local=\${PIPESTATUS[0]} @@ -841,10 +840,10 @@ run_ps () { return_value=\$ret_local fi echo \"Postscript: \$* exited with code \$ret_local\" - msgutil_r \$MASTER_IP \"debug\" \"\`date\` Postscript: \$* exited with code \$ret_local\" \"\$logfile\" + msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` postscript \$* return with \$ret_local\"" \"\$logfile\" else echo \"\`date\` Postscript \$1 does NOT exist.\" - msgutil_r \$MASTER_IP \"debug\" \"\`date\` Postscript: \$* exited with code \$ret_local\" \"\$logfile\" + msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Postscript \$1 does NOT exist.\"" \"\$logfile\" return_value=-1 fi