From fdd2c4e60f1b5fd3953d2ab928e9af8105237a96 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 19 Feb 2008 13:39:58 +0000 Subject: [PATCH] This routine copies the required certificate to the service node from the mounted /xcatpost directory during an install of a Service Node. Run from servicenode postinstall script git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@521 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/sbin/copycerts | 129 +++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 xCAT-server-2.0/sbin/copycerts diff --git a/xCAT-server-2.0/sbin/copycerts b/xCAT-server-2.0/sbin/copycerts new file mode 100644 index 000000000..e915362c4 --- /dev/null +++ b/xCAT-server-2.0/sbin/copycerts @@ -0,0 +1,129 @@ +#!/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/x + cat' + : '/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 + +=cut + +#----------------------------------------------------------------------------- + +# if this is a service node +# +# Copy Certificates, and config file to appropriate directories from mounted +# +if (xCAT::Utils->isServiceNode()) +{ + ©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; + if (-d "/xcatpost/.xcat") + { + if (!(-d "/root/.xcat")) + { + mkdir("/root/.xcat", 0600); + } + `cp /xcatpost/.xcat/* /root/.xcat`; + } + else + { + xCAT::MsgUtils->message('S', + "/xcatpost/.xcat directory does not exist\n"); + return 1; + + } + if (-d "/xcatpost/ca") + { + if (!(-d "/etc/xcat")) + { + mkdir("/etc/xcat", 0755); + } + if (!(-d "/etc/xcat/ca")) + { + mkdir("/etc/xcat/ca", 0755); + } + `cp -r /xcatpost/ca/* /etc/xcat/ca`; + } + else + { + xCAT::MsgUtils->message('S', "/xcatpost/ca directory does not exist\n"); + return 1; + + } + if (-d "/xcatpost/cert") + { + if (!(-d "/etc/xcat")) + { + mkdir("/etc/xcat", 0755); + } + if (!(-d "/etc/xcat/cert")) + { + mkdir("/etc/xcat/cert", 0755); + } + `cp -r /xcatpost/cert/* /etc/xcat/cert`; + } + else + { + xCAT::MsgUtils->message('S', + "/xcatpost/cert directory does not exit\n"); + return 1; + + } + if (-d "/xcatpost/sysconfig") + { + `cp /xcatpost/sysconfig/xcat /etc/sysconfig`; + chmod 0600, "/etc/sysconfig/xcat"; + } + else + { + xCAT::MsgUtils->message('S', + "/xcatpost/sysconfig directory does not exit\n"); + return 1; + + } + + # TODO fix for SuSE and AIX + `service postgresql restart`; + `service xcatd restart`; + return $rc; +} +