staticroute revision 1.5
11.1Schristos#!/bin/sh
21.1Schristos#
31.5Stron# $NetBSD: staticroute,v 1.5 2009/10/07 08:06:11 tron Exp $
41.1Schristos#
51.1Schristos
61.1Schristos# PROVIDE: staticroute
71.1Schristos# REQUIRE: network
81.1Schristos# BEFORE:  NETWORKING
91.1Schristos
101.3Sreed# See the route.conf(5) manual page for details.
111.3Sreed
121.2Smycroft$_rc_subr_loaded . /etc/rc.subr
131.1Schristos
141.1Schristosname="staticroute"
151.1Schristosstart_cmd="staticroute_doit Adding add"
161.1Schristosstop_cmd="staticroute_doit Deleting delete"
171.1Schristos
181.1Schristosstaticroute_doit() {
191.5Stron	retval=0
201.5Stron
211.1Schristos	if [ -s /etc/route.conf ]; then
221.1Schristos		echo "$1 static routes."
231.1Schristos		while read args; do
241.1Schristos			[ -z "$args" ] && continue
251.1Schristos			case "$args" in
261.1Schristos			"#"*)
271.1Schristos				;;
281.1Schristos			"+"*)
291.5Stron				if [ $2 = "add" ]; then
301.5Stron					eval ${args#*+} || retval=1
311.5Stron				fi
321.1Schristos				;;
331.1Schristos			"-"*)
341.5Stron				if [ $2 = "delete" ]; then
351.5Stron					eval ${args#*-} || retval=1
361.5Stron				fi
371.1Schristos				;;
381.1Schristos			*)
391.5Stron				route -q $2 -$args || retval=1
401.1Schristos				;;
411.1Schristos			esac
421.1Schristos		done < /etc/route.conf
431.1Schristos	fi
441.4Stron
451.5Stron	return $retval
461.1Schristos}
471.1Schristos
481.1Schristosload_rc_config $name
491.1Schristosrun_rc_command "$1"
50