xcat-core/xCAT-client/bin/rinstall

88 lines
2.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
2014-06-24 11:53:50 +00:00
# Used as a convience command combined of [nodech]-nodeset-rsetboot-rpower-[rcons/wcons]
# to make ease of node OS provision
2014-06-24 11:53:50 +00:00
# This is the client front-end to rinstall/winstall commands
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;
2014-06-24 11:53:50 +00:00
use xCAT::Utils;
use xCAT::Client;
use Cwd;
use strict;
2014-06-24 11:53:50 +00:00
# build a request to go the rinstall plugin
my $bname = basename($0);
my $cmdref;
$cmdref->{command}->[0] = $bname;
$cmdref->{cwd}->[0] = cwd();
# allows our plugins to get the stdin of the cmd that invoked the plugin
my $data;
if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM'}) )
{
my $rin="";
my $rout;
vec($rin,fileno(STDIN),1)=1;
my $nfound=select($rout=$rin,"","",1);
if ($nfound)
{
while ( <STDIN> ) { $data.=$_; }
$cmdref->{stdin}->[0]=$data;
}
}
2014-06-24 11:53:50 +00:00
else
{
2014-06-24 11:53:50 +00:00
if (-p STDIN) {
while ( <STDIN> ) { $data.=$_; }
$cmdref->{stdin}->[0]=$data;
}
}
2014-06-24 11:53:50 +00:00
my $arg;
my @tmpargv = @ARGV;
# first
$arg=shift(@ARGV);
# first 1st non-hyphen arg is the noderange
while ($arg =~ /^-/) {
push (@{$cmdref->{arg}}, $arg);
$arg=shift(@ARGV);
}
2014-06-24 11:53:50 +00:00
$cmdref->{noderange}->[0]=$arg;
push (@{$cmdref->{arg}}, @ARGV);
2014-06-24 11:53:50 +00:00
my $noderange=$cmdref->{noderange}->[0]; # save the noderange
2014-06-24 11:53:50 +00:00
# ok call Client to run the plugin rinstall.pm
xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response);
2014-06-24 11:53:50 +00:00
if ($xCAT::Client::EXITCODE == 0) # no errors
{
my $startconsole=$cmdref->{startconsole}->[0];
# if startconsole requested ( -c flag) for rinstall always for winstall
# This is set in the rinstall plugin
if ($startconsole == 1) {
if (basename($0) =~ /rinstall/) {
exec("rcons $noderange");
}
2014-06-24 11:53:50 +00:00
elsif (basename($0) =~ /winstall/) {
# winstall can commence a wcons command to the noderange for monitoring the provision cycle
2014-06-24 11:53:50 +00:00
exec("wcons $noderange");
}
}
}
2014-06-24 11:53:50 +00:00
exit $xCAT::Client::EXITCODE;