xref: /netbsd-src/etc/rc.d/staticroute (revision de4fa6c51a9708fc05f88b618fa6fad87c9508ec)
1#!/bin/sh
2#
3# $NetBSD: staticroute,v 1.3 2008/01/31 15:21:32 reed Exp $
4#
5
6# PROVIDE: staticroute
7# REQUIRE: network
8# BEFORE:  NETWORKING
9
10# See the route.conf(5) manual page for details.
11
12$_rc_subr_loaded . /etc/rc.subr
13
14name="staticroute"
15start_cmd="staticroute_doit Adding add"
16stop_cmd="staticroute_doit Deleting delete"
17
18staticroute_doit() {
19	if [ -s /etc/route.conf ]; then
20		echo "$1 static routes."
21		while read args; do
22			[ -z "$args" ] && continue
23			case "$args" in
24			"#"*)
25				;;
26			"+"*)
27				[ $2 = "add" ] && eval ${args#*+}
28				;;
29			"-"*)
30				[ $2 = "delete" ] && eval ${args#*-}
31				;;
32			*)
33				route -q $2 -$args
34				;;
35			esac
36		done < /etc/route.conf
37	fi
38}
39
40load_rc_config $name
41run_rc_command "$1"
42