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
This commit is contained in:
lissav 2008-04-24 13:29:36 +00:00
parent 1f50594afc
commit 552e267089

View File

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