Home | History | Annotate | Line # | Download | only in rc.d
staticroute revision 1.5.6.1
      1      1.1  christos #!/bin/sh
      2      1.1  christos #
      3  1.5.6.1      yamt # $NetBSD: staticroute,v 1.5.6.1 2012/05/23 10:07:21 yamt 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.5      tron 	retval=0
     20      1.5      tron 
     21      1.1  christos 	if [ -s /etc/route.conf ]; then
     22      1.1  christos 		echo "$1 static routes."
     23  1.5.6.1      yamt 		( 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.5      tron 				if [ $2 = "add" ]; then
     30  1.5.6.1      yamt 					eval "${args#*+}" || retval=1
     31      1.5      tron 				fi
     32      1.1  christos 				;;
     33      1.1  christos 			"-"*)
     34      1.5      tron 				if [ $2 = "delete" ]; then
     35  1.5.6.1      yamt 					eval "${args#*-}" || retval=1
     36      1.5      tron 				fi
     37      1.1  christos 				;;
     38  1.5.6.1      yamt 			"!"*)
     39  1.5.6.1      yamt 				eval "${args#*!}" || retval=1
     40  1.5.6.1      yamt 				;;
     41      1.1  christos 			*)
     42  1.5.6.1      yamt 				eval "route -q $2 -$args" || retval=1
     43      1.1  christos 				;;
     44      1.1  christos 			esac
     45  1.5.6.1      yamt 		done < /etc/route.conf )
     46      1.1  christos 	fi
     47      1.4      tron 
     48      1.5      tron 	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