#!/bin/bash
#
#
# Description: wrapper of OCF RA Route, based on original heartbeat RA.
# See OCF RA Route for more information.
#
# Author: Benjamin Renard <brenard@easter-eggs.com>
# License: GNU General Public License (GPL)
# Copyright: (C) 2011 Easter-eggs
#
# This script manages IP route via a gateway
#
# It can add an IP route, or remove one.
#
# usage: $0 ip-network-destination/netmaskbits/ip-gateway \
# {start|stop|status|monitor}
#
# The "start" arg adds an IP route.
#
# The "stop" arg removes one.
#
DEBUG=0
function usage {
echo "Usage : $0 [-h|--help] route/cidr/via {start|stop|status}"
}
[ "$1" == "-h" -o "$1" == "--help" ] && usage && exit 0
config=$1
function verif_ip {
ip="$1"
[ ! -n "$ip" ] && return 1
[ "$( echo -n "$ip"|sed "s/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*//" )" != "" ] && return 1
o1=$( echo "$ip"|cut -d'.' -f1 )
[ "$o1" == "" ] && return 2
[ $o1 -gt 254 ] && return 2
o2=$( echo "$ip"|cut -d'.' -f2 )
[ "$o2" == "" ] && return 3
[ $o2 -gt 254 ] && return 3
o3=$( echo "$ip"|cut -d'.' -f3 )
[ "$o3" == "" ] && return 4
[ $o3 -gt 254 ] && return 4
o4=$( echo "$ip"|cut -d'.' -f4 )
[ "$o4" == "" ] && return 5
[ $o4 -gt 254 ] && return 5
return 0
}
function verif_cidr {