Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a2fd2f436 | ||
|
|
8d7cda14ab | ||
|
|
028cea62e1 | ||
|
|
ef9955b577 | ||
|
|
63168b5b12 | ||
|
|
94e5ed288d | ||
|
|
1350a6faea | ||
|
|
372a6ab44a | ||
|
|
a2c2f2010a | ||
| 9738889e22 | |||
| 4788142cab |
1
makerpm
1
makerpm
@@ -85,6 +85,7 @@ function makexcat {
|
||||
cd `dirname $0`/$RPMNAME
|
||||
tar --exclude .svn -czf $RPMROOT/SOURCES/license.tar.gz LICENSE.html
|
||||
cp xcat.conf $RPMROOT/SOURCES
|
||||
cp xcat.conf.apach24 $RPMROOT/SOURCES
|
||||
cp xCATSN $RPMROOT/SOURCES
|
||||
cd - >/dev/null
|
||||
elif [ "$RPMNAME" = "xCAT-buildkit" ]; then
|
||||
|
||||
@@ -532,7 +532,7 @@ nodegroup => {
|
||||
},
|
||||
},
|
||||
nodehm => {
|
||||
cols => [qw(node power mgt cons termserver termport conserver serialport serialspeed serialflow getmac cmdmapping comments disable)],
|
||||
cols => [qw(node power mgt cons termserver termport conserver serialport serialspeed serialflow getmac cmdmapping consoleondemand comments disable)],
|
||||
keys => [qw(node)],
|
||||
tablespace =>'XCATTBS16K',
|
||||
table_desc => "Settings that control how each node's hardware is managed. Typically, an additional table that is specific to the hardware type of the node contains additional info. E.g. the ipmi, mp, and ppc tables.",
|
||||
@@ -549,6 +549,7 @@ nodehm => {
|
||||
serialflow => "The flow control value of the serial port for this node. For SOL this is typically 'hard'.",
|
||||
getmac => 'The method to use to get MAC address of the node with the getmac command. If not set, the mgt attribute will be used. Valid values: same as values for mgmt attribute.',
|
||||
cmdmapping => 'The fully qualified name of the file that stores the mapping between PCM hardware management commands and xCAT/third-party hardware management commands for a particular type of hardware device. Only used by PCM.',
|
||||
consoleondemand => 'This overrides the value from site.consoleondemand; (0=no, 1=yes). Default is the result from site.consoleondemand.',
|
||||
comments => 'Any user-written notes.',
|
||||
disable => "Set to 'yes' or '1' to comment out this row.",
|
||||
},
|
||||
@@ -1933,6 +1934,10 @@ my @nodeattrs = (
|
||||
{attr_name => 'serialflow',
|
||||
tabentry => 'nodehm.serialflow',
|
||||
access_tabentry => 'nodehm.node=attr:node',
|
||||
},
|
||||
{attr_name => 'consoleondemand',
|
||||
tabentry => 'nodehm.consoleondemand',
|
||||
access_tabentry => 'nodehm.node=attr:node',
|
||||
},
|
||||
##################
|
||||
# vpd table #
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# AIX Bundle file for compiler runtime packages
|
||||
|
||||
I:xlC.aix61
|
||||
I:xlC.rte
|
||||
I:xlfrte
|
||||
I:xlfrte.aix61
|
||||
I:xlfrte.msg.en_US
|
||||
I:xlsmp.aix61.rte
|
||||
I:xlsmp.msg.en_US.rte
|
||||
I:xlsmp.rte
|
||||
@@ -662,11 +662,7 @@ sub mknetboot
|
||||
$kcmdline = "NFSROOT=$nfssrv:$nfsdir STATEMNT=";
|
||||
}
|
||||
} else {
|
||||
if (-r "$rootimgdir/rootimg-statelite.gz.metainfo") {
|
||||
$kcmdline = "imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg-statelite.gz.metainfo STATEMNT=";
|
||||
} else {
|
||||
$kcmdline = "imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg-statelite.gz STATEMNT=";
|
||||
}
|
||||
$kcmdline = "imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg-statelite.gz STATEMNT=";
|
||||
}
|
||||
|
||||
# add support for subVars in the value of "statemnt"
|
||||
@@ -728,13 +724,8 @@ sub mknetboot
|
||||
$kcmdline .= "NODE=$node ";
|
||||
}
|
||||
else {
|
||||
if (-r "$rootimgdir/rootimg.$suffix.metainfo") {
|
||||
$kcmdline =
|
||||
"imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg.$suffix.metainfo ";
|
||||
} else {
|
||||
$kcmdline =
|
||||
"imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg.$suffix ";
|
||||
}
|
||||
$kcmdline =
|
||||
"imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg.$suffix ";
|
||||
$kcmdline .= "XCAT=$xcatmaster:$xcatdport ";
|
||||
$kcmdline .= "NODE=$node ";
|
||||
# add flow control setting
|
||||
|
||||
@@ -12,6 +12,7 @@ use strict;
|
||||
use Data::Dumper;
|
||||
my @cservers = qw(mrv cyclades);
|
||||
my %termservers; #list of noted termservers
|
||||
my $siteondemand; # The site value for consoleondemand
|
||||
|
||||
my $usage_string=
|
||||
" makeconservercf [-d|--delete] noderange
|
||||
@@ -276,6 +277,10 @@ sub docfheaders {
|
||||
my $site_entry = $entries[0];
|
||||
if ( defined($site_entry) and $site_entry eq "yes" ) {
|
||||
push @newheaders," options ondemand;\n";
|
||||
$siteondemand=1;
|
||||
}
|
||||
else {
|
||||
$siteondemand=0;
|
||||
}
|
||||
|
||||
push @newheaders,"}\n";
|
||||
@@ -322,7 +327,7 @@ sub makeconservercf {
|
||||
my $hmtab = xCAT::Table->new('nodehm');
|
||||
my @cfgents1;# = $hmtab->getAllNodeAttribs(['cons','serialport','mgt','conserver','termserver','termport']);
|
||||
if (($nodes and @$nodes > 0) or $req->{noderange}->[0]) {
|
||||
@cfgents1 = $hmtab->getNodesAttribs($nodes,['node','cons','serialport','mgt','conserver','termserver','termport']);
|
||||
@cfgents1 = $hmtab->getNodesAttribs($nodes,['node','cons','serialport','mgt','conserver','termserver','termport','consoleondemand']);
|
||||
# Adjust the data structure to make the result consistent with the getAllNodeAttribs() call we make if a noderange was not specified
|
||||
my @tmpcfgents1;
|
||||
foreach my $ent (@cfgents1)
|
||||
@@ -335,7 +340,7 @@ sub makeconservercf {
|
||||
@cfgents1 = @tmpcfgents1
|
||||
|
||||
} else {
|
||||
@cfgents1 = $hmtab->getAllNodeAttribs(['cons','serialport','mgt','conserver','termserver','termport']);
|
||||
@cfgents1 = $hmtab->getAllNodeAttribs(['cons','serialport','mgt','conserver','termserver','termport','consoleondemand']);
|
||||
}
|
||||
|
||||
|
||||
@@ -538,6 +543,14 @@ foreach my $node (sort keys %$cfgenthash) {
|
||||
push @$content," exec $locerror".$::XCATROOT."/share/xcat/cons/".$cmeth." ".$node.";\n"
|
||||
}
|
||||
}
|
||||
if (defined($cfgent->{consoleondemand})) {
|
||||
if ($cfgent->{consoleondemand} && !$siteondemand ) {
|
||||
push @$content," options ondemand;\n";
|
||||
}
|
||||
elsif (!$cfgent->{consoleondemand} && $siteondemand ) {
|
||||
push @$content," options !ondemand;\n";
|
||||
}
|
||||
}
|
||||
push @$content,"}\n";
|
||||
push @$content,"#xCAT END $node CONS\n";
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
# This plugin is used to handle the command requests for Xeon Phi (mic) support
|
||||
#
|
||||
|
||||
|
||||
package xCAT_plugin::mic;
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
@@ -612,6 +614,11 @@ sub rflash {
|
||||
# run the cmd on the host to flash the mic
|
||||
my @args = ("-s", "-v", "-e");
|
||||
push @args, "$::XCATROOT/sbin/flashmic";
|
||||
my $master = $request->{'_xcatdest'};
|
||||
# in case there are multiple servicenode entries, assume the first entry
|
||||
# is the master
|
||||
($master) = split (/,/,$master);
|
||||
|
||||
# assume that all hosts are on the same network connected to this master
|
||||
# (otherwise, will need to move this call into loop above for each host
|
||||
# and build separate miccfg calls for each unique returned value from
|
||||
@@ -630,7 +637,6 @@ sub rflash {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
push @args, ("-m", "$master");
|
||||
push @args, ("-p", "$tftpdir/xcat/miccfg");
|
||||
|
||||
@@ -930,6 +936,11 @@ sub nodeset {
|
||||
# run the cmd on the host to configure the mic
|
||||
my @args = ("-s", "-v", "-e");
|
||||
push @args, "$::XCATROOT/sbin/configmic";
|
||||
my $master = $request->{'_xcatdest'};
|
||||
# in case there are multiple servicenode entries, assume the first entry
|
||||
# is the master
|
||||
($master) = split (/,/,$master);
|
||||
|
||||
# assume that all hosts are on the same network connected to this master
|
||||
# (otherwise, will need to move this call into loop above for each host
|
||||
# and build separate miccfg calls for each unique returned value from
|
||||
|
||||
@@ -51,14 +51,12 @@ sub process_request {
|
||||
my $rootimg_dir;
|
||||
my $destdir;
|
||||
my $imagename;
|
||||
my $dotorrent;
|
||||
|
||||
GetOptions(
|
||||
"profile|p=s" => \$profile,
|
||||
"arch|a=s" => \$arch,
|
||||
"osver|o=s" => \$osver,
|
||||
"method|m=s" => \$method,
|
||||
"tracker=s" => \$dotorrent,
|
||||
"help|h" => \$help,
|
||||
"version|v" => \$version
|
||||
);
|
||||
@@ -388,14 +386,6 @@ sub process_request {
|
||||
`$excludestr`;
|
||||
if ($method =~ /cpio/) {
|
||||
chmod 0644,"$destdir/rootimg.gz";
|
||||
if ($dotorrent) {
|
||||
my $currdir = getcwd;
|
||||
chdir($destdir);
|
||||
unlink("rootimg.gz.metainfo");
|
||||
system("ctorrent -t -u $dotorrent -l 1048576 -s rootimg.gz.metainfo rootimg.gz");
|
||||
chmod 0644, "rootimg.gz.metainfo";
|
||||
chdir($currdir);
|
||||
}
|
||||
umask $oldmask;
|
||||
} elsif ($method =~ /squashfs/) {
|
||||
my $flags;
|
||||
|
||||
@@ -2120,7 +2120,6 @@ sub validate_node_entry{
|
||||
$errmsg .= "MAC address $node_entry{$_} is invalid. You must use a valid MAC address.\n";
|
||||
}else{
|
||||
$allmacs{$node_entry{$_}} = 0;
|
||||
$allmacsupper{uc($node_entry{$_})} = 0;
|
||||
}
|
||||
}elsif ($_ eq "ip"){
|
||||
if (exists $allips{$node_entry{$_}}){
|
||||
|
||||
@@ -67,7 +67,6 @@ sub process_request {
|
||||
my $exlist; # it is used when rootfstype = ramdisk
|
||||
my $destdir;
|
||||
my $imagename;
|
||||
my $dotorrent;
|
||||
|
||||
GetOptions(
|
||||
"rootfstype|t=s" => \$rootfstype,
|
||||
@@ -75,7 +74,6 @@ sub process_request {
|
||||
"arch|a=s" => \$arch,
|
||||
"osver|o=s" => \$osver,
|
||||
"help|h" => \$help,
|
||||
"tracker" => \$dotorrent,
|
||||
"version|v" => \$version,
|
||||
"verbose|V" => \$verbose
|
||||
);
|
||||
@@ -536,14 +534,6 @@ sub process_request {
|
||||
chdir("$rootimg_dir");
|
||||
xCAT::Utils->runcmd("$excludestr");
|
||||
chmod 0644, "$destdir/rootimg-statelite.gz";
|
||||
if ($dotorrent) {
|
||||
my $currdir = getcwd;
|
||||
chdir($destdir);
|
||||
unlink("rootimg-statelite.gz.metainfo");
|
||||
system("ctorrent -t -u $dotorrent -l 1048576 -s rootimg-statelite.gz.metainfo rootimg.gz");
|
||||
chmod 0644, "rootimg-statelite.gz.metainfo";
|
||||
chdir($currdir);
|
||||
}
|
||||
umask $oldmask;
|
||||
|
||||
system("rm -f $xcat_packimg_tmpfile");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/bin/sh
|
||||
echo $drivers
|
||||
dracut_install wget cpio gzip dash modprobe touch echo cut wc
|
||||
dracut_install -o ctorrent
|
||||
dracut_install wget cpio gzip dash modprobe touch echo cut wc
|
||||
dracut_install grep ifconfig hostname awk egrep grep dirname expr
|
||||
dracut_install mount.nfs
|
||||
dracut_install parted mke2fs bc mkswap swapon chmod
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/bin/sh
|
||||
echo $drivers
|
||||
dracut_install wget cpio gzip dash modprobe wc touch echo cut
|
||||
dracut_install -o ctorrent
|
||||
dracut_install grep ifconfig hostname awk egrep grep dirname expr
|
||||
dracut_install parted mke2fs bc mkswap swapon chmod
|
||||
inst "$moddir/xcat-updateflag" "/tmp/updateflag"
|
||||
|
||||
@@ -45,9 +45,6 @@ if [ ! -z "$imgurl" ]; then
|
||||
fi
|
||||
#echo 0 > /proc/sys/vm/zone_reclaim_mode #Avoid kernel bug
|
||||
|
||||
if [ -r /*.metainfo ]; then
|
||||
ctorrent /*.metainfo -e 0
|
||||
fi
|
||||
if [ -r /rootimg.sfs ]; then
|
||||
echo Setting up squashfs with ram overlay.
|
||||
mknod /dev/loop0 b 7 0
|
||||
|
||||
@@ -29,16 +29,16 @@ if [%3] EQU [bcdonly] set BCDONLY=1
|
||||
if [%WINPENAME%] NEQ [] set BOOTPATH=winboot\%WINPENAME%\Boot
|
||||
|
||||
::location where Windows PE from ADK install is located
|
||||
set adkpedir=%defdrive%\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment
|
||||
set oscdimg=%defdrive%\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg
|
||||
set adkpedir=%defdrive%\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment
|
||||
set oscdimg=%defdrive%\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg
|
||||
set WinPERoot=%adkpedir%
|
||||
set OSCDImgRoot=%oscdimg%
|
||||
set Path=C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\amd64\DISM;%Path%
|
||||
set Path=C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools\amd64\DISM;%Path%
|
||||
|
||||
::clean the c:\winPE_amd64 and copy it from ADK
|
||||
if exist %defdrive%\WinPE_%SUFFIX% rd %defdrive%\WinPE_%SUFFIX% /s /q
|
||||
set retpath=%cd%
|
||||
cd /d "%adkpedir%"
|
||||
cd "%adkpedir%"
|
||||
call copype.cmd %ARCH% %defdrive%\WinPE_%SUFFIX%
|
||||
cd /d %retpath%
|
||||
|
||||
@@ -70,8 +70,8 @@ rem copy "%defdrive%\Program Files\Windows AIK\Tools\%ARCH%\imagex.exe" %defdriv
|
||||
dism /Image:%defdrive%\WinPE_%SUFFIX%\mount /add-package /packagepath:"%adkpedir%\amd64\WinPE_OCs\WinPE-WMI.cab"
|
||||
dism /Image:%defdrive%\WinPE_%SUFFIX%\mount /add-package /packagepath:"%adkpedir%\amd64\WinPE_OCs\WinPE-Scripting.cab"
|
||||
dism /Image:%defdrive%\WinPE_%SUFFIX%\mount /add-package /packagepath:"%adkpedir%\amd64\WinPE_OCs\WinPE-RNDIS.cab"
|
||||
dism /Image:%defdrive%\WinPE_%SUFFIX%\mount /add-package /packagepath:"%adkpedir%\amd64\WinPE_OCs\WinPE-NetFX.cab"
|
||||
dism /Image:%defdrive%\WinPE_%SUFFIX%\mount /add-package /packagepath:"%adkpedir%\amd64\WinPE_OCs\WinPE-PowerShell.cab"
|
||||
dism /Image:%defdrive%\WinPE_%SUFFIX%\mount /add-package /packagepath:"%adkpedir%\amd64\WinPE_OCs\WinPE-NetFX4.cab"
|
||||
dism /Image:%defdrive%\WinPE_%SUFFIX%\mount /add-package /packagepath:"%adkpedir%\amd64\WinPE_OCs\WinPE-PowerShell3.cab"
|
||||
dism /Image:%defdrive%\WinPE_%SUFFIX%\mount /add-package /packagepath:"%adkpedir%\amd64\WinPE_OCs\WinPE-DismCmdlets.cab"
|
||||
dism /Image:%defdrive%\WinPE_%SUFFIX%\mount /add-package /packagepath:"%adkpedir%\amd64\WinPE_OCs\WinPE-StorageWMI.cab"
|
||||
dism /Image:%defdrive%\WinPE_%SUFFIX%\mount /add-package /packagepath:"%adkpedir%\amd64\WinPE_OCs\WinPE-WDS-Tools.cab"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# -n hostname
|
||||
# Flags are used for check output:
|
||||
# -o expected output
|
||||
# -O logical operator
|
||||
# -l logical operator
|
||||
#
|
||||
# Expected result format is '{ANY:{ANY:content}}'
|
||||
# These steps are used to explain how to scan result
|
||||
@@ -30,7 +30,7 @@ BEGIN
|
||||
{
|
||||
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
||||
}
|
||||
use Getopt::Long qw{:config bundling no_ignore_case};
|
||||
use Getopt::Long;
|
||||
use Data::Dumper;
|
||||
use strict;
|
||||
my $help;
|
||||
@@ -64,7 +64,7 @@ if (
|
||||
"c=s" => \$cert,
|
||||
"n=s" => \$hostname,
|
||||
"o=s" => \$output,
|
||||
"O=s" => \$loperator,
|
||||
"l=s" => \$loperator,
|
||||
"debug" => \$debug,
|
||||
)
|
||||
) {
|
||||
@@ -181,8 +181,8 @@ sub usage
|
||||
print " testrestapi [-m method] [-r resource] [-t tocken]\n";
|
||||
print " [-h host] [-P port][-u user] [-p passwd]\n";
|
||||
print " [-d data] [-c cert] [-n hostname]\n";
|
||||
print " [-o expect_output] [-O logical_operator] \n";
|
||||
print " [--debug]\n";
|
||||
print " [-o expect_output] [-l logical_operator] [-debug]\n";
|
||||
print " [-debug]\n";
|
||||
print "\n";
|
||||
return;
|
||||
}
|
||||
@@ -333,7 +333,7 @@ sub parse_json
|
||||
my @all = split /,/, $content;
|
||||
foreach my $n (@all) {
|
||||
$n =~ /\"(.*)\"/;
|
||||
$hash{$1} = "restapiarray";
|
||||
$hash{$1} = 1;
|
||||
}
|
||||
return \%hash;
|
||||
}
|
||||
@@ -402,13 +402,9 @@ sub check_result
|
||||
my @actualvalue = split /:/, $actual; # @actualvalue = nodetype, arch, x86_64
|
||||
print_debug("begin to compare $expval and $actualvalue[$flag]");
|
||||
|
||||
if(($expval eq "restapiarray" ) and ($actualvalue[$flag] eq "restapiarray")){
|
||||
next;
|
||||
}
|
||||
|
||||
if(($expval eq $actualvalue[$flag]) or ($expval eq "ANY")) { #ANY =~ nodetype
|
||||
$flaghash{$actual} = "eq";
|
||||
} elsif (($actualvalue[$flag] =~ $expval) or ($expval eq "ANY")) {
|
||||
} elsif (($expval =~ $actualvalue[$flag]) or ($expval eq "ANY")) {
|
||||
$flaghash{$actual} = "match";
|
||||
} else {
|
||||
$flaghash{$actual} = "none";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# IBM(c) 2011EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@@ -6,10 +6,26 @@
|
||||
#=head2 routeop is called by makeroutes command and setuproutes postscript to
|
||||
# setup a route on a node.
|
||||
# The syntax is:
|
||||
# routeop add/delete net mask gateway ifname
|
||||
# routeop add/delete net mask gateway ifnamea #NOTE: the add/delete will be
|
||||
# obsoleted, using 'replace' is recommended.
|
||||
# routeop replace net mask gateway ifname #NOTE: it only works for sles so far
|
||||
# net - IP of net like 192.168.1.0. The keyword
|
||||
# 'default' is used to set the default route.
|
||||
# mask - The length of the netmask (CIDR) like 8,16,24 OR
|
||||
# the dotted-decimal format like 255.255.0.0
|
||||
# gateway - The next hop. It could be set to 0.0.0.0 for omitting
|
||||
# ifname - The interface to route to the next hop
|
||||
#=head3 example
|
||||
# routeop replace default 0 10.1.0.209 eth0
|
||||
# routeop replace 50.1.0.0 16 10.1.0.210 eth0
|
||||
# routeop replace 60.1.1.0 24 0.0.0.0 eth0
|
||||
# routeop replace 70.1.1.0 24 10.1.0.211 #NOTE: this is NOT supported for redhat
|
||||
#=cut
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
str_dir_name=`dirname $0`
|
||||
. $str_dir_name/xcatlib.sh
|
||||
|
||||
op=$1
|
||||
|
||||
net=$2
|
||||
@@ -19,6 +35,25 @@ if [ -n "$5" ]; then
|
||||
ifname=$5
|
||||
fi
|
||||
|
||||
# use nummask to know whether the netmask format is 255.255.255.0 or CIDR (a number)
|
||||
nummask=0
|
||||
echo $mask | egrep "^[.0123456789]+$" > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: invalid format of netmask $mask."
|
||||
exit 1
|
||||
else
|
||||
echo $mask | egrep "^[0123456789]+$" > /dev/null
|
||||
if [ $? -eq 0 ]; then # only has digital
|
||||
nummask=1 # the netmask is the length of network mask.
|
||||
if [ $mask -ge 128 ]; then
|
||||
echo "Error: invalid format of netmask $mask."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
function debianpreconf(){
|
||||
#create the config sub dir
|
||||
if [ ! -d "/etc/network/interfaces.d" ];then
|
||||
@@ -143,6 +178,238 @@ route_exists()
|
||||
echo $ret
|
||||
}
|
||||
|
||||
# handle the route replace operation that adding the setting to configuration file
|
||||
replace_persistent_route()
|
||||
{
|
||||
net=$1;
|
||||
mask=$2;
|
||||
gw=$3;
|
||||
if [ -n "$4" ]; then
|
||||
ifname=$4
|
||||
fi
|
||||
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
#determine the os name
|
||||
OS_name="something"
|
||||
if [ -f /etc/redhat-release ]
|
||||
then
|
||||
OS_name="redhat" #it can be RedHatFerdora or CentOS
|
||||
elif [ -f /etc/SuSE-release ]
|
||||
then
|
||||
OS_name="sles"
|
||||
else
|
||||
OS_name="debian"
|
||||
fi
|
||||
|
||||
# The replace operation does not support debain so far
|
||||
if [ "$OS_name" != "redhat" ] && [ "$OS_name" != "sles" ]; then
|
||||
echo "Warning: replace operation only supports to add persistent route for sles and redhat by now."
|
||||
return
|
||||
fi
|
||||
|
||||
# set the destination of the route for searching in the route configuration file
|
||||
if [ "$net" = "default" ]; then
|
||||
routedest="default"
|
||||
routedest1="default"
|
||||
else
|
||||
routedest="$net/$mask"
|
||||
routedest1="$net\/$mask"
|
||||
fi
|
||||
|
||||
case $OS_name in
|
||||
sles)
|
||||
filename="/etc/sysconfig/network/routes";
|
||||
if echo $net | grep : 2>&1 1>/dev/null
|
||||
then
|
||||
# for ipv6
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
route="$net/$mask :: - $ifname"
|
||||
route1="$net\/$mask :: - $ifname";
|
||||
else
|
||||
route="$net/$mask $gw - -"
|
||||
route1="$net\/$mask $gw - -";
|
||||
fi
|
||||
else
|
||||
# for ipv4
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
if [ "$net" = "default" ]; then
|
||||
route="default - - $ifname";
|
||||
route1="default - - $ifname";
|
||||
else
|
||||
route="$net/$mask - - $ifname";
|
||||
route1="$net\/$mask - - $ifname";
|
||||
fi
|
||||
else
|
||||
if [ "$net" = "default" ]; then
|
||||
route="default $gw - $ifname";
|
||||
route1="default $gw - $ifname";
|
||||
else
|
||||
route="$net/$mask $gw - $ifname";
|
||||
route1="$net\/$mask $gw - $ifname";
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -f $filename ]; then
|
||||
egrep "^$routedest" $filename 2>&1 1>/dev/null
|
||||
if [ $? -ne 0 ]; then #route does not exist
|
||||
echo $route >> $filename
|
||||
echo "Persistent route \"$route\" has been added in $filename."
|
||||
else
|
||||
# replace it
|
||||
sed -i -e "s/$routedest1.*/$route1/g" $filename
|
||||
echo "Persistent route \"$route\" has been replaced in $filename."
|
||||
fi
|
||||
else
|
||||
echo "$route" > $filename
|
||||
echo "Persistent route \"$route\" has been added in $filename."
|
||||
fi
|
||||
;;
|
||||
|
||||
redhat)
|
||||
#echo "rh/fedora/centos"
|
||||
if [ -z "$ifname" ]; then
|
||||
echo "Error: the device name is necessary to configure static route."
|
||||
return
|
||||
fi
|
||||
|
||||
if echo $net | grep : 2>&1 1>/dev/null
|
||||
then
|
||||
# ipv6
|
||||
filename="/etc/sysconfig/network-scripts/route6-$ifname"
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
route="$net/$mask dev $ifname"
|
||||
route1="$net\/$mask dev $ifname"
|
||||
else
|
||||
route="$net/$mask via $gw"
|
||||
route1="$net\/$mask via $gw"
|
||||
fi
|
||||
else
|
||||
# ipv4
|
||||
filename="/etc/sysconfig/network-scripts/route-$ifname"
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
route="$net/$mask dev $ifname"
|
||||
route1="$net\/$mask dev $ifname"
|
||||
else
|
||||
route="$net/$mask via $gw"
|
||||
route1="$net\/$mask via $gw"
|
||||
fi
|
||||
fi
|
||||
if [ -f $filename ]; then
|
||||
egrep "^$routedest" $filename 2>&1 1>/dev/null
|
||||
if [ $? -ne 0 ]; then #route does not exist
|
||||
echo $route >> $filename
|
||||
echo "Persistent route \"$route\" has been added in $filename."
|
||||
else
|
||||
# replace it
|
||||
sed -i -e "s/$routedest1.*/$route1/g" $filename
|
||||
echo "Persistent route \"$route\" has been replaced in $filename."
|
||||
fi
|
||||
else
|
||||
echo "$route" > $filename
|
||||
echo "Persistent route \"$route\" has been added in $filename."
|
||||
fi
|
||||
;;
|
||||
|
||||
debian)
|
||||
debianpreconf
|
||||
matchstr=""
|
||||
v6flag=0
|
||||
#on debian/ubuntu need the network device name
|
||||
if [ ! $ifname ];then
|
||||
ifname=`netstat -nr | grep "$net" | awk '{print $8}' | head -1`
|
||||
fi
|
||||
filename="/etc/network/interfaces.d/$ifname"
|
||||
|
||||
if [ ! -f $filename ];then
|
||||
echo "auto $ifname" > $filename
|
||||
echo "iface $ifname inet dhcp" >> $filename
|
||||
fi
|
||||
echo $net | grep : 2>&1 1>/dev/null
|
||||
#ipv6
|
||||
if [ $? -eq 0 ];then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
matchstr="$net/$mask dev $ifname"
|
||||
else
|
||||
matchstr="$net/$mask gw $gw"
|
||||
fi
|
||||
v6flag=1
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
matchstr="net $net netmask $mask dev $ifname"
|
||||
else
|
||||
matchstr="net $net netmask $mask gw $gw"
|
||||
fi
|
||||
fi
|
||||
|
||||
grep "$matchstr" $filename 2>&1 1>/dev/null
|
||||
if [ $? -ne 0 ];then
|
||||
foundflag=0
|
||||
tempfile="/etc/network/interfaces.d/tmp"
|
||||
while read LINE
|
||||
do
|
||||
echo $LINE | grep "iface" 2>&1 1>/dev/null
|
||||
if [ $? -eq 0 -a $foundflag -eq 1 ];then
|
||||
foundflag=0
|
||||
if [ $v6flag -eq 1 ];then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
|
||||
else
|
||||
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
|
||||
fi
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
else
|
||||
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
|
||||
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo $LINE | grep "iface $ifname " 2>&1 1>/dev/null
|
||||
#this is the last line of the device
|
||||
if [ $? -eq 0 ];then
|
||||
foundflag=1
|
||||
fi
|
||||
|
||||
echo $LINE >> $tempfile
|
||||
done < $filename
|
||||
#the insert place is the last line of the config file
|
||||
if [ $foundflag -eq 1 ];then
|
||||
if [ $v6flag -eq 1 ];then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
|
||||
else
|
||||
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
|
||||
fi
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
else
|
||||
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
|
||||
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
mv -f $tempfile $filename
|
||||
echo "Persistent route \"$matchstr\" added in $filename."
|
||||
else
|
||||
echo "Persisten route \"$match\" already exists in $filename"
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
else #AIX
|
||||
echo "Adding persistent route on AIX is not supported yet."
|
||||
fi
|
||||
}
|
||||
|
||||
# handle the route add operation that adding the setting to configuration file
|
||||
add_persistent_route()
|
||||
{
|
||||
net=$1;
|
||||
@@ -168,6 +435,14 @@ add_persistent_route()
|
||||
OS_name="debian"
|
||||
fi
|
||||
|
||||
# The replace operation does not support redhat and debain so far
|
||||
if [ "$op" = "replace" ]; then
|
||||
if [ "$OS_name" = "redhat" -o "$OS_name" = "debain" ]; then
|
||||
echo "Warning: replace operation only supports to add persistent route for sles by now."
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
case $OS_name in
|
||||
sles)
|
||||
#echo "sles"
|
||||
@@ -175,36 +450,56 @@ add_persistent_route()
|
||||
filename="/etc/sysconfig/network/routes";
|
||||
if echo $net | grep : 2>&1 1>/dev/null
|
||||
then
|
||||
if [ $gw_ip = "" -o $gw_ip = "::" ] ; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
route="$net/$mask :: - $ifname"
|
||||
route1="$net\/$mask :: - $ifname";
|
||||
else
|
||||
else
|
||||
route="$net/$mask $gw - -"
|
||||
route1="$net\/$mask $gw - -";
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ $gw_ip = "" -o $gw_ip = "0.0.0.0" ] ; then
|
||||
route="$net 0.0.0.0 $mask $ifname";
|
||||
route1="$net 0.0.0.0 $mask $ifname";
|
||||
else
|
||||
route="$net $gw $mask $ifname";
|
||||
route1="$net $gw $mask $ifname";
|
||||
fi
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
if [ $nummask -eq 1 ]; then
|
||||
if [ "$net" = "default" ]; then
|
||||
route="default - - $ifname";
|
||||
route1="default - - $ifname";
|
||||
else
|
||||
route="$net/$mask - - $ifname";
|
||||
route1="$net\/$mask - - $ifname";
|
||||
fi
|
||||
else
|
||||
route="$net 0.0.0.0 $mask $ifname";
|
||||
route1="$net 0.0.0.0 $mask $ifname";
|
||||
fi
|
||||
else
|
||||
if [ $nummask -eq 1 ]; then
|
||||
if [ "$net" = "default" ]; then
|
||||
route="default $gw - $ifname";
|
||||
route1="default $gw - $ifname";
|
||||
else
|
||||
route="$net/$mask $gw - $ifname";
|
||||
route1="$net\/$mask $gw - $ifname";
|
||||
fi
|
||||
else
|
||||
route="$net $gw $mask $ifname";
|
||||
route1="$net $gw $mask $ifname";
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -f $filename ]; then
|
||||
grep "$route" $filename 2>&1 1>/dev/null
|
||||
if [ $? -ne 0 ]; then #route does not exist
|
||||
grep "$xcat_config_start" $filename 2>&1 1>/dev/null
|
||||
if [ $? -ne 0 ]; then #no xCAT section
|
||||
echo $xcat_config_start >> $filename
|
||||
echo $route >> $filename
|
||||
echo $xcat_config_end >> $filename
|
||||
else
|
||||
sed -i -e s/"$xcat_config_end"/"$route1\n$xcat_config_end"/g $filename
|
||||
fi
|
||||
echo "Persistent route \"$route\" added in $filename."
|
||||
grep "$xcat_config_start" $filename 2>&1 1>/dev/null
|
||||
if [ $? -ne 0 ]; then #no xCAT section
|
||||
echo $xcat_config_start >> $filename
|
||||
echo $route >> $filename
|
||||
echo $xcat_config_end >> $filename
|
||||
else
|
||||
sed -i -e s/"$xcat_config_end"/"$route1\n$xcat_config_end"/g $filename
|
||||
fi
|
||||
echo "Persistent route \"$route\" added in $filename."
|
||||
else
|
||||
echo "Persistent route \"$route\" already exists in $filename."
|
||||
echo "Persistent route \"$route\" already exists in $filename."
|
||||
fi
|
||||
else
|
||||
#echo "got here"
|
||||
@@ -232,18 +527,18 @@ add_persistent_route()
|
||||
echo $net | grep : 2>&1 1>/dev/null
|
||||
#ipv6
|
||||
if [ $? -eq 0 ];then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
matchstr="$net/$mask dev $ifname"
|
||||
else
|
||||
else
|
||||
matchstr="$net/$mask gw $gw"
|
||||
fi
|
||||
v6flag=1
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
matchstr="net $net netmask $mask dev $ifname"
|
||||
else
|
||||
else
|
||||
matchstr="net $net netmask $mask gw $gw"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
grep "$matchstr" $filename 2>&1 1>/dev/null
|
||||
@@ -256,21 +551,21 @@ add_persistent_route()
|
||||
if [ $? -eq 0 -a $foundflag -eq 1 ];then
|
||||
foundflag=0
|
||||
if [ $v6flag -eq 1 ];then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
|
||||
else
|
||||
else
|
||||
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
else
|
||||
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
|
||||
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo $LINE | grep "iface $ifname " 2>&1 1>/dev/null
|
||||
@@ -284,21 +579,21 @@ add_persistent_route()
|
||||
#the insert place is the last line of the config file
|
||||
if [ $foundflag -eq 1 ];then
|
||||
if [ $v6flag -eq 1 ];then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
|
||||
else
|
||||
else
|
||||
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
|
||||
else
|
||||
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
|
||||
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
mv -f $tempfile $filename
|
||||
@@ -313,7 +608,7 @@ add_persistent_route()
|
||||
if echo $net | grep : 2>&1 1>/dev/null
|
||||
then
|
||||
if [ "$gw" = "" ] ; then
|
||||
$gw = "::";
|
||||
$gw = "::";
|
||||
fi
|
||||
filename="/etc/sysconfig/static-routes-ipv6";
|
||||
route="$ifname $net/$mask $gw";
|
||||
@@ -324,10 +619,10 @@ add_persistent_route()
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
route="any net $net netmask $mask dev $ifname";
|
||||
route1="any net $net netmask $mask dev $ifname";
|
||||
else
|
||||
else
|
||||
route="any net $net netmask $mask gw $gw $ifname";
|
||||
route1="any net $net netmask $mask gw $gw $ifname";
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -f $filename ]; then
|
||||
grep "$route" $filename 2>&1 1>/dev/null
|
||||
@@ -387,16 +682,16 @@ rm_persistent_route()
|
||||
# ipv6 net
|
||||
if echo $net | grep : 2>&1 1>/dev/null
|
||||
then
|
||||
if [ $gw = "" -o $gw = "::" ] ; then
|
||||
if [ $gw = "" -o $gw = "::" ] ; then
|
||||
route="$net/$mask :: - $ifname";
|
||||
route1="$net\/$mask :: - $ifname";
|
||||
else
|
||||
else
|
||||
route="$net/$mask $gw - -";
|
||||
route1="$net\/$mask $gw - -";
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ $gw = "" ] ; then
|
||||
$gw = "0.0.0.0";
|
||||
if [ $gw = "" ] ; then
|
||||
$gw = "0.0.0.0";
|
||||
fi
|
||||
if [ -n "$ifname" ]; then
|
||||
route="$net $gw $mask $ifname";
|
||||
@@ -431,18 +726,18 @@ rm_persistent_route()
|
||||
echo $net | grep : 2>&1 1>/dev/null
|
||||
#ipv6
|
||||
if [ $? -eq 0 ];then
|
||||
if [ $gw = "" -o $gw = "::" ] ; then
|
||||
if [ $gw = "" -o $gw = "::" ] ; then
|
||||
matchstr="$net/$mask dev $ifname"
|
||||
else
|
||||
else
|
||||
matchstr="$net/$mask gw $gw"
|
||||
fi
|
||||
fi
|
||||
v6flag=1
|
||||
else
|
||||
if [ $gw = "" -o $gw = "0.0.0.0" ] ; then
|
||||
if [ $gw = "" -o $gw = "0.0.0.0" ] ; then
|
||||
matchstr="net $net netmask $mask dev $ifname"
|
||||
else
|
||||
else
|
||||
matchstr="net $net netmask $mask gw $gw"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
grep "$matchstr" $filename
|
||||
@@ -463,10 +758,10 @@ rm_persistent_route()
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
route="$ifname $net\/$mask ::"
|
||||
route1="$ifname $net/$mask ::"
|
||||
else
|
||||
else
|
||||
route="$ifname $net\/$mask $gw"
|
||||
route1="$ifname $net/$mask $gw"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
filename="/etc/sysconfig/static-routes";
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
@@ -504,22 +799,22 @@ if [ "$op" = "add" ]; then
|
||||
if echo $net | grep : 2>&1 1>/dev/null
|
||||
then
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
cmd="ip -6 route add $net/$mask dev $ifname"
|
||||
else
|
||||
else
|
||||
cmd="ip -6 route add $net/$mask via $gw"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# AIX TODO
|
||||
cmd="ip -6 route add $net/$mask via $gw"
|
||||
fi
|
||||
else
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
cmd="route add -net $net netmask $mask dev $ifname"
|
||||
else
|
||||
else
|
||||
cmd="route add -net $net netmask $mask gw $gw"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
cmd="route add -net $net -netmask $mask $gw"
|
||||
fi
|
||||
@@ -553,22 +848,22 @@ elif [ "$op" = "delete" ]; then
|
||||
if echo $net | grep : 2>&1 1>/dev/null
|
||||
then
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
cmd="ip -6 route delete $net/$mask dev $ifname"
|
||||
else
|
||||
else
|
||||
cmd="ip -6 route delete $net/$mask via $gw"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# AIX TODO
|
||||
cmd="ip -6 route delete $net/$mask via $gw"
|
||||
fi
|
||||
else
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
cmd="route delete -net $net netmask $mask dev $ifname"
|
||||
else
|
||||
else
|
||||
cmd="route delete -net $net netmask $mask gw $gw"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
cmd="route delete -net $net -netmask $mask $gw"
|
||||
fi
|
||||
@@ -587,5 +882,57 @@ elif [ "$op" = "delete" ]; then
|
||||
|
||||
#remove the persistent route
|
||||
rm_persistent_route $net $mask $gw $ifname
|
||||
elif [ "$op" = "replace" ]; then
|
||||
if [ $nummask -ne 1 ]; then
|
||||
mask=$(v4mask2prefix $mask)
|
||||
fi
|
||||
|
||||
if echo $net | grep : 2>&1 1>/dev/null
|
||||
then # ipv6
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
if [ "$net" = "default" ]; then
|
||||
cmd="ip -6 route replace default dev $ifname"
|
||||
else
|
||||
cmd="ip -6 route replace $net/$mask dev $ifname"
|
||||
fi
|
||||
else
|
||||
if [ "$net" = "default" ]; then
|
||||
cmd="ip -6 route replace default via $gw"
|
||||
else
|
||||
cmd="ip -6 route replace $net/$mask via $gw"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else #ipv4
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
if [ "$net" = "default" ]; then
|
||||
cmd="ip route replace default dev $ifname"
|
||||
else
|
||||
cmd="ip route replace $net/$mask dev $ifname"
|
||||
fi
|
||||
else
|
||||
if [ "$net" = "default" ]; then
|
||||
cmd="ip route replace default via $gw"
|
||||
else
|
||||
cmd="ip route replace $net/$mask via $gw"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Adding temporary route: $cmd"
|
||||
result=`$cmd 2>&1`
|
||||
code=$?
|
||||
if [ $code -ne 0 ]; then
|
||||
logger -t xCAT -p local4.err "Error: $cmd [error code=$code, result=$result]"
|
||||
echo "Error: $cmd [error code=$code, result=$result]"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
#replace the persistent route
|
||||
replace_persistent_route $net $mask $gw $ifname
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
# IBM(c) 2011 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#=head1 setroute
|
||||
#=head2 setrout command adds the routes to the node according to
|
||||
#=head1 setroute [add]
|
||||
# [add] - The operation to manipulate the route entry. It is optional.
|
||||
# The default is 'replace' if ignoring it.
|
||||
#
|
||||
#=head2 setrout command replaces/adds the routes to the node according to
|
||||
# what is specified in the xCAT tables.
|
||||
# The route name for the node is defined in noderes.routenames.
|
||||
# The route itself is defined in the routes table.
|
||||
@@ -14,6 +17,12 @@ if [ -z "$NODEROUTENAMES" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
OP="replace"
|
||||
|
||||
if [ -n "$1" ] && [ "$1" = "add" ]; then
|
||||
OP="add"
|
||||
fi
|
||||
|
||||
for rn in `echo "$NODEROUTENAMES" | tr "," "\n"`
|
||||
do
|
||||
eval route_string=\$ROUTE_$rn
|
||||
@@ -34,7 +43,7 @@ do
|
||||
mask=`echo $mask | awk -F'/' '{print $2}'`
|
||||
fi
|
||||
|
||||
cmd="routeop add $net $mask $gw $ifname"
|
||||
cmd="routeop $OP $net $mask $gw $ifname"
|
||||
result=`$cmd 2>&1`
|
||||
echo $result
|
||||
done
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
# Change these two parameters according to your requirements
|
||||
$::NFSRETRIES = 3;
|
||||
$::NFSTIMEO = 50;
|
||||
$::NFSTIMEO = 10;
|
||||
|
||||
# Candidate commands: mount, df, lsfs, nfs4cl showfs
|
||||
# Only the mount command could list all file systems
|
||||
|
||||
@@ -116,6 +116,7 @@ fi
|
||||
|
||||
|
||||
%install
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d
|
||||
mkdir -p $RPM_BUILD_ROOT/install/postscripts
|
||||
@@ -152,10 +153,9 @@ chmod 755 $RPM_BUILD_ROOT/install/postscripts/*
|
||||
rm LICENSE.html
|
||||
mkdir -p postscripts/hostkeys
|
||||
cd -
|
||||
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf.apach22
|
||||
cp %{SOURCE7} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf.apach24
|
||||
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf.apach22
|
||||
cp %{SOURCE7} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf.apach24
|
||||
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf
|
||||
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf
|
||||
cp %{SOURCE7} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24
|
||||
cp %{SOURCE5} $RPM_BUILD_ROOT/etc/xCATMN
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
|
||||
@@ -168,23 +168,15 @@ cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
|
||||
if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
|
||||
then
|
||||
rm -rf /etc/httpd/conf.d/xcat.conf
|
||||
cp /etc/httpd/conf.d/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
|
||||
elif [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
|
||||
then
|
||||
rm -rf /etc/httpd/conf.d/xcat.conf
|
||||
cp /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
|
||||
else
|
||||
rm -rf /etc/httpd/conf.d/xcat.conf
|
||||
cp /etc/httpd/conf.d/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf
|
||||
|
||||
rm -rf /etc/apache2/conf.d/xcat.conf
|
||||
cp /etc/apache2/conf.d/xcat.conf.apach22 /etc/apache2/conf.d/xcat.conf
|
||||
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
|
||||
fi
|
||||
|
||||
if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
|
||||
then
|
||||
rm -rf /etc/apache2/conf.d/xcat.conf
|
||||
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
|
||||
fi
|
||||
|
||||
rm -rf /etc/apache2/conf.d/xcat.conf.apach22
|
||||
rm -rf /etc/apache2/conf.d/xcat.conf.apach24
|
||||
rm -rf /etc/httpd/conf.d/xcat.conf.apach22
|
||||
rm -rf /etc/httpd/conf.d/xcat.conf.apach24
|
||||
|
||||
%endif
|
||||
|
||||
@@ -220,11 +212,9 @@ exit 0
|
||||
%files
|
||||
%{prefix}
|
||||
# one for sles, one for rhel. yes, it's ugly...
|
||||
/etc/apache2/conf.d/xcat.conf.apach22
|
||||
/etc/apache2/conf.d/xcat.conf.apach24
|
||||
/etc/httpd/conf.d/xcat.conf.apach22
|
||||
/etc/httpd/conf.d/xcat.conf.apach24
|
||||
|
||||
/etc/xcat/conf.orig/xcat.conf.apach24
|
||||
/etc/httpd/conf.d/xcat.conf
|
||||
/etc/apache2/conf.d/xcat.conf
|
||||
/etc/xCATMN
|
||||
/install/postscripts
|
||||
/install/prescripts
|
||||
|
||||
@@ -15,6 +15,7 @@ Source1: xcat.conf
|
||||
Source2: license.tar.gz
|
||||
Source3: xCATSN
|
||||
Source5: templates.tar.gz
|
||||
Source6: xcat.conf.apach24
|
||||
Provides: xCATsn = %{version}
|
||||
Requires: xCAT-server xCAT-client perl-DBD-SQLite
|
||||
|
||||
@@ -80,6 +81,7 @@ tar -xf license.tar
|
||||
|
||||
%install
|
||||
%ifos linux
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d/
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/
|
||||
@@ -87,6 +89,8 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/
|
||||
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf
|
||||
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf
|
||||
cp %{SOURCE3} $RPM_BUILD_ROOT/etc/xCATSN
|
||||
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach22
|
||||
cp %{SOURCE6} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
|
||||
cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
|
||||
@@ -122,6 +126,23 @@ fi
|
||||
%endif
|
||||
|
||||
%post
|
||||
%ifos linux
|
||||
#Apply the correct httpd/apache configuration file according to the httpd/apache version
|
||||
if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
|
||||
then
|
||||
rm -rf /etc/httpd/conf.d/xcat.conf
|
||||
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
|
||||
fi
|
||||
|
||||
if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
|
||||
then
|
||||
rm -rf /etc/apache2/conf.d/xcat.conf
|
||||
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
|
||||
fi
|
||||
|
||||
|
||||
%endif
|
||||
|
||||
# create dir for the current pid and move the original ones from /tmp/xcat to /var/run/xcat
|
||||
mkdir -p /var/run/xcat
|
||||
if [ -r "/tmp/xcat/installservice.pid" ]; then
|
||||
@@ -161,7 +182,6 @@ if [ -e "/etc/redhat-release" ]; then
|
||||
else # SuSE
|
||||
apachedaemon='apache2'
|
||||
fi
|
||||
|
||||
# start xcatd on linux
|
||||
chkconfig $apachedaemon on
|
||||
if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image
|
||||
@@ -199,6 +219,8 @@ fi
|
||||
%{prefix}
|
||||
# one for sles, one for rhel. yes, it's ugly...
|
||||
%ifos linux
|
||||
/etc/xcat/conf.orig/xcat.conf.apach24
|
||||
/etc/xcat/conf.orig/xcat.conf.apach22
|
||||
/etc/httpd/conf.d/xcat.conf
|
||||
/etc/apache2/conf.d/xcat.conf
|
||||
%endif
|
||||
|
||||
Reference in New Issue
Block a user