aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifup-routes
blob: 580b4d6ebdd5305f0d684cc39f5a199965b8e77a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
TEXTDOMAIN=initscripts

# adds static routes which go through device $1

. /etc/rc.d/init.d/functions

if [ "$1" = "" ]; then
	echo $"usage: ifup-routes <net-device>"
	exit 1
fi

if [ ! -f /etc/sysconfig/static-routes ]; then
	exit 0
fi

#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