2011-04-08 19:56:09 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# IBM(c) 2011 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
2014-06-30 08:21:10 +00:00
|
|
|
#=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
|
2011-04-08 19:56:09 +00:00
|
|
|
# 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.
|
|
|
|
#=cut
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2011-08-22 01:08:40 +00:00
|
|
|
if [ -z "$NODEROUTENAMES" ]; then
|
2011-04-08 19:56:09 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2014-06-30 08:21:10 +00:00
|
|
|
OP="replace"
|
|
|
|
|
|
|
|
if [ -n "$1" ] && [ "$1" = "add" ]; then
|
|
|
|
OP="add"
|
|
|
|
fi
|
|
|
|
|
2011-04-08 19:56:09 +00:00
|
|
|
for rn in `echo "$NODEROUTENAMES" | tr "," "\n"`
|
|
|
|
do
|
|
|
|
eval route_string=\$ROUTE_$rn
|
|
|
|
net=`echo $route_string |cut -d',' -f1`
|
|
|
|
mask=`echo $route_string |cut -d',' -f2`
|
|
|
|
gw=`echo $route_string |cut -d',' -f3`
|
|
|
|
ifname=`echo $route_string |cut -d',' -f4`
|
|
|
|
|
2013-02-28 02:32:24 +00:00
|
|
|
# remove the suffix /64 from ipv6 net
|
|
|
|
if echo $net | grep "/" 2>&1 1>/dev/null
|
|
|
|
then
|
|
|
|
net=`echo $net | awk -F'/' '{print $1}'`
|
|
|
|
fi
|
|
|
|
|
|
|
|
# remove the prefix "/" from ipv6 mask
|
|
|
|
if echo $mask | grep "/" 2>&1 1>/dev/null
|
|
|
|
then
|
|
|
|
mask=`echo $mask | awk -F'/' '{print $2}'`
|
|
|
|
fi
|
|
|
|
|
2014-06-30 08:21:10 +00:00
|
|
|
cmd="routeop $OP $net $mask $gw $ifname"
|
2011-04-08 19:56:09 +00:00
|
|
|
result=`$cmd 2>&1`
|
|
|
|
echo $result
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|