11.1Schristos#!/bin/sh
21.1Schristos#
31.6Sgendalia# $NetBSD: staticroute,v 1.6 2012/05/02 15:57:15 gendalia 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.6Sgendalia		( 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.6Sgendalia					eval "${args#*+}" || retval=1
311.5Stron				fi
321.1Schristos				;;
331.1Schristos			"-"*)
341.5Stron				if [ $2 = "delete" ]; then
351.6Sgendalia					eval "${args#*-}" || retval=1
361.5Stron				fi
371.1Schristos				;;
381.6Sgendalia			"!"*)
391.6Sgendalia				eval "${args#*!}" || retval=1
401.6Sgendalia				;;
411.1Schristos			*)
421.6Sgendalia				eval "route -q $2 -$args" || retval=1
431.1Schristos				;;
441.1Schristos			esac
451.6Sgendalia		done < /etc/route.conf )
461.1Schristos	fi
471.4Stron
481.5Stron	return $retval
491.1Schristos}
501.1Schristos
511.1Schristosload_rc_config $name
521.1Schristosrun_rc_command "$1"
53