#! /bin/sh
########################################################################
# Begin /sbin/ifup
#
# Description : Interface Up
#
# Authors     : Jean-Marc Pigeon
#
# Notes       : ${1} is the action to do (up/down)
#               ${2} is the ip type (ipv4/ipv6)
#               ${3} is the interface to use
#
########################################################################
. /lib/lsb/init-functions

MATCH='^[[:space:]]*(\#.*)?$'


if [ $# != 3 ] ; then
  log_failure_msg2 "$0 Expecting 3 parameters, found only \""$*"\""
  exit 1
  fi
case "${1}" in
  "start"	)
    act="add"
    ;;
  "stop"	)
    act="del"
    ;;
  "*"		)
    ;;
  esac
case "${2}" in
  "ipv4"		)
    iptype="-4"
    DATA=/etc/sysconfig/route.${3}
    ;;
  "ipv6"	)
    iptype="-6"
    DATA=/etc/sysconfig/route6.${3}
    ;;
  "*"		)
    ;;
  esac
if [ -f $DATA ] ; then
  log_info_msg "Set route ${1} on ${2} interface... "
  { 
  cat $DATA; 
  echo;
  } | while read line; do
    if [[ ! "$line" =~ $MATCH ]]; then
      /sbin/ip $iptype route $act $line 2> /dev/null ;
      fi
    done
  evaluate_retval
  fi
# End /sbin/setroute
