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