HP-UX Secure Resource Partitions (SRP) A.02.01 Administrator's Guide

100
###################################################################
#
# Get the SRP environment from
"/etc/cmcluster/hpsrp/<srp>/srp_script.incl"
#
# Environemnt variable example: use a local gateway on the host
# SRP_SG_MANAGED_IP[0]="192.0.0.99"
# SRP_SG_GATEWAY[0]="192.0.0.99"
#
# Environemnt variable example: use a remote gateway
# SRP_SG_MANAGED_IP[1]="10.1.1.99"
# 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