Code drop of supporting the SRC mechanism for xcatd
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4713 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
eda43cb198
commit
2d4e596b3d
@ -81,7 +81,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%else
|
||||
#restart the xcatd on if xCAT or xCATsn is installed already
|
||||
if [ -f $RPM_INSTALL_PREFIX0/sbin/xcatd ]; then
|
||||
XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/xcatstart -r
|
||||
XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/restartxcatd -r
|
||||
fi
|
||||
%endif
|
||||
|
||||
|
@ -849,7 +849,7 @@ sub mysqlreboot
|
||||
}
|
||||
|
||||
$cmd =
|
||||
"awk '{gsub(\"xcatd:2:once:/opt/xcat/sbin/xcatd > /dev/console 2>&1\",\"mysql:2:once:/usr/local/mysql/bin/mysqld_safe --user=mysql \\& \\nxcatd:2:once:/opt/xcat/sbin/xcatd > /dev/console 2>\\&1\"); print}' /etc/inittab > /etc/inittab.xcat";
|
||||
"awk '{gsub(\"xcatd:2:once:/opt/xcat/sbin/restartxcatd > /dev/console 2>&1\",\"mysql:2:once:/usr/local/mysql/bin/mysqld_safe --user=mysql \\& \\nxcatd:2:once:/opt/xcat/sbin/restartxcatd > /dev/console 2>\\&1\"); print}' /etc/inittab > /etc/inittab.xcat";
|
||||
|
||||
xCAT::Utils->runcmd($cmd, 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
@ -1522,7 +1522,7 @@ sub restorexcatdb
|
||||
my $xcmd;
|
||||
if ($::osname eq 'AIX')
|
||||
{
|
||||
$xcmd = "$::XCATROOT/sbin/xcatstart";
|
||||
$xcmd = "$::XCATROOT/sbin/restartxcatd";
|
||||
|
||||
}
|
||||
else
|
||||
|
220
xCAT-server/sbin/restartxcatd
Executable file
220
xCAT-server/sbin/restartxcatd
Executable file
@ -0,0 +1,220 @@
|
||||
#!/usr/bin/perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#(C)IBM Corp
|
||||
|
||||
#
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT =
|
||||
$ENV{'XCATROOT'} ? $ENV{'XCATROOT'}
|
||||
: -d '/opt/xcat' ? '/opt/xcat'
|
||||
: '/usr';
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
use Getopt::Long;
|
||||
use File::Basename;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::Utils;
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head1 startstopxcatd
|
||||
|
||||
|
||||
|
||||
restartxcatd - this routine is used to restart the xcatd processes by
|
||||
startsrc and stopsrc commands.
|
||||
It runs on AIX.
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Main
|
||||
my $cmd = basename($0);
|
||||
if (!(xCAT::Utils->isAIX()))
|
||||
{ # only runs on AIX
|
||||
xCAT::MsgUtils->message("E", "This command should only be run on AIX.\n");
|
||||
exit 1;
|
||||
|
||||
}
|
||||
|
||||
&parse_args($cmd);
|
||||
|
||||
my $rc;
|
||||
my $cmd;
|
||||
my @output;
|
||||
my $inoperative = 0;
|
||||
my $check_num;
|
||||
|
||||
# Check whether the xcatd subsystem has been created
|
||||
$cmd = "/usr/bin/lssrc -s xcatd | grep \"xcatd Subsystem is not on file\"";
|
||||
@output = `$cmd`;
|
||||
if (@output) {
|
||||
xCAT::MsgUtils->message("E", "Cannot find the xcatd subsystem on the Management Node.\n");
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Check the current status of xcatd subsystem
|
||||
$cmd = "lssrc -s xcatd | grep 'xcatd' | grep 'inoperative'";
|
||||
@output = `$cmd`;
|
||||
if (scalar(@output)) {
|
||||
xCAT::MsgUtils->message("I", "xcatd subsystem in inoperative status.\n");
|
||||
$inoperative = 1;
|
||||
}
|
||||
|
||||
if ($inoperative) {
|
||||
# Kill xcatd if needed
|
||||
$cmd = "ps -ef | grep xcatd | grep 'SSL listener'";
|
||||
@output = `$cmd`;
|
||||
foreach my $ps (@output) {
|
||||
$ps =~ s/^\s+//; # strip any leading spaces
|
||||
my ($uid, $pid, $ppid, $desc) = split /\s+/, $ps;
|
||||
$cmd = "/usr/bin/kill -15 -$pid";
|
||||
$rc = system($cmd);
|
||||
if ($rc >> 8) {
|
||||
xCAT::MsgUtils->message("E", "Cannot kill the xcatd processes correctly.\n");
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
$check_num = 10;
|
||||
while ($check_num > 0) {
|
||||
$check_num--;
|
||||
@output = `$cmd`;
|
||||
if (scalar(@output)) {
|
||||
sleep 1;
|
||||
} else {
|
||||
last;
|
||||
}
|
||||
}
|
||||
if ($check_num <= 0) {
|
||||
xCAT::MsgUtils->message("E", "Cannot kill the xcatd processes correctly.\n");
|
||||
exit 1;
|
||||
}
|
||||
} else {
|
||||
# Stop the xcatd subsystem
|
||||
$cmd = "/usr/bin/stopsrc -s xcatd";
|
||||
$rc = system($cmd);
|
||||
if ($rc >> 8) {
|
||||
xCAT::MsgUtils->message("E", "Cannot run stopsrc command correctly.\n");
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Wait for end of the xcatd subsystem
|
||||
$check_num = 10;
|
||||
while ($check_num > 0) {
|
||||
$check_num--;
|
||||
$cmd = "lssrc -s xcatd | grep 'xcatd' | grep 'inoperative'";
|
||||
@output = `$cmd`;
|
||||
if (scalar(@output) == 0) {
|
||||
sleep 1;
|
||||
} else {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_num <= 0) {
|
||||
xCAT::MsgUtils->message("E", "Cannot stop the xcatd subsystem correctly.\n");
|
||||
exit 1;
|
||||
} else {
|
||||
xCAT::MsgUtils->message("I", "Stoped the xcatd subsystem.\n");
|
||||
}
|
||||
}
|
||||
|
||||
# Start the xcatd subsystem
|
||||
$cmd = "/usr/bin/startsrc -s xcatd";
|
||||
|
||||
if ($ENV{XCATRELOAD} || $ENV{XCATROOT} || $ENV{PATH}) {
|
||||
$cmd .= " -e \"";
|
||||
if ($ENV{XCATRELOAD}) {
|
||||
$cmd .= " XCATRELOAD=$ENV{XCATRELOAD}";
|
||||
}
|
||||
if ($ENV{XCATROOT}) {
|
||||
$cmd .= " XCATROOT=$ENV{XCATROOT}";
|
||||
}
|
||||
if ($ENV{PATH}) {
|
||||
$cmd .= " PATH=$ENV{PATH}";
|
||||
}
|
||||
$cmd .= "\"";
|
||||
}
|
||||
$rc = system($cmd);
|
||||
if ($rc >> 8) {
|
||||
xCAT::MsgUtils->message("E", "Cannot run startsrc command correctly.\n");
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Check the status of xcatd subsystem
|
||||
$check_num = 10;
|
||||
while ($check_num > 0) {
|
||||
$check_num--;
|
||||
$cmd = "lssrc -s xcatd | grep 'xcatd' | grep 'active'";
|
||||
my @output = `$cmd`;
|
||||
if (scalar(@output) == 0) {
|
||||
sleep 1;
|
||||
} else {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_num <= 0) {
|
||||
xCAT::MsgUtils->message("E", "Cannot start the xcatd subsystem correctly.\n");
|
||||
exit 1;
|
||||
} else {
|
||||
xCAT::MsgUtils->message("I", "Started the xcatd susbsystem.\n");
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 parse_args
|
||||
|
||||
Parses for input
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
my $usagemsg = "restartxcatd [-h|-v|-r]\n";
|
||||
|
||||
sub parse_args
|
||||
{
|
||||
my ($cmd) = @_;
|
||||
my $msg;
|
||||
my $usagemsg;
|
||||
Getopt::Long::Configure("posix_default");
|
||||
Getopt::Long::Configure("no_gnu_compat");
|
||||
Getopt::Long::Configure("bundling");
|
||||
if (
|
||||
!GetOptions(
|
||||
'h|help' => \$::HELP,
|
||||
'r|reload' => \$::RELOAD,
|
||||
'v|version' => \$::VERSION
|
||||
|
||||
)
|
||||
)
|
||||
{
|
||||
xCAT::MsgUtils->message("E", $usagemsg);
|
||||
exit 1;
|
||||
}
|
||||
if ($::HELP)
|
||||
{
|
||||
xCAT::MsgUtils->message("I", $usagemsg);
|
||||
exit 0;
|
||||
}
|
||||
if ($::RELOAD)
|
||||
{
|
||||
$ENV{XCATRELOAD} = "yes";
|
||||
}
|
||||
if ($::VERSION)
|
||||
{
|
||||
my $version = xCAT::Utils->Version();
|
||||
$version .="\n";
|
||||
xCAT::MsgUtils->message("I", $version);
|
||||
exit 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -258,10 +258,18 @@ if ($::INITIALINSTALL || $::FORCE || $::UPDATEINSTALL)
|
||||
|
||||
&setupAIXIPMITool;
|
||||
|
||||
# Add the xcatd subsystem to the AIX
|
||||
no strict 'refs';
|
||||
my $mkssys_cmd = "mkssys -p $::XCATROOT/sbin/xcatd -s xcatd -u 0 -S -n 15 -f 15 -a \"-f\"";
|
||||
system($mkssys_cmd);
|
||||
use strict;
|
||||
|
||||
# for AIX systems add xcatd to the /etc/inittab file
|
||||
my $rmitab_cmd = "rmitab xcatd";
|
||||
system($rmitab_cmd);
|
||||
my $mkitab_cmd =
|
||||
'mkitab "xcatd:2:once:/opt/xcat/sbin/xcatd > /dev/console 2>&1" > /dev/null 2>&1';
|
||||
my $rc = system($mkitab_cmd); # may already be there no error check
|
||||
"mkitab \"xcatd:2:once:$::XCATROOT/sbin/restartxcatd > /dev/console 2>&1\" > /dev/null 2>&1";
|
||||
my $rc = system($mkitab_cmd);
|
||||
|
||||
# add AIX needed exports
|
||||
&setupAIXexports;
|
||||
@ -319,15 +327,13 @@ if ($::INITIALINSTALL || $::FORCE || $::UPDATEINSTALL || $::genCredentials)
|
||||
my $xcmd;
|
||||
if ($::osname eq 'AIX')
|
||||
{
|
||||
$xcmd = "$::XCATROOT/sbin/xcatstart";
|
||||
|
||||
$xcmd = "$::XCATROOT/sbin/restartxcatd";
|
||||
}
|
||||
else
|
||||
{
|
||||
$xcmd = "/etc/init.d/xcatd restart";
|
||||
}
|
||||
system($xcmd);
|
||||
|
||||
}
|
||||
|
||||
# more - Linux-only config
|
||||
|
@ -511,6 +511,9 @@ sub plugin_reaper {
|
||||
}
|
||||
|
||||
$SIG{CHLD} = \&generic_reaper;
|
||||
|
||||
my $pid_UDP;
|
||||
my $pid_MON;
|
||||
$SIG{TERM} = $SIG{INT} = sub {
|
||||
printf("Asked to quit...\n");
|
||||
$quit++;
|
||||
@ -520,20 +523,30 @@ $SIG{TERM} = $SIG{INT} = sub {
|
||||
foreach (keys %plugin_children) {
|
||||
kill 2, $_;
|
||||
}
|
||||
if ($pid_UDP) {
|
||||
kill 2, $pid_UDP;
|
||||
}
|
||||
if ($pid_MON) {
|
||||
kill 2, $pid_MON;
|
||||
}
|
||||
xCAT::Table::shut_dbworker;
|
||||
if ($dbmaster) {
|
||||
kill 2, $dbmaster;
|
||||
}
|
||||
$SIG{ALRM} = sub { xexit 0; }; #die "Did not close out in time for 5 second grace period"; };
|
||||
alarm(2);
|
||||
};
|
||||
|
||||
my $pid = xCAT::Utils->xfork;
|
||||
defined $pid or die "Unable to fork for UDP/TCP";
|
||||
unless ($pid) {
|
||||
$pid_UDP = xCAT::Utils->xfork;
|
||||
defined $pid_UDP or die "Unable to fork for UDP/TCP";
|
||||
unless ($pid_UDP) {
|
||||
$$progname="xcatd: UDP listener";
|
||||
do_udp_service;
|
||||
xexit(0);
|
||||
}
|
||||
$pid = xCAT::Utils->xfork;
|
||||
defined $pid or die "Unable to fork installmonitor";
|
||||
unless ($pid) {
|
||||
$pid_MON = xCAT::Utils->xfork;
|
||||
defined $pid_MON or die "Unable to fork installmonitor";
|
||||
unless ($pid_MON) {
|
||||
$$progname="xcatd: install monitor";
|
||||
do_installm_service;
|
||||
xexit(0);
|
||||
@ -556,7 +569,12 @@ if ($inet6support) {
|
||||
}
|
||||
|
||||
unless ($listener) {
|
||||
kill 2, $pid;
|
||||
kill 2, $pid_UDP;
|
||||
kill 2, $pid_MON;
|
||||
xCAT::Table::shut_dbworker;
|
||||
if ($dbmaster) {
|
||||
kill 2, $dbmaster;
|
||||
}
|
||||
xCAT::MsgUtils->message("S","xCAT service unable to open SSL services on $port: $!");
|
||||
closelog();
|
||||
die "ERROR:Unable to start xCAT service on port $port.";
|
||||
|
@ -71,8 +71,6 @@ chmod -h 755 $RPM_BUILD_ROOT/%{prefix}/sbin/*
|
||||
cp -h bin/* $RPM_BUILD_ROOT/%{prefix}/bin
|
||||
chmod -h 755 $RPM_BUILD_ROOT/%{prefix}/bin/*
|
||||
%endif
|
||||
ln -sf ../sbin/stopstartxcatd $RPM_BUILD_ROOT/%{prefix}/sbin/xcatstart
|
||||
ln -sf ../sbin/stopstartxcatd $RPM_BUILD_ROOT/%{prefix}/sbin/xcatstop
|
||||
#cp rc.d/* $RPM_BUILD_ROOT/%{prefix}/rc.d
|
||||
#chmod 755 $RPM_BUILD_ROOT/%{prefix}/rc.d/*
|
||||
|
||||
@ -97,6 +95,7 @@ set -x
|
||||
|
||||
# For now, don't ship these plugins - to avoid AIX dependency.
|
||||
%ifnos linux
|
||||
rm $RPM_BUILD_ROOT/%{prefix}/sbin/stopstartxcatd
|
||||
#rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/blade.pm
|
||||
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/hpblade.pm
|
||||
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/hpilo.pm
|
||||
@ -186,7 +185,8 @@ fi
|
||||
if [ "$1" -gt "1" ]; then #only on upgrade for AIX...
|
||||
#migration issue for monitoring
|
||||
XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab filename=monitorctrl.pm notification -d
|
||||
XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/xcatstart -r
|
||||
|
||||
XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/restartxcatd -r
|
||||
fi
|
||||
%endif
|
||||
|
||||
|
@ -162,24 +162,31 @@ sub setupAIXsn
|
||||
`logger -t xcat $msg`;
|
||||
}
|
||||
|
||||
# get the xCAT credentials from the server
|
||||
# get the xCAT credentials from the server
|
||||
&getcreds;
|
||||
|
||||
# Add the xcatd subsystem to the AIX
|
||||
my $mkssys_cmd = 'mkssys -p /opt/xcat/sbin/xcatd -s xcatd -u 0 -S -n 15 -f 15 -a "-f"';
|
||||
if (&runcmd($mkssys_cmd) != 0) {
|
||||
$msg = "$::sdate servicenode: Could not create subsystem for xcatd. It maybe already have been added.\n";
|
||||
`logger -t xcat $msg`;
|
||||
}
|
||||
|
||||
# start xcatd
|
||||
if (&runcmd("/opt/xcat/sbin/xcatd &") != 0) {
|
||||
if (&runcmd("/opt/xcat/sbin/restartxcatd") != 0) {
|
||||
$msg = "$::sdate servicenode: Could not start xcatd.\n";
|
||||
`logger -t xcat $msg`;
|
||||
}
|
||||
`logger -t xcat $msg`;
|
||||
}
|
||||
|
||||
# add xcatd to /etc/inittab???
|
||||
my $mkitab_cmd = 'mkitab "xcatd:2:once:/opt/xcat/sbin/xcatd > /dev/console 2>&1"';
|
||||
my $mkitab_cmd = 'mkitab "xcatd:2:once:/opt/xcat/sbin/restartxcatd > /dev/console 2>&1"';
|
||||
|
||||
if (&runcmd($mkitab_cmd) != 0) {
|
||||
# error might just mean that the entry is already there!
|
||||
|
||||
# $msg = "$::sdate servicenode: Could not add xcatd to /etc/inittab.\n";
|
||||
# `logger -t xcat $msg`;
|
||||
}
|
||||
# `logger -t xcat $msg`;
|
||||
}
|
||||
|
||||
# set ulimit - so we can copy over large files - like spot
|
||||
if (&runcmd("/usr/bin/chuser fsize=-1 root") != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user