#!/bin/sh

# Adds static routes which go through device $1

WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

if [ -z "$1" ]; then
	msg_usage "${0##*/} <net-device>"
	exit 1
fi

[ -s /etc/sysconfig/static-routes ] || exit 0

#note the trailing space in the grep gets rid of aliases
grep "^$1 " /etc/sysconfig/static-routes | while read device args; do
	/sbin/route add -$args $device
done
grep "^any " /etc/sysconfig/static-routes | while read ignore type net netmask mask gw dev; do
	if [ "$dev" = "$1" ]; then
		/sbin/route add -$type $net $netmask $mask $dev
	elif [ "$gw" = "gw" ]; then
		/sbin/route add -$type $net $netmask $mask $gw $dev
	fi
done
