2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 17:23:08 +00:00

Merge pull request #222 from penguhyang/run_ps

make the run_ps subroutine to be consistent
This commit is contained in:
yangsong 2015-09-28 20:34:27 +08:00
commit 436c1f869e
3 changed files with 21 additions and 14 deletions

View File

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

View File

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

View File

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