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 14name="staticroute" 15start_cmd="staticroute_doit Adding add" 16stop_cmd="staticroute_doit Deleting delete" 17 18staticroute_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 48load_rc_config $name 49run_rc_command "$1" 50