Home | History | Annotate | Line # | Download | only in rc.d
staticroute revision 1.5
      1 #!/bin/sh
      2 #
      3 # $NetBSD: staticroute,v 1.5 2009/10/07 08:06:11 tron 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 
     14 name="staticroute"
     15 start_cmd="staticroute_doit Adding add"
     16 stop_cmd="staticroute_doit Deleting delete"
     17 
     18 staticroute_doit() {
     19 	retval=0
     20 
     21 	if [ -s /etc/route.conf ]; then
     22 		echo "$1 static routes."
     23 		while read args; do
     24 			[ -z "$args" ] && continue
     25 			case "$args" in
     26 			"#"*)
     27 				;;
     28 			"+"*)
     29 				if [ $2 = "add" ]; then
     30 					eval ${args#*+} || retval=1
     31 				fi
     32 				;;
     33 			"-"*)
     34 				if [ $2 = "delete" ]; then
     35 					eval ${args#*-} || retval=1
     36 				fi
     37 				;;
     38 			*)
     39 				route -q $2 -$args || retval=1
     40 				;;
     41 			esac
     42 		done < /etc/route.conf
     43 	fi
     44 
     45 	return $retval
     46 }
     47 
     48 load_rc_config $name
     49 run_rc_command "$1"
     50