2008-02-19 13:38:14 +00:00
|
|
|
#!/usr/bin/perl
|
2007-10-26 22:44:33 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#(C)IBM Corp
|
|
|
|
|
2008-02-19 13:38:14 +00:00
|
|
|
#
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2008-02-19 13:38:14 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2008-02-19 13:38:14 +00:00
|
|
|
=head1 servicenode
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2008-02-19 13:38:14 +00:00
|
|
|
This updates the service node with files necessary to access the
|
|
|
|
database on the MasterNode and restarts the xcat daemon
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2008-08-22 15:02:13 +00:00
|
|
|
On AIX systems this does the service node configuration.
|
|
|
|
|
2008-02-19 13:38:14 +00:00
|
|
|
=cut
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2008-02-19 13:38:14 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2008-04-24 13:29:36 +00:00
|
|
|
# MAIN
|
2008-08-22 15:02:13 +00:00
|
|
|
|
2008-04-24 13:29:36 +00:00
|
|
|
my $rc=0;
|
|
|
|
|
2008-08-22 15:02:13 +00:00
|
|
|
$::osname = `uname`;
|
|
|
|
chomp $::osname;
|
|
|
|
|
|
|
|
$::sdate = `/bin/date`;
|
|
|
|
chomp $::sdate;
|
|
|
|
|
|
|
|
$::hname = `hostname`;
|
|
|
|
chomp $::hname;
|
|
|
|
|
|
|
|
if ($::osname eq 'AIX')
|
|
|
|
{
|
|
|
|
# AIX service node setup
|
|
|
|
$rc = &setupAIXsn;
|
|
|
|
if ( $rc != 0) {
|
|
|
|
my $msg="$::sdate servicenode: One or more errors occurred when attempting to configure node $::hname as an xCAT service node.\n";
|
|
|
|
print "$msg\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2008-04-24 13:29:36 +00:00
|
|
|
{
|
2008-08-22 15:02:13 +00:00
|
|
|
# Linux setup
|
|
|
|
# remove OpenIPMI-tools and tftp
|
|
|
|
# install xcat from /install/xcat
|
|
|
|
# Copy Certificates, and config file to apprpriate directories
|
|
|
|
# from /install and restart xcatd
|
|
|
|
&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");
|
|
|
|
}
|
|
|
|
&runcmd("/opt/xcat/sbin/copycerts");
|
2008-04-15 19:44:32 +00:00
|
|
|
}
|
2008-08-22 15:02:13 +00:00
|
|
|
|
|
|
|
exit $rc;
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2008-04-24 13:29:36 +00:00
|
|
|
#
|
2008-08-22 15:02:13 +00:00
|
|
|
# Subroutines
|
2008-04-24 13:29:36 +00:00
|
|
|
#
|
2008-08-22 15:02:13 +00:00
|
|
|
|
|
|
|
# run the command
|
2008-04-24 13:29:36 +00:00
|
|
|
sub runcmd
|
|
|
|
{
|
|
|
|
my ($cmd) = @_;
|
2008-10-07 17:48:44 +00:00
|
|
|
my $rc=0;
|
2008-08-22 15:02:13 +00:00
|
|
|
|
2008-04-24 13:29:36 +00:00
|
|
|
$cmd .= ' 2>&1' ;
|
2008-10-07 17:48:44 +00:00
|
|
|
$::outref = [];
|
|
|
|
$::outref = `$cmd`;
|
2008-04-24 13:29:36 +00:00
|
|
|
if ($?)
|
|
|
|
{
|
|
|
|
$rc = $? >> 8;
|
|
|
|
if ($rc > 0)
|
|
|
|
{
|
2008-10-07 17:48:44 +00:00
|
|
|
my $msg="$cmd returned rc=$rc @$::outref\n";
|
2008-05-15 14:52:25 +00:00
|
|
|
`logger -t xcat $msg`;
|
2008-04-24 13:29:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $rc;
|
|
|
|
}
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2008-08-22 15:02:13 +00:00
|
|
|
# do AIX service node setup
|
|
|
|
sub setupAIXsn
|
|
|
|
{
|
|
|
|
my $error=0;
|
2008-10-07 17:48:44 +00:00
|
|
|
my $servnode;
|
|
|
|
|
|
|
|
# get the name of my service node/NIM master from the /etc/xcatinfo file
|
|
|
|
# file was created by xcataixpost when the node was first installed
|
|
|
|
if (-f "/etc/xcatinfo") {
|
|
|
|
my $cmd = "cat /etc/xcatinfo | grep 'XCATSERVER'";
|
|
|
|
&runcmd($cmd);
|
|
|
|
my $SNline = $::outref;
|
|
|
|
my $junk;
|
|
|
|
($junk, $servnode) = split(/=/, $SNline);
|
|
|
|
$servnode =~ s/^\s*//;
|
|
|
|
chomp $servnode;
|
|
|
|
} else {
|
|
|
|
$msg = "$::sdate servicenode: Could not find /etc/xcatinfo file.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $rcpcmd = "rcp -r $servnode:/etc/hosts /etc";
|
|
|
|
if (&runcmd($rcpcmd) != 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not get /etc/hosts file.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# make sure we have enough space in /xcatpost ("/") fs
|
|
|
|
my $dfcmd = "df -m / | grep '\/' |tr -s ' '| cut -f 3 -d ' '";
|
|
|
|
if (&runcmd($dfcmd) != 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not find file system free space.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
my $freespace = $::outref;
|
|
|
|
if ($freespace <= 220) {
|
|
|
|
# add to "/" fs if needed
|
|
|
|
my $chfscmd = "/usr/sbin/chfs -a size=+220M /";
|
|
|
|
if (&runcmd($chfscmd) != 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not increase file system size.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# make sure we have enough space in /usr fs
|
|
|
|
my $dfcmd = "df -m /usr | grep 'usr' |tr -s ' '| cut -f 3 -d ' '";
|
|
|
|
if (&runcmd($dfcmd) != 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not find file system free space.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
my $freespace = $::outref;
|
|
|
|
if ($freespace <= 2200) {
|
|
|
|
# add to "/usr" fs if needed
|
|
|
|
my $chfscmd = "/usr/sbin/chfs -a size=+2200M /usr";
|
|
|
|
if (&runcmd($chfscmd) != 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not increase file system size.\n
|
|
|
|
";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# copy SN software to /xcatpost/AIX/xcatpkgs
|
|
|
|
my $rcpcmd = "mkdir -p /xcatpost/AIX/xcatpkgs; rcp -r $servnode:/install/AIX/xcatpkgs/* /xcatpost/AIX/xcatpkgs";
|
|
|
|
if (&runcmd($rcpcmd) != 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not copy service node software from the management node.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# run inutoc
|
|
|
|
my $inucmd = "inutoc /xcatpost/AIX/xcatpkgs";
|
|
|
|
if (&runcmd($rcpcmd) != 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not run inutoc.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# install openssl
|
|
|
|
my $gencmd = "geninstall -IaXY -d /xcatpost/AIX/xcatpkgs -f /xcatpost/AIX/xcatpkgs/xCATinstpSN.bnd";
|
|
|
|
if (&runcmd($gencmd) != 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not install openssl.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# install openssh
|
|
|
|
my $gencmd = "geninstall -IaXY -d /xcatpost/AIX/xcatpkgs -f /xcatpost/AIX/xcatpkgs/xCATaixSSH.bnd";
|
|
|
|
if (&runcmd($gencmd) != 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not install openssh.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# run updatepkg to update RPM's reflection of the software
|
|
|
|
# installed by installp - may already be done - but won't hurt!
|
|
|
|
if (&runcmd("/usr/sbin/updtvpkg") != 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not run updtvpkg.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# install rpms
|
|
|
|
my $rpmcmd = "rpm -U /xcatpost/AIX/xcatpkgs/*.rpm";
|
2008-10-10 15:13:11 +00:00
|
|
|
&runcmd($rpmcmd);
|
2008-08-22 15:02:13 +00:00
|
|
|
|
|
|
|
# so conserver will start
|
|
|
|
if (&runcmd("mkdir -p /var/log/consoles")!= 0) {
|
2008-10-07 17:48:44 +00:00
|
|
|
$msg = "$::sdate servicenode: Could not make /var/log/consoles.\n";
|
|
|
|
`logger -t xcat $msg`;
|
2008-08-22 15:02:13 +00:00
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# makes it a service node
|
|
|
|
if (&runcmd("touch /etc/xCATSN") != 0 ) {
|
2008-10-07 17:48:44 +00:00
|
|
|
$msg = "$::sdate servicenode: Could not touch /etc/xCATSN\n";
|
|
|
|
`logger -t xcat $msg`;
|
2008-08-22 15:02:13 +00:00
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# call copycerts
|
|
|
|
if (&runcmd("/opt/xcat/sbin/copycerts") != 0) {
|
2008-10-07 17:48:44 +00:00
|
|
|
$msg = "$::sdate servicenode: Could not run copycerts.\n";
|
|
|
|
`logger -t xcat $msg`;
|
2008-08-22 15:02:13 +00:00
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
2008-10-07 17:48:44 +00:00
|
|
|
# copy the cfgloc file from /xcatpost
|
|
|
|
if (&runcmd("mkdir -p /etc/xcat")!= 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not make /etc/xcat directory.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $sedcmd = "sed -e 's/host=.*|xcatadmin/host=$servnode|xcatadmin/' /xcatpost/etc/xcat/cfgloc > /etc/xcat/cfgloc";
|
|
|
|
if (&runcmd($sedcmd)!= 0) {
|
|
|
|
$msg = "$::sdate servicenode: Could not copy cfgloc file.\n";
|
|
|
|
`logger -t xcat $msg`;
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
2008-08-22 15:02:13 +00:00
|
|
|
# start xcatd
|
|
|
|
if (&runcmd("/opt/xcat/sbin/xcatd &") != 0) {
|
2008-10-07 17:48:44 +00:00
|
|
|
$msg = "$::sdate servicenode: Could not start xcatd.\n";
|
|
|
|
`logger -t xcat $msg`;
|
2008-08-22 15:02:13 +00:00
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# TODO - add xcatd as system service???
|
|
|
|
# mkssys -s xcatd -p /opt/xcat/sbin/xcatd -u 0 -K
|
|
|
|
|
|
|
|
# add xcatd to /etc/inittab???
|
|
|
|
$mkitab_cmd = 'mkitab "xcatd:2:once:/opt/xcat/sbin/xcatd > /dev/console 2>&1"';
|
|
|
|
# $mkitab_cmd = 'mkitab "xcatd:2:once:/usr/bin/startsrc -s xcatd > /dev/console 2>&1"';
|
|
|
|
|
|
|
|
if (&runcmd($mkitab_cmd) != 0) {
|
2008-10-07 17:48:44 +00:00
|
|
|
$msg = "$::sdate servicenode: Could not add xcatd to /etc/inittab.\n";
|
|
|
|
`logger -t xcat $msg`;
|
2008-08-22 15:02:13 +00:00
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# do nim master setup - master fileset already installed
|
|
|
|
if (&runcmd("nim_master_setup -a mk_resource=no") != 0) {
|
2008-10-07 17:48:44 +00:00
|
|
|
$msg = "$::sdate servicenode: Could not run nim_master_setup.\n";
|
|
|
|
`logger -t xcat $msg`;
|
2008-08-22 15:02:13 +00:00
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($error > 0) {
|
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|