cleaned up copycerts, added safeguard for conserver startup in CONSsn.pm
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1379 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
971d960030
commit
ed9c761a01
@ -1,140 +1,152 @@
|
||||
#!/usr/bin/env perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#-------------------------------------------------------
|
||||
package xCAT_plugin::CONSsn;
|
||||
use xCAT::Table;
|
||||
|
||||
use xCAT::Utils;
|
||||
use xCAT_plugin::conserver;
|
||||
|
||||
use xCAT::Client;
|
||||
use xCAT::MsgUtils;
|
||||
use Getopt::Long;
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head1
|
||||
xCAT plugin package to setup conserver
|
||||
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 handled_commands
|
||||
|
||||
Check to see if on a Service Node
|
||||
Check database to see if this node is going to have Conserver setup
|
||||
should be always
|
||||
Call setup_CONS
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
sub handled_commands
|
||||
|
||||
{
|
||||
my $rc = 0;
|
||||
if (xCAT::Utils->isServiceNode())
|
||||
{
|
||||
my @nodeinfo = xCAT::Utils->determinehostname;
|
||||
my $nodename = pop @nodeinfo; # get hostname
|
||||
my @nodeipaddr = @nodeinfo; # get ip addresses
|
||||
|
||||
my $service = "conserver";
|
||||
$rc = xCAT::Utils->isServiceReq($nodename, $service, \@nodeipaddr);
|
||||
if ($rc == 1)
|
||||
{
|
||||
|
||||
# service needed on this Service Node
|
||||
$rc = &setup_CONS($nodename); # setup CONS
|
||||
if ($rc == 0)
|
||||
{
|
||||
xCAT::Utils->update_xCATSN($service);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($rc == 2)
|
||||
{ # already setup, just start the daemon
|
||||
# start conserver
|
||||
my $cmd = "/etc/rc.d/init.d/conserver start";
|
||||
system $cmd;
|
||||
if ($? > 0) {
|
||||
xCAT::MsgUtils->message("S", "Error on command: $cmd");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 process_request
|
||||
|
||||
Process the command
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub process_request
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 setup_CONS
|
||||
|
||||
Sets up Conserver
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
sub setup_CONS
|
||||
{
|
||||
my ($nodename) = @_;
|
||||
my $rc = 0;
|
||||
|
||||
|
||||
# make the consever 8 configuration file
|
||||
my $cmdref;
|
||||
$cmdref->{command}->[0] = "makeconservercf";
|
||||
$cmdref->{cwd}->[0] = "/opt/xcat/sbin";
|
||||
$cmdref->{svboot}->[0] = "yes";
|
||||
|
||||
my $modname = "conserver";
|
||||
${"xCAT_plugin::" . $modname . "::"}{process_request}
|
||||
->($cmdref, \&xCAT::Client::handle_response);
|
||||
|
||||
my $cmd = "chkconfig conserver on";
|
||||
system $cmd;
|
||||
if ($? > 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("S", "Error chkconfig conserver on");
|
||||
return 1;
|
||||
}
|
||||
|
||||
# stop conserver
|
||||
my $cmd = "service conserver stop";
|
||||
system $cmd;
|
||||
if ($? > 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("S", "Error stoping Conserver");
|
||||
}
|
||||
|
||||
|
||||
# start conserver
|
||||
$cmd = "service conserver start";
|
||||
system $cmd;
|
||||
if ($? > 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("S", "Error starting Conserver");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return $rc;
|
||||
}
|
||||
|
||||
1;
|
||||
#!/usr/bin/env perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#-------------------------------------------------------
|
||||
package xCAT_plugin::CONSsn;
|
||||
use xCAT::Table;
|
||||
|
||||
use xCAT::Utils;
|
||||
use xCAT_plugin::conserver;
|
||||
|
||||
use xCAT::Client;
|
||||
use xCAT::MsgUtils;
|
||||
use Getopt::Long;
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head1
|
||||
xCAT plugin package to setup conserver
|
||||
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 handled_commands
|
||||
|
||||
Check to see if on a Service Node
|
||||
Check database to see if this node is going to have Conserver setup
|
||||
should be always
|
||||
Call setup_CONS
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
sub handled_commands
|
||||
|
||||
{
|
||||
my $rc = 0;
|
||||
if (xCAT::Utils->isServiceNode())
|
||||
{
|
||||
my @nodeinfo = xCAT::Utils->determinehostname;
|
||||
my $nodename = pop @nodeinfo; # get hostname
|
||||
my @nodeipaddr = @nodeinfo; # get ip addresses
|
||||
|
||||
my $service = "conserver";
|
||||
$rc = xCAT::Utils->isServiceReq($nodename, $service, \@nodeipaddr);
|
||||
if ($rc == 1)
|
||||
{
|
||||
|
||||
# service needed on this Service Node
|
||||
$rc = &setup_CONS($nodename); # setup CONS
|
||||
if ($rc == 0)
|
||||
{
|
||||
xCAT::Utils->update_xCATSN($service);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($rc == 2)
|
||||
{ # already setup, just start the daemon
|
||||
# start conserver
|
||||
my $cmd = "/etc/rc.d/init.d/conserver start";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 process_request
|
||||
|
||||
Process the command
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub process_request
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 setup_CONS
|
||||
|
||||
Sets up Conserver
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
sub setup_CONS
|
||||
{
|
||||
my ($nodename) = @_;
|
||||
my $rc = 0;
|
||||
|
||||
# read DB for nodeinfo
|
||||
my $master;
|
||||
my $os;
|
||||
my $arch;
|
||||
my $cmd;
|
||||
my $retdata = xCAT::Utils->readSNInfo($nodename);
|
||||
if ($retdata->{'arch'})
|
||||
{ # no error
|
||||
$master = $retdata->{'master'};
|
||||
$os = $retdata->{'os'};
|
||||
$arch = $retdata->{'arch'};
|
||||
|
||||
# make the consever 8 configuration file
|
||||
my $cmdref;
|
||||
$cmdref->{command}->[0] = "makeconservercf";
|
||||
$cmdref->{cwd}->[0] = "/opt/xcat/sbin";
|
||||
$cmdref->{svboot}->[0] = "yes";
|
||||
|
||||
my $modname = "conserver";
|
||||
${"xCAT_plugin::" . $modname . "::"}{process_request}
|
||||
->($cmdref, \&xCAT::Client::handle_response);
|
||||
|
||||
my $cmd = "chkconfig conserver on";
|
||||
xCAT::Utils->runcmd($cmd, 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("S", "Error chkconfig conserver on");
|
||||
return 1;
|
||||
}
|
||||
|
||||
# start conserver. conserver needs 2 CA files to start
|
||||
my $ca_file1="/etc/xcat/ca/ca-cert.pem";
|
||||
my $ca_file2="/etc/xcat/cert/server-cred.pem";
|
||||
if (! -e $ca_file1) {
|
||||
print "conserver cannot be started because the file $ca_file1 cannot be found\n";
|
||||
} elsif (! -e $ca_file2) {
|
||||
print "conserver cannot be started because the file $ca_file2 cannot be found\n";
|
||||
} else {
|
||||
my $cmd = "/etc/rc.d/init.d/conserver restart";
|
||||
xCAT::Utils->runcmd($cmd, 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("S", "Error starting Conserver");
|
||||
return 1;
|
||||
} else {
|
||||
print "\nconserver started\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ # error reading Db
|
||||
$rc = 1;
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -1,139 +1,101 @@
|
||||
#!/usr/bin/perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#egan@us.ibm.com
|
||||
#(C)IBM Corp
|
||||
|
||||
#
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT =
|
||||
$ENV{'XCATROOT'} ? $ENV{'XCATROOT'}
|
||||
: -d '/opt/xcat' ? '/opt/xcat'
|
||||
: '/usr';
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
use File::Basename;
|
||||
use Getopt::Long;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::Utils;
|
||||
my $bname = basename($0);
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head1 copycerts
|
||||
|
||||
This updates the service node with files necessary to access the
|
||||
database on the MasterNode and restarts the xcat daemon
|
||||
run from servicenode postinstall script
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
©CertstoSN;
|
||||
|
||||
exit 0;
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 copyCertstoSN
|
||||
|
||||
Copy from the mounted /xcatpost/ directory to the MS /install/postscripts
|
||||
directory the /install/postscripts/ca install/postscripts/cert and
|
||||
/install/postscripts/_xcat into the local file system. These certificate are
|
||||
needed for the postresql db setup for the service node to be able to access
|
||||
the DB from the service node.
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
sub copyCertstoSN
|
||||
{
|
||||
my $rc = 0;
|
||||
`touch /etc/xCATSN`;
|
||||
`touch /tmp/lissatestxxx`;
|
||||
`unalias cp`;
|
||||
if (-d "/xcatpost/_xcat")
|
||||
{
|
||||
if (!(-d "/root/.xcat"))
|
||||
{
|
||||
mkdir("/root/.xcat", 0600);
|
||||
}
|
||||
`cp -rp /xcatpost/_xcat/* /root/.xcat`;
|
||||
`chmod 0600 /root/.xcat/*`;
|
||||
}
|
||||
else
|
||||
{
|
||||
xCAT::MsgUtils->message('S',
|
||||
"/xcatpost/_xcat directory does not exist\n");
|
||||
|
||||
}
|
||||
if (-d "/xcatpost/ca")
|
||||
{
|
||||
if (!(-d "/etc/xcat"))
|
||||
{
|
||||
mkdir("/etc/xcat", 0755);
|
||||
}
|
||||
if (!(-d "/etc/xcat/ca"))
|
||||
{
|
||||
mkdir("/etc/xcat/ca", 0755);
|
||||
}
|
||||
`cp -rp /xcatpost/ca/* /etc/xcat/ca`;
|
||||
`chmod 0600 /etc/xcat/ca/*`;
|
||||
`chmod 0600 /etc/xcat/ca/certs/*`;
|
||||
}
|
||||
else
|
||||
{
|
||||
xCAT::MsgUtils->message('S', "/xcatpost/ca directory does not exist\n");
|
||||
|
||||
}
|
||||
if (-d "/xcatpost/cert")
|
||||
{
|
||||
if (!(-d "/etc/xcat"))
|
||||
{
|
||||
mkdir("/etc/xcat", 0755);
|
||||
}
|
||||
if (!(-d "/etc/xcat/cert"))
|
||||
{
|
||||
mkdir("/etc/xcat/cert", 0755);
|
||||
}
|
||||
`cp -rp /xcatpost/cert/* /etc/xcat/cert`;
|
||||
`chmod 0600 /etc/xcat/cert/*`;
|
||||
}
|
||||
else
|
||||
{
|
||||
xCAT::MsgUtils->message('S',
|
||||
"/xcatpost/cert directory does not exit\n");
|
||||
|
||||
}
|
||||
if (-d "/xcatpost/etc/xcat") {
|
||||
`cp /xcatpost/etc/xcat/cfgloc /etc/xcat/cfgloc`;
|
||||
chmod 0600, "/etc/xcat/cfgloc";
|
||||
}
|
||||
else
|
||||
{
|
||||
xCAT::MsgUtils->message('S',
|
||||
"/xcatpost/etc/xcat directory does not exit\n");
|
||||
|
||||
}
|
||||
if (-d "/xcatpost/etc/sysconfig")
|
||||
{
|
||||
if (!(-d "/etc/sysconfig"))
|
||||
{
|
||||
mkdir("/etc/sysconfig", 0755);
|
||||
}
|
||||
`cp /xcatpost/etc/sysconfig/xcat /etc/sysconfig/xcat`;
|
||||
chmod 0700, "/etc/sysconfig/xcat";
|
||||
}
|
||||
else
|
||||
{
|
||||
xCAT::MsgUtils->message('S',
|
||||
"/xcatpost/etc/sysconfig directory does not exit\n");
|
||||
|
||||
}
|
||||
# TODO fix for SuSE and AIX
|
||||
# `service xcatd restart`;
|
||||
return $rc;
|
||||
}
|
||||
|
||||
#!/usr/bin/perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#egan@us.ibm.com
|
||||
#(C)IBM Corp
|
||||
|
||||
#
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT =
|
||||
$ENV{'XCATROOT'} ? $ENV{'XCATROOT'}
|
||||
: -d '/opt/xcat' ? '/opt/xcat'
|
||||
: '/usr';
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
use File::Basename;
|
||||
use Getopt::Long;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::Utils;
|
||||
my $bname = basename($0);
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head1 copycerts
|
||||
|
||||
This updates the service node with files necessary to access the
|
||||
database on the MasterNode and restarts the xcat daemon
|
||||
run from servicenode postinstall script
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
©CertstoSN;
|
||||
|
||||
exit 0;
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 copyCertstoSN
|
||||
|
||||
Copy from the mounted /xcatpost/ directory to the MS /install/postscripts
|
||||
directory the /install/postscripts/ca install/postscripts/cert and
|
||||
/install/postscripts/_xcat into the local file system. These certificate are
|
||||
needed for the postresql db setup for the service node to be able to access
|
||||
the DB from the service node.
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
sub copyCertstoSN
|
||||
{
|
||||
my $rc = 0;
|
||||
`touch /etc/xCATSN`;
|
||||
if (-d "/xcatpost/_xcat")
|
||||
{
|
||||
if (!(-d "/root/.xcat"))
|
||||
{
|
||||
mkdir("/root/.xcat", 0600);
|
||||
}
|
||||
`cp -f -rp /xcatpost/_xcat/* /root/.xcat`;
|
||||
`chmod 0600 /root/.xcat/*`;
|
||||
}
|
||||
else
|
||||
{
|
||||
xCAT::MsgUtils->message('S',
|
||||
"/xcatpost/_xcat directory does not exist\n");
|
||||
|
||||
}
|
||||
if (-d "/xcatpost/ca")
|
||||
{
|
||||
if (!(-d "/etc/xcat"))
|
||||
{
|
||||
mkdir("/etc/xcat", 0755);
|
||||
}
|
||||
if (!(-d "/etc/xcat/ca"))
|
||||
{
|
||||
mkdir("/etc/xcat/ca", 0755);
|
||||
}
|
||||
`cp -f -rp /xcatpost/ca/* /etc/xcat/ca`;
|
||||
`chmod 0600 /etc/xcat/ca/*`;
|
||||
`chmod 0600 /etc/xcat/ca/certs/*`;
|
||||
}
|
||||
else
|
||||
{
|
||||
xCAT::MsgUtils->message('S', "/xcatpost/ca directory does not exist\n");
|
||||
|
||||
}
|
||||
if (-d "/xcatpost/etc/xcat") {
|
||||
`cp -f /xcatpost/etc/xcat/cfgloc /etc/xcat/cfgloc`;
|
||||
chmod 0600, "/etc/xcat/cfgloc";
|
||||
}
|
||||
else
|
||||
{
|
||||
xCAT::MsgUtils->message('S',
|
||||
"/xcatpost/etc/xcat directory does not exit\n");
|
||||
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user