Merge branch '2.8' of ssh://git.code.sf.net/p/xcat/xcat-core into 2.8
This commit is contained in:
commit
54a98d30c1
@ -3546,7 +3546,8 @@ sub gettimezone
|
||||
$svcname: the name of the service
|
||||
$svcmgrtype: the service manager type:
|
||||
0: SYSVinit
|
||||
1: systemd
|
||||
1: systemd
|
||||
2: upstart
|
||||
Returns:
|
||||
the name of service unit or service daemon
|
||||
undef on fail
|
||||
@ -3577,64 +3578,45 @@ sub servicemap{
|
||||
#=> ["list of possible service file names for the specified $svcname under the specified $svcmgrtype "]
|
||||
# }
|
||||
my %svchash=(
|
||||
"dhcp" => {
|
||||
0=>["dhcp3-server","dhcpd","isc-dhcp-server"],
|
||||
1=>["dhcpd.service"],
|
||||
},
|
||||
"nfs" => {
|
||||
0=>["nfsserver","nfs","nfs-kernel-server"],
|
||||
1=>["nfs-server.service"],
|
||||
},
|
||||
"named" => {
|
||||
0=>["named","bind9"],
|
||||
1=>["named.service"],
|
||||
},
|
||||
"syslog" => {
|
||||
0=>["syslog","syslogd","rsyslog"],
|
||||
1=>["rsyslog.service"],
|
||||
},
|
||||
"firewall" => {
|
||||
0=>["iptables","firewalld","SuSEfirewall2_setup"],
|
||||
1=>["firewalld.service"],
|
||||
},
|
||||
"http" => {
|
||||
0=>["apache2","httpd"],
|
||||
1=>["httpd.service"],
|
||||
},
|
||||
"ntpserver" => {
|
||||
0=>["ntpd","ntp"],
|
||||
1=>["ntpd.service"],
|
||||
},
|
||||
"mysql" => {
|
||||
0=>["mysqld","mysql"],
|
||||
1=>["mysqld.service"],
|
||||
},
|
||||
"dhcp" => ["dhcp3-server","dhcpd","isc-dhcp-server"],
|
||||
"nfs" => ["nfsserver","nfs-server","nfs","nfs-kernel-server"],
|
||||
"named" => ["named","bind9"],
|
||||
"syslog" => ["syslog","syslogd","rsyslog"],
|
||||
"firewall" => ["iptables","firewalld","SuSEfirewall2_setup","ufw"],
|
||||
"http" => ["apache2","httpd"],
|
||||
"ntpserver" =>["ntpd","ntp"],
|
||||
"mysql" => ["mysqld","mysql"],
|
||||
);
|
||||
|
||||
my $path=undef;
|
||||
my $postfix="";
|
||||
my $retdefault=$svcname;
|
||||
if($svcmgrtype == 0){
|
||||
$path="/etc/init.d/";
|
||||
}elsif ($svcmgrtype == 1){
|
||||
$path="/usr/lib/systemd/system/";
|
||||
$postfix=".service";
|
||||
$retdefault=$svcname.".service";
|
||||
}elsif ($svcmgrtype == 2){
|
||||
$path="/etc/init/";
|
||||
$postfix=".conf";
|
||||
}
|
||||
|
||||
|
||||
my $ret=undef;
|
||||
if($svchash{$svcname} and $svchash{$svcname}{$svcmgrtype}){
|
||||
foreach my $file (@{$svchash{$svcname}{$svcmgrtype}}){
|
||||
if(-e $path.$file ){
|
||||
if($svchash{$svcname}){
|
||||
foreach my $file (@{$svchash{$svcname}}){
|
||||
if(-e $path.$file.$postfix ){
|
||||
$ret=$file;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(-e $path.$retdefault){
|
||||
if(-e $path.$retdefault.$postfix){
|
||||
$ret=$retdefault;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $ret;
|
||||
|
||||
}
|
||||
@ -3668,20 +3650,30 @@ sub startservice{
|
||||
}
|
||||
|
||||
my $cmd="";
|
||||
#for Systemd
|
||||
my $svcunit=undef;
|
||||
#for sysVinit
|
||||
my $svcd=undef;
|
||||
#for upstart
|
||||
my $svcjob=undef;
|
||||
|
||||
$svcunit=servicemap($svcname,1);
|
||||
$svcjob=servicemap($svcname,2);
|
||||
$svcd=servicemap($svcname,0);
|
||||
if($svcunit)
|
||||
{
|
||||
$cmd="systemctl start $svcunit";
|
||||
}
|
||||
elsif( $svcjob )
|
||||
{
|
||||
$cmd="initctl start $svcjob";
|
||||
}
|
||||
elsif( $svcd )
|
||||
{
|
||||
$cmd="service $svcd start";
|
||||
}
|
||||
print "$cmd\n";
|
||||
|
||||
#print "$cmd\n";
|
||||
if( $cmd eq "" )
|
||||
{
|
||||
return -1;
|
||||
@ -3722,18 +3714,26 @@ sub stopservice{
|
||||
my $cmd="";
|
||||
my $svcunit=undef;
|
||||
my $svcd=undef;
|
||||
my $svcjob=undef;
|
||||
|
||||
$svcunit=servicemap($svcname,1);
|
||||
$svcjob=servicemap($svcname,2);
|
||||
$svcd=servicemap($svcname,0);
|
||||
if($svcunit)
|
||||
{
|
||||
$cmd="systemctl stop $svcunit";
|
||||
}
|
||||
elsif( $svcjob )
|
||||
{
|
||||
$cmd="initctl status $svcjob |grep stop; if [ \"\$?\" != \"0\" ]; then initctl stop $svcjob ; fi";
|
||||
}
|
||||
elsif( $svcd )
|
||||
{
|
||||
$cmd="service $svcd stop";
|
||||
}
|
||||
print "$cmd\n";
|
||||
|
||||
|
||||
#print "$cmd\n";
|
||||
if( $cmd eq "" )
|
||||
{
|
||||
return -1;
|
||||
@ -3774,8 +3774,10 @@ sub restartservice{
|
||||
my $cmd="";
|
||||
my $svcunit=undef;
|
||||
my $svcd=undef;
|
||||
my $svcjob=undef;
|
||||
|
||||
$svcunit=servicemap($svcname,1);
|
||||
$svcjob=servicemap($svcname,2);
|
||||
$svcd=servicemap($svcname,0);
|
||||
if($svcunit)
|
||||
{
|
||||
@ -3785,7 +3787,12 @@ sub restartservice{
|
||||
{
|
||||
$cmd="service $svcd restart";
|
||||
}
|
||||
print "$cmd\n";
|
||||
elsif( $svcjob )
|
||||
{
|
||||
$cmd="initctl status $svcjob |grep stop; if [ \"\$?\" != \"0\" ]; then initctl restart $svcjob ; else initctl start $svcjob; fi";
|
||||
}
|
||||
|
||||
#print "$cmd\n";
|
||||
if( $cmd eq "" )
|
||||
{
|
||||
return -1;
|
||||
@ -3837,9 +3844,11 @@ sub checkservicestatus{
|
||||
my $cmd="";
|
||||
my $svcunit=undef;
|
||||
my $svcd=undef;
|
||||
my $svcjob=undef;
|
||||
my %ret;
|
||||
|
||||
$svcunit=servicemap($svcname,1);
|
||||
$svcjob=servicemap($svcname,2);
|
||||
$svcd=servicemap($svcname,0);
|
||||
my $output=undef;
|
||||
|
||||
@ -3850,7 +3859,6 @@ sub checkservicestatus{
|
||||
$output=xCAT::Utils->runcmd($cmd, -1);
|
||||
if($output =~ /^active$/i){
|
||||
$ret{retcode}=0;
|
||||
print "xxx$output\n";
|
||||
}elsif($output =~ /^failed$/i){
|
||||
$ret{retcode}=2;
|
||||
|
||||
@ -3858,6 +3866,18 @@ sub checkservicestatus{
|
||||
$ret{retcode}=1;
|
||||
}
|
||||
}
|
||||
elsif ( $svcjob )
|
||||
{
|
||||
#for upstart, parse the output
|
||||
$cmd="initctl status $svcjob";
|
||||
$output=xCAT::Utils->runcmd($cmd, -1);
|
||||
if($output =~ /waiting/i){
|
||||
$ret{retcode}=2;
|
||||
}elsif($output =~ /running/i){
|
||||
$ret{retcode}=0;
|
||||
}
|
||||
|
||||
}
|
||||
elsif( $svcd )
|
||||
{
|
||||
#for SYSVinit, check the return value since the "service" command output is confused
|
||||
@ -3917,13 +3937,20 @@ sub enableservice{
|
||||
my $cmd="";
|
||||
my $svcunit=undef;
|
||||
my $svcd=undef;
|
||||
my $svcjob=undef;
|
||||
|
||||
$svcunit=servicemap($svcname,1);
|
||||
$svcjob=servicemap($svcname,2);
|
||||
$svcd=servicemap($svcname,0);
|
||||
if($svcunit)
|
||||
{
|
||||
$cmd="systemctl enable $svcunit";
|
||||
}
|
||||
elsif($svcjob)
|
||||
{
|
||||
$cmd="update-rc.d $svcjob defaults";
|
||||
|
||||
}
|
||||
elsif( $svcd )
|
||||
{
|
||||
my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig");
|
||||
@ -3936,7 +3963,6 @@ sub enableservice{
|
||||
}
|
||||
}
|
||||
}
|
||||
print "$cmd\n";
|
||||
if( $cmd eq "" )
|
||||
{
|
||||
return -1;
|
||||
@ -3976,14 +4002,21 @@ sub disableservice{
|
||||
}
|
||||
my $cmd="";
|
||||
my $svcunit=undef;
|
||||
my $svcjob=undef;
|
||||
my $svcd=undef;
|
||||
|
||||
$svcunit=servicemap($svcname,1);
|
||||
$svcjob=servicemap($svcname,2);
|
||||
$svcd=servicemap($svcname,0);
|
||||
if($svcunit)
|
||||
{
|
||||
$cmd="systemctl disable $svcunit";
|
||||
}
|
||||
elsif($svcjob)
|
||||
{
|
||||
$cmd="update-rc.d -f $svcjob remove";
|
||||
|
||||
}
|
||||
elsif( $svcd )
|
||||
{
|
||||
my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig");
|
||||
@ -3996,7 +4029,8 @@ sub disableservice{
|
||||
}
|
||||
}
|
||||
}
|
||||
print "$cmd\n";
|
||||
|
||||
# print "$cmd\n";
|
||||
if( $cmd eq "" )
|
||||
{
|
||||
return -1;
|
||||
|
@ -7,3 +7,4 @@ rsync
|
||||
yp-tools
|
||||
openssh-server
|
||||
util-linux-ng
|
||||
net-tools
|
||||
|
@ -99,6 +99,7 @@ if (@ARGV > 0) {
|
||||
$imagename=$ARGV[0];
|
||||
}
|
||||
|
||||
|
||||
my %updates_os = (); # the hash for updating osimage table
|
||||
my %updates = (); # the hash for updating linuximage table
|
||||
|
||||
@ -787,7 +788,6 @@ sub mkinitrd_dracut {
|
||||
|
||||
sub mkinitrd {
|
||||
my ($mode) = @_; # statelite or stateless
|
||||
|
||||
if($mode eq "statelite") {
|
||||
push @ndrivers, "fscache.ko";
|
||||
push @ndrivers, "sunrpc.ko";
|
||||
@ -1438,6 +1438,12 @@ EOMS
|
||||
if ( -d "$rootimg_dir/lib/firmware/" ){
|
||||
system("cp -r $rootimg_dir/lib/firmware/* /tmp/xcatinitrd.$$/lib/firmware");
|
||||
}
|
||||
|
||||
if ( -d "$rootimg_dir/lib/modules/$kernelver/" ){
|
||||
system("cp $rootimg_dir/lib/modules/$kernelver/modules.builtin /tmp/xcatinitrd.$$/lib/modules/$kernelver/modules.builtin");
|
||||
system("cp $rootimg_dir/lib/modules/$kernelver/modules.order /tmp/xcatinitrd.$$/lib/modules/$kernelver/modules.order");
|
||||
}
|
||||
|
||||
system("chroot /tmp/xcatinitrd.$$/ depmod $kernelver");
|
||||
# Copy udev and network scripts into initrd for s390x, which also works for other platforms
|
||||
# udev
|
||||
@ -1464,6 +1470,7 @@ EOMS
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/sbin/ifconfig");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/hostname");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/route");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/nc");
|
||||
symlink("bash", "/tmp/xcatinitrd.$$/bin/sh");
|
||||
symlink("bash", "/tmp/xcatinitrd.$$/sbin/sh");
|
||||
|
||||
|
@ -5,5 +5,6 @@ install/prescripts
|
||||
install/kdump
|
||||
opt/xcat/share/xcat
|
||||
etc/apache2/conf.d
|
||||
etc/apache2/conf-available
|
||||
etc/apache2/conf-enabled
|
||||
opt/xcat/share/doc/packages/xCAT
|
||||
|
@ -1,5 +1,6 @@
|
||||
xcat.conf etc/apache2/conf.d/
|
||||
xcat.conf.apach24 etc/apache2/conf-enabled
|
||||
xcat.conf etc/apache2/conf-available/
|
||||
xcat.conf.apach24 etc/apache2/conf-available/
|
||||
LICENSE.html opt/xcat/share/doc/packages/xCAT
|
||||
postscripts/* install/postscripts/
|
||||
prescripts/* install/prescripts/
|
||||
|
@ -42,7 +42,7 @@ case "$1" in
|
||||
fi
|
||||
|
||||
# [ -e /etc/apache2/conf-enabled/xcat.conf ] && rm /etc/apache2/conf-enabled/xcat.conf
|
||||
# mv /etc/apache2/conf-enabled/xcat.conf.apach24 /etc/apache2/conf-enabled/xcat.conf
|
||||
ln -s -f /etc/apache2/conf-available/xcat.conf.apach24 /etc/apache2/conf-enabled/xcat.conf
|
||||
|
||||
/etc/init.d/apache2 restart
|
||||
;;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# IBM(c) 2011EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -6,14 +6,20 @@
|
||||
#=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
|
||||
# gatewasy - The next hop. It could be set to "" or 0.0.0.0
|
||||
# mask - The length of the netmask (CIDR) like 8,16,24
|
||||
# dotted-decimal format like 255.255.0.0 is not supported.
|
||||
# gateway - The next hop. It could be set to 0.0.0.0 for omitting
|
||||
# ifname - The interface to route to the next hop
|
||||
# example: routeop replace default 0 10.1.0.209 eth0
|
||||
#=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
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
@ -26,14 +32,25 @@ if [ -n "$5" ]; then
|
||||
ifname=$5
|
||||
fi
|
||||
|
||||
# use nummask to know whether the netmask format is 255.255.255.0 or 24 (a number)
|
||||
# use nummask to know whether the netmask format is 255.255.255.0 or CIDR (a number)
|
||||
nummask=0
|
||||
echo $mask | grep '\.' > /dev/null
|
||||
echo $mask | egrep "^[.0123456789]+$" > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
nummask=1 # the netmask is the length of network mask.
|
||||
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
|
||||
@ -158,7 +175,238 @@ route_exists()
|
||||
echo $ret
|
||||
}
|
||||
|
||||
# handle the route add/replace operation that adding the setting to configuration file
|
||||
# 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;
|
||||
@ -632,6 +880,11 @@ elif [ "$op" = "delete" ]; then
|
||||
#remove the persistent route
|
||||
rm_persistent_route $net $mask $gw $ifname
|
||||
elif [ "$op" = "replace" ]; then
|
||||
if [ $nummask -ne 1 ]; then
|
||||
echo "Error: [routeop replace] only supports the CIDR formatted netmask like 16, 24."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if echo $net | grep : 2>&1 1>/dev/null
|
||||
then # ipv6
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
@ -671,14 +924,13 @@ elif [ "$op" = "replace" ]; then
|
||||
result=`$cmd 2>&1`
|
||||
code=$?
|
||||
if [ $code -ne 0 ]; then
|
||||
logger -t xCAT -p local4.err "$cmd\nerror code=$code, result=$result."
|
||||
echo " error code=$code, result=$result."
|
||||
if [ -f "/etc/debian_version" ];then
|
||||
exit 1;
|
||||
fi
|
||||
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
|
||||
add_persistent_route $net $mask $gw $ifname
|
||||
replace_persistent_route $net $mask $gw $ifname
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@ -274,45 +274,39 @@ function servicemap {
|
||||
local svclistname=
|
||||
|
||||
INIT_dhcp="dhcp3-server dhcpd isc-dhcp-server";
|
||||
SYSTEMD_dhcp="dhcpd.service";
|
||||
|
||||
INIT_nfs="nfsserver nfs nfs-kernel-server";
|
||||
SYSTEMD_nfs="nfs-server.service";
|
||||
INIT_nfs="nfsserver nfs-server nfs nfs-kernel-server";
|
||||
|
||||
INIT_named="named bind9";
|
||||
SYSTEMD_named="named.service";
|
||||
|
||||
INIT_syslog="syslog syslogd rsyslog";
|
||||
SYSTEMD_syslog="rsyslog.service";
|
||||
|
||||
INIT_firewall="iptables firewalld SuSEfirewall2_setup";
|
||||
SYSTEMD_firewall="firewalld.service";
|
||||
INIT_firewall="iptables firewalld SuSEfirewall2_setup ufw";
|
||||
|
||||
INIT_http="apache2 httpd";
|
||||
SYSTEMD_http="httpd.service";
|
||||
|
||||
INIT_ntpserver="ntpd ntp";
|
||||
SYSTEMD_ntpserver="ntpd.service";
|
||||
|
||||
INIT_mysql="mysqld mysql";
|
||||
SYSTEMD_mysql="mysqld.service";
|
||||
|
||||
INIT_ssh="sshd ssh";
|
||||
SYSTEMD_ssh="sshd.service";
|
||||
|
||||
local path=
|
||||
local postfix=""
|
||||
local retdefault=$svcname
|
||||
local svcvar=${svcname//[-.]/_}
|
||||
if [ "$svcmgrtype" = "0" ];then
|
||||
svclistname=INIT_$svcvar
|
||||
path="/etc/init.d/"
|
||||
elif [ "$svcmgrtype" = "1" ];then
|
||||
svclistname=SYSTEMD_$svcvar
|
||||
retdefault=$svcname.service
|
||||
path="/usr/lib/systemd/system/"
|
||||
postfix=".service"
|
||||
elif [ "$svcmgrtype" = "2" ];then
|
||||
path="/etc/init/"
|
||||
postfix=".conf"
|
||||
fi
|
||||
|
||||
|
||||
svclistname=INIT_$svcvar
|
||||
local svclist=$(eval echo \$$svclistname)
|
||||
|
||||
if [ -z "$svclist" ];then
|
||||
@ -321,7 +315,7 @@ function servicemap {
|
||||
|
||||
for name in `echo $svclist`
|
||||
do
|
||||
if [ -e "$path$name" ];then
|
||||
if [ -e "$path$name$postfix" ];then
|
||||
echo $name
|
||||
break
|
||||
fi
|
||||
@ -333,10 +327,13 @@ function startservice {
|
||||
local svcname=$1
|
||||
local cmd=
|
||||
local svcunit=`servicemap $svcname 1`
|
||||
local svcjob=`servicemap $svcname 2`
|
||||
local svcd=`servicemap $svcname 0`
|
||||
|
||||
if [ -n "$svcunit" ];then
|
||||
cmd="systemctl start $svcunit"
|
||||
elif [ -n "$svcjob" ];then
|
||||
cmd="initctl start $svcjob";
|
||||
elif [ -n "$svcd" ];then
|
||||
cmd="service $svcd start";
|
||||
fi
|
||||
@ -354,13 +351,23 @@ function stopservice {
|
||||
local svcname=$1
|
||||
local cmd=
|
||||
local svcunit=`servicemap $svcname 1`
|
||||
local svcjob=`servicemap $svcname 2`
|
||||
local svcd=`servicemap $svcname 0`
|
||||
|
||||
if [ -n "$svcunit" ];then
|
||||
cmd="systemctl stop $svcunit"
|
||||
elif [ -n "$svcjob" ];then
|
||||
initctl status $svcjob | grep stop
|
||||
if [ "$?" = "0" ] ; then
|
||||
return 0
|
||||
else
|
||||
cmd="initctl stop $svcjob"
|
||||
fi
|
||||
elif [ -n "$svcd" ];then
|
||||
cmd="service $svcd stop";
|
||||
cmd="service $svcd stop"
|
||||
fi
|
||||
|
||||
echo $cmd
|
||||
|
||||
if [ -z "$cmd" ];then
|
||||
return 127
|
||||
@ -374,12 +381,20 @@ function restartservice {
|
||||
local svcname=$1
|
||||
local cmd=
|
||||
local svcunit=`servicemap $svcname 1`
|
||||
local svcjob=`servicemap $svcname 2`
|
||||
local svcd=`servicemap $svcname 0`
|
||||
|
||||
if [ -n "$svcunit" ];then
|
||||
cmd="systemctl restart $svcunit"
|
||||
elif [ -n "$svcjob" ];then
|
||||
initctl status $svcjob | grep stop
|
||||
if [ "$?" = "0" ];then
|
||||
cmd= "initctl start $svcjob"
|
||||
else
|
||||
cmd="initctl restart $svcjob"
|
||||
fi
|
||||
elif [ -n "$svcd" ];then
|
||||
cmd="service $svcd restart";
|
||||
cmd="service $svcd restart"
|
||||
fi
|
||||
|
||||
if [ -z "$cmd" ];then
|
||||
@ -394,6 +409,7 @@ function checkservicestatus {
|
||||
local svcname=$1
|
||||
|
||||
local svcunit=`servicemap $svcname 1`
|
||||
local svcjob=`servicemap $svcname 2`
|
||||
local svcd=`servicemap $svcname 0`
|
||||
|
||||
local output=
|
||||
@ -408,6 +424,13 @@ function checkservicestatus {
|
||||
elif echo $output|grep -E -i "^failed$";then
|
||||
retcode=2
|
||||
fi
|
||||
elif [ -n "$svcjob" ];then
|
||||
output=$(initctl status $svcjob)
|
||||
if echo $output|grep -i "waiting";then
|
||||
retcode=2
|
||||
elif echo $output|grep -i "running";then
|
||||
retcode=0
|
||||
fi
|
||||
elif [ -n "$svcd" ];then
|
||||
output=$(service $svcd status)
|
||||
retcode=$?
|
||||
@ -420,7 +443,7 @@ function checkservicestatus {
|
||||
else
|
||||
retcode=127
|
||||
fi
|
||||
|
||||
#echo $svcunit-----$svcd
|
||||
return $retcode
|
||||
|
||||
}
|
||||
@ -429,14 +452,17 @@ function enableservice {
|
||||
local svcname=$1
|
||||
local cmd=
|
||||
local svcunit=`servicemap $svcname 1`
|
||||
local svcjob=`servicemap $svcname 2`
|
||||
local svcd=`servicemap $svcname 0`
|
||||
|
||||
if [ -n "$svcunit" ];then
|
||||
cmd="systemctl enable $svcunit"
|
||||
elif [ -n "$svcjob" ];then
|
||||
cmd="update-rc.d $svcjob defaults"
|
||||
elif [ -n "$svcd" ];then
|
||||
command -v chkconfig >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
cmd="chkconfig $svcd on";
|
||||
cmd="chkconfig $svcd on"
|
||||
else
|
||||
command -v update-rc.d >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
@ -457,10 +483,13 @@ function disableservice {
|
||||
local svcname=$1
|
||||
local cmd=
|
||||
local svcunit=`servicemap $svcname 1`
|
||||
local svcjob=`servicemap $svcname 2`
|
||||
local svcd=`servicemap $svcname 0`
|
||||
|
||||
if [ -n "$svcunit" ];then
|
||||
cmd="systemctl disable $svcunit"
|
||||
elif [ -n "svcjob" ];then
|
||||
cmd="update-rc.d -f $svcd remove"
|
||||
elif [ -n "$svcd" ];then
|
||||
command -v chkconfig >/dev/null 2>&1
|
||||
if [ $? -eq 0 ];then
|
||||
|
Loading…
x
Reference in New Issue
Block a user