From 552e2670898ee5db28a7518d7416baa07208ff75 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 24 Apr 2008 13:29:36 +0000 Subject: [PATCH] Capture STD and STDERR and use logger. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1180 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/servicenode | 49 ++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/xCAT/postscripts/servicenode b/xCAT/postscripts/servicenode index dd906e7a3..66c6f8c53 100755 --- a/xCAT/postscripts/servicenode +++ b/xCAT/postscripts/servicenode @@ -20,22 +20,39 @@ # remove OpenIPMI-tools and tftp # install xcat from /install/xcat # Copy Certificates, and config file to apprpriate directories from /install -# and restart postgresql and xcatd -# -my $msg = "Removing OpenIPMI-tools"; -`logger -t xcat $msg`; -`rpm -e OpenIPMI-tools`; -$msg = "Removing tftp"; -`logger -t xcat $msg`; -`rpm -e tftp-server`; -if ($ENV{'NODESETSTATE'} eq "install") { - $msg = "Installing xCAT"; - `logger -t xcat $msg`; - `rpm -ivh /xcatpost/xcat/RPMS/*/*.rpm`; +# and restart xcatd +# MAIN +my $rc=0; +&runcmd("rpm -e OpenIPMI-tools"); + +&runcmd("rpm -e tftp-server"); +if ($ENV{'NODESETSTATE'} eq "install") +{ + $msg = "Installing xCAT"; + `logger -t xcat $msg`; + &runcmd("rpm -ivh /xcatpost/xcat/RPMS/*/*.rpm"); } -$msg = "copying certificates and restarting daemon"; -`logger -t xcat $msg`; -`/opt/xcat/sbin/copycerts`; +&runcmd("/opt/xcat/sbin/copycerts"); -exit 0; +# +# run the command +# +sub runcmd +{ + my ($cmd) = @_; + my $rc; + $cmd .= ' 2>&1' ; + my $outref = []; + @$outref = `$cmd`; + if ($?) + { + $rc = $? >> 8; + if ($rc > 0) + { + `logger -t xcat @$outref`; + } + } + return $rc; +} +exit $rc;