diff --git a/xCAT-server/share/xcat/install/scripts/post.debian b/xCAT-server/share/xcat/install/scripts/post.debian index 461a93baf..13c45fc78 100644 --- a/xCAT-server/share/xcat/install/scripts/post.debian +++ b/xCAT-server/share/xcat/install/scripts/post.debian @@ -112,34 +112,28 @@ export PATH=$PATH:/xcatpost # However, Ubuntu cleans /tmp on reboot. So, for Ubuntu, /var/tmp is used instead. # use the run_ps subroutine to run the postscripts -TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1 postscript/;s/run_ps\s*#/#/;s/-here\spostscript/-here/;s/run_ps\s*$//" /xcatpost/mypostscript` +TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript` echo " # subroutine used to run postscripts -# $1 argument is the script name -# $2 argument is the script type run_ps () { logdir=\"/var/log/xcat\" mkdir -p \$logdir logfile=\"/var/log/xcat/xcat.log\" - - if [ -z \"\$2\"]; then - scriptype=\"postscript\" - fi if [ -f \$1 ]; then - echo "\"\`date\` Running \$scriptype: \$1\"" | tee -a \$logfile + echo "\"\`date\` Running postscript: \$@\"" | tee -a \$logfile #./\$@ 2>&1 1> /tmp/tmp4xcatlog #cat /tmp/tmp4xcatlog | tee -a \$logfile ./\$@ 2>&1 | tee -a $logfile else - echo "\"\`date\` \$scriptype \$1 does NOT exist.\"" | tee -a \$logfile + echo "\"\`date\` Postscript \$1 does NOT exist.\"" | tee -a \$logfile fi } # subroutine end " > /xcatpost/mypostscript echo "$TMP" >> /xcatpost/mypostscript -TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1 postbootscript/;s/run_ps\s*#/#/;s/-here\spostbootscript/-here/;s/run_ps\s*$//" /xcatpost/mypostscript` +TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript` echo "$TMP" > /xcatpost/mypostscript diff --git a/xCAT-server/share/xcat/install/scripts/post.rhel5.s390x b/xCAT-server/share/xcat/install/scripts/post.rhel5.s390x index b3e2f2357..9f30feaaf 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rhel5.s390x +++ b/xCAT-server/share/xcat/install/scripts/post.rhel5.s390x @@ -93,32 +93,26 @@ cd /xcatpost export PATH=$PATH:/xcatpost # Use the run_ps subroutine to run the postscripts -TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1 postscript/;s/run_ps\s*#/#/;s/-here\spostscript/-here/;s/run_ps\s*$//" /xcatpost/mypostscript` +TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript` echo " # Subroutine used to run postscripts -# $1 argument is the script name -# $2 argument is the script type run_ps () { logdir=\"/var/log/xcat\" mkdir -p \$logdir logfile=\"/var/log/xcat/xcat.log\" - - if [ -z \"\$2\"]; then - scriptype=\"postscript\" - fi if [ -f \$1 ]; then - echo \"Running \$scriptype: \$1\" | tee -a \$logfile + echo \"Running postscript: \$@\" | tee -a \$logfile ./\$@ 2>&1 | tee -a $logfile else - echo \"\$scriptype \$1 does NOT exist.\" | tee -a \$logfile + echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile fi } # Subroutine end " > /xcatpost/mypostscript echo "$TMP" >> /xcatpost/mypostscript -TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1 postbootscript/;s/run_ps\s*#/#/;s/-here\spostbootscript/-here/;s/run_ps\s*$//" /xcatpost/mypostscript` +TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript` echo "$TMP" > /xcatpost/mypostscript diff --git a/xCAT-server/share/xcat/install/scripts/post.rhel6.s390x b/xCAT-server/share/xcat/install/scripts/post.rhel6.s390x index 91864a84b..61ce1477a 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rhel6.s390x +++ b/xCAT-server/share/xcat/install/scripts/post.rhel6.s390x @@ -92,32 +92,26 @@ cd /xcatpost export PATH=$PATH:/xcatpost # Use the run_ps subroutine to run the postscripts -TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1 postscript/;s/run_ps\s*#/#/;s/-here\spostscript/-here/;s/run_ps\s*$//" /xcatpost/mypostscript` +TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript` echo " # Subroutine used to run postscripts -# $1 argument is the script name -# $2 argument is the script type run_ps () { logdir=\"/var/log/xcat\" mkdir -p \$logdir logfile=\"/var/log/xcat/xcat.log\" - - if [ -z \"\$2\"]; then - scriptype=\"postscript\" - fi if [ -f \$1 ]; then - echo \"Running \$scriptype: \$1\" | tee -a \$logfile + echo \"Running postscript: \$@\" | tee -a \$logfile ./\$@ 2>&1 | tee -a $logfile else - echo \"\$scriptype \$1 does NOT exist.\" | tee -a \$logfile + echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile fi } # Subroutine end " > /xcatpost/mypostscript echo "$TMP" >> /xcatpost/mypostscript -TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1 postbootscript/;s/run_ps\s*#/#/;s/-here\spostbootscript/-here/;s/run_ps\s*$//" /xcatpost/mypostscript` +TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript` echo "$TMP" > /xcatpost/mypostscript diff --git a/xCAT-server/share/xcat/install/scripts/post.sles10.s390x b/xCAT-server/share/xcat/install/scripts/post.sles10.s390x index a51024a79..3902c8917 100644 --- a/xCAT-server/share/xcat/install/scripts/post.sles10.s390x +++ b/xCAT-server/share/xcat/install/scripts/post.sles10.s390x @@ -100,26 +100,20 @@ PATH=$PATH:/xcatpost export PATH # use the run_ps subroutine to run the postscripts -TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1 postscript/;s/run_ps\s*#/#/;s/-here\spostscript/-here/;s/run_ps\s*$//" /tmp/mypostscript` +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 -# $1 argument is the script name -# $2 argument is the script type run_ps () { logdir=\"/var/log/xcat\" mkdir -p \$logdir logfile=\"/var/log/xcat/xcat.log\" - - if [ -z \"\$2\"]; then - scriptype=\"postscript\" - fi if [ -f \$1 ]; then - echo \"Running \$scriptype: \$1\" | tee -a \$logfile + echo \"Running postscript: \$@\" | tee -a \$logfile ./\$@ 2>&1 1> /tmp/tmp4xcatlog cat /tmp/tmp4xcatlog | tee -a \$logfile else - echo \"\$scriptype \$1 does NOT exist.\" | tee -a \$logfile + echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile fi } # subroutine end @@ -127,7 +121,7 @@ run_ps () { " > /tmp/mypostscript echo "cd /xcatpost" >> /tmp/mypostscript echo "$TMP" >> /tmp/mypostscript -TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1 postbootscript/;s/run_ps\s*#/#/;s/-here\spostbootscript/-here/;s/run_ps\s*$//" /tmp/mypostscript` +TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` echo "$TMP" > /tmp/mypostscript diff --git a/xCAT-server/share/xcat/install/scripts/post.sles11.s390x b/xCAT-server/share/xcat/install/scripts/post.sles11.s390x index dbe653e50..3e84ad99b 100644 --- a/xCAT-server/share/xcat/install/scripts/post.sles11.s390x +++ b/xCAT-server/share/xcat/install/scripts/post.sles11.s390x @@ -101,26 +101,20 @@ PATH=$PATH:/xcatpost export PATH # use the run_ps subroutine to run the postscripts -TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1 postscript/;s/run_ps\s*#/#/;s/-here\spostscript/-here/;s/run_ps\s*$//" /tmp/mypostscript` +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 -# $1 argument is the script name -# $2 argument is the script type run_ps () { logdir=\"/var/log/xcat\" mkdir -p \$logdir logfile=\"/var/log/xcat/xcat.log\" - - if [ -z \"\$2\"]; then - scriptype=\"postscript\" - fi if [ -f \$1 ]; then - echo \"Running \$scriptype: \$1\" | tee -a \$logfile + echo \"Running postscript: \$@\" | tee -a \$logfile ./\$@ 2>&1 1> /tmp/tmp4xcatlog cat /tmp/tmp4xcatlog | tee -a \$logfile else - echo \"\$scriptype \$1 does NOT exist.\" | tee -a \$logfile + echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile fi } # subroutine end @@ -128,7 +122,7 @@ run_ps () { " > /tmp/mypostscript echo "cd /xcatpost" >> /tmp/mypostscript echo "$TMP" >> /tmp/mypostscript -TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1 postbootscript/;s/run_ps\s*#/#/;s/-here\spostbootscript/-here/;s/run_ps\s*$//" /tmp/mypostscript` +TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` echo "$TMP" > /tmp/mypostscript diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 522a18e9b..4d50a85b7 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -153,9 +153,9 @@ if [ ! -x /xcatpost/mypostscript ]; then done fi -TMP=`sed "/^#\s*postscripts-start-here/,/^#\s*postscripts-end-here/ s/\(.*\)/run_ps \1 postscript/;s/run_ps\s*#/#/;s/-here\spostscript/-here/;s/run_ps\s*$//" /xcatpost/mypostscript` +TMP=`sed "/^#\s*postscripts-start-here/,/^#\s*postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript` echo "$TMP" > /xcatpost/mypostscript -TMP=`sed "/^#\s*postbootscripts-start-here/,/^#\s*postbootscripts-end-here/ s/\(.*\)/run_ps \1 postbootscript/;s/run_ps\s*#/#/;s/-here\spostbootscript/-here/;s/run_ps\s*$//" /xcatpost/mypostscript` +TMP=`sed "/^#\s*postbootscripts-start-here/,/^#\s*postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript` cd /xcatpost #gunzip xcatpost.tar.gz @@ -178,54 +178,48 @@ echo " # global value to store the running status of the postbootscripts,the value is non-zero if one postbootscript failed return_value=0 # subroutine used to run postscripts -# $1 argument is the script name -# $2 argument is the script type run_ps () { - local ret_local=0 - mkdir -p "\"/var/log/xcat\"" - # On some Linux distro, the rsyslogd daemon write log files with permision - # other than root:root. And in some case, the directory /var/log/xcat was - # created by xCAT, and had root:root ownership. In this way, rsyslogd - # did not have enough permission to write to log files under this directory. - # As a dirty hack, change the ownership of directory /var/log/xcat to the - # same ownership of directory /var/log. - chown `ls -ld /var/log | awk '{ print \$3\":\"\$4 }'` "\"/var/log/xcat\"" - local logfile=\"/var/log/xcat/xcat.log\" + local ret_local=0 + mkdir -p "\"/var/log/xcat\"" + # On some Linux distro, the rsyslogd daemon write log files with permision + # other than root:root. And in some case, the directory /var/log/xcat was + # created by xCAT, and had root:root ownership. In this way, rsyslogd + # did not have enough permission to write to log files under this directory. + # As a dirty hack, change the ownership of directory /var/log/xcat to the + # same ownership of directory /var/log. + chown `ls -ld /var/log | awk '{ print \$3\":\"\$4 }'` "\"/var/log/xcat\"" + local logfile=\"/var/log/xcat/xcat.log\" - if [ -z \"\$2\"]; then - scriptype=\"postscript\" - fi + if [ -f \$1 ]; then + echo \"\`date\` Running postscript: \$*\" + msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Running postscript: \$*\"" \"\$logfile\" + if [ \"\$XCATDEBUGMODE\" = \"1\" ] || [ \"\$XCATDEBUGMODE\" = \"2\" ]; then + local compt=\$(file \$1) + local reg=\"shell script\" + if [[ \"\$compt\" =~ \$reg ]]; then + bash -x ./\$@ 2>&1 + ret_local=\$? + else + ./\$@ 2>&1 | tee -a \$logfile | logger -t xcat -p debug + ret_local=\${PIPESTATUS[0]} + fi + else + ./\$@ 2>&1 | tee -a \$logfile + ret_local=\${PIPESTATUS[0]} + fi - if [ -f \$1 ]; then - echo \"\`date\` Running \$scriptype: \$1\" - msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Running \$scriptype: \$1\"" \"\$logfile\" - if [ \"\$XCATDEBUGMODE\" = \"1\" ] || [ \"\$XCATDEBUGMODE\" = \"2\" ]; then - local compt=\$(file \$1) - local reg=\"shell script\" - if [[ \"\$compt\" =~ \$reg ]]; then - bash -x ./\$@ 2>&1 - ret_local=\$? - else - ./\$@ 2>&1 | tee -a \$logfile | logger -t xcat -p debug - ret_local=\${PIPESTATUS[0]} - fi - else - ./\$@ 2>&1 | tee -a \$logfile - ret_local=\${PIPESTATUS[0]} - fi + 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 - if [ \"\$ret_local\" -ne \"0\" ]; then - return_value=\$ret_local - fi - echo \"\$scriptype: \$1 exited with code \$ret_local\" - msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` \$scriptype \$1 return with \$ret_local\"" \"\$logfile\" - else - echo \"\`date\` \$scriptype \$1 does NOT exist.\" - msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` \$scriptype \$1 does NOT exist.\"" \"\$logfile\" - return_value=-1 - fi - - return 0 + return 0 } # subroutine end diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index 5364f01a2..629df8630 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -822,31 +822,21 @@ fi #echo "$MYCONT" # use the run_ps subroutine to run the postscripts -if [ $NODE_DEPLOYMENT -eq 1 ] || [ "$MODE" = "4" ] || [ "$MODE" = "6" ]; then - TMP=`sed "/# postscripts-start-here/,/# postscripts-end-here/ s/\(.*\)/run_ps \1 postbootscript/;s/run_ps\s*#/#/;s/-here\spostbootscript/-here/;s/run_ps\s*$//" /$xcatpost/mypostscript` -else - TMP=`sed "/# postscripts-start-here/,/# postscripts-end-here/ s/\(.*\)/run_ps \1 postscript/;s/run_ps\s*#/#/;s/-here\spostscript/-here/;s/run_ps\s*$//" /$xcatpost/mypostscript` -fi +TMP=`sed "/# postscripts-start-here/,/# postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /$xcatpost/mypostscript` echo " . /xcatpost/xcatlib.sh # global value to store the running status of the postbootscripts,the value is non-zero if one postbootscript failed return_value=0 # subroutine used to run postscripts -# $1 argument is the script name -# $2 argument is the script type run_ps () { local ret_local=0 mkdir -p "\"/var/log/xcat\"" local logfile=\"/var/log/xcat/xcat.log\" - if [ -z \"\$2\"]; then - scriptype=\"postscript\" - fi - if [ -f \$1 ]; then - echo \"\`date\` Running \$scriptype: \$1\" - msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Running \$scriptype: \$1\"" \"\$logfile\" + echo \"\`date\` Running postscript: \$*\" + msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Running postscript: \$*\"" \"\$logfile\" if [ \"\$XCATDEBUGMODE\" = \"1\" ] || [ \"\$XCATDEBUGMODE\" = \"2\" ]; then local compt=\$(file \$1) local reg=\"shell script\" @@ -865,11 +855,11 @@ run_ps () { if [ \"\$ret_local\" -ne \"0\" ]; then return_value=\$ret_local fi - echo \"\$scriptype: \$1 exited with code \$ret_local\" - msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` \$scriptype \$1 return with \$ret_local\"" \"\$logfile\" + echo \"Postscript: \$* exited with code \$ret_local\" + msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` postscript \$* return with \$ret_local\"" \"\$logfile\" else - echo \"\`date\` \$scriptype \$1 does NOT exist.\" - msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` \$scriptype \$1 does NOT exist.\"" \"\$logfile\" + echo \"\`date\` Postscript \$1 does NOT exist.\" + msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Postscript \$1 does NOT exist.\"" \"\$logfile\" return_value=-1 fi @@ -879,11 +869,7 @@ run_ps () { " > /$xcatpost/mypostscript echo "$TMP" >> /$xcatpost/mypostscript -if [ "$MODE" = "1" ] || [ "$MODE" = "2" ] || [ "$MODE" = "3" ] || [ "$MODE" = "5" ]; then - TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ s/\(.*\)/run_ps \1 postscript/;s/run_ps\s*#/#/;s/-here\spostscript/-here/;s/run_ps\s*$//" /$xcatpost/mypostscript` -else - TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ s/\(.*\)/run_ps \1 postbootscript/;s/run_ps\s*#/#/;s/-here\spostbootscript/-here/;s/run_ps\s*$//" /$xcatpost/mypostscript` -fi +TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /$xcatpost/mypostscript` echo "$TMP" > /$xcatpost/mypostscript if [ $NODE_DEPLOYMENT -eq 1 ] || [ "$MODE" = "4" ] || [ "$MODE" = "6" ]; then