Home | History | Annotate | Line # | Download | only in rc.d
staticroute revision 1.3.12.1
      1       1.1  christos #!/bin/sh
      2       1.1  christos #
      3  1.3.12.1       riz # $NetBSD: staticroute,v 1.3.12.1 2012/05/19 16:48:36 riz Exp $
      4       1.1  christos #
      5       1.1  christos 
      6       1.1  christos # PROVIDE: staticroute
      7       1.1  christos # REQUIRE: network
      8       1.1  christos # BEFORE:  NETWORKING
      9       1.1  christos 
     10       1.3      reed # See the route.conf(5) manual page for details.
     11       1.3      reed 
     12       1.2   mycroft $_rc_subr_loaded . /etc/rc.subr
     13       1.1  christos 
     14       1.1  christos name="staticroute"
     15       1.1  christos start_cmd="staticroute_doit Adding add"
     16       1.1  christos stop_cmd="staticroute_doit Deleting delete"
     17       1.1  christos 
     18       1.1  christos staticroute_doit() {
     19  1.3.12.1       riz 	retval=0
     20  1.3.12.1       riz 
     21       1.1  christos 	if [ -s /etc/route.conf ]; then
     22       1.1  christos 		echo "$1 static routes."
     23  1.3.12.1       riz 		( while read args; do
     24       1.1  christos 			[ -z "$args" ] && continue
     25       1.1  christos 			case "$args" in
     26       1.1  christos 			"#"*)
     27       1.1  christos 				;;
     28       1.1  christos 			"+"*)
     29  1.3.12.1       riz 				if [ $2 = "add" ]; then
     30  1.3.12.1       riz 					eval "${args#*+}" || retval=1
     31  1.3.12.1       riz 				fi
     32       1.1  christos 				;;
     33       1.1  christos 			"-"*)
     34  1.3.12.1       riz 				if [ $2 = "delete" ]; then
     35  1.3.12.1       riz 					eval "${args#*-}" || retval=1
     36  1.3.12.1       riz 				fi
     37  1.3.12.1       riz 				;;
     38  1.3.12.1       riz 			"!"*)
     39  1.3.12.1       riz 				eval "${args#*!}" || retval=1
     40       1.1  christos 				;;
     41       1.1  christos 			*)
     42  1.3.12.1       riz 				eval "route -q $2 -$args" || retval=1
     43       1.1  christos 				;;
     44       1.1  christos 			esac
     45  1.3.12.1       riz 		done < /etc/route.conf )
     46       1.1  christos 	fi
     47  1.3.12.1       riz 
     48  1.3.12.1       riz 	return $retval
     49       1.1  christos }
     50       1.1  christos 
     51       1.1  christos load_rc_config $name
     52       1.1  christos run_rc_command "$1"
     53