HP-UX Containers (SRP) A.03.00 Administrator's Guide
117
# SRP_SG_GATEWAY[1]="10.1.1.1"
#
###################################################################
. `dirname $0`/srp_script.incl
###################################################################
#
# Functions
#
###################################################################
# add routing entry
function srp_route_add
{
# run 'route' command for each IP address
rval=0
index=0
last_index=${#SRP_SG_MANAGED_IP[@]}
while [ "$index" -lt "$last_index" ]
do
srp_ip="${SRP_SG_MANAGED_IP[$index]}"
srp_gateway="${SRP_SG_GATEWAY[$index]}";
if [ -z "$srp_ip" ] # skip empty slot in the array
then
let index=$index+1
let last_index=$last_index+1
continue
fi
if [ "$srp_ip" = "$srp_gateway" ]
then
# use local IP as gateway
emsg=$(/usr/sbin/route add default $srp_gateway 0 \
source $srp_ip 2>&1)
else
# use remote gateway
emsg=$(/usr/sbin/route add default $srp_gateway 1 \
source $srp_ip 2>&1)
fi
if (($? != 0)); then
print "ERROR: $emsg" >$2
rval=1
fi
let index=$index+1
done
return $rval
}
# delete routing entry
function srp_route_delete
{
# run 'route' command for each IP address
rval=0
index=0
last_index=${#SRP_SG_MANAGED_IP[@]}
while [ "$index" -lt "$last_index" ]
do
srp_ip="${SRP_SG_MANAGED_IP[$index]}"
srp_gateway="${SRP_SG_GATEWAY[$index]}";
if [ -z "$srp_ip" ] # skip empty slot in the array
then
let index=$index+1
let last_index=$last_index+1
continue
fi
if [ "$srp_ip" = "$srp_gateway" ]