1#!/bin/sh 2# 3# $NetBSD: staticroute,v 1.6 2012/05/02 15:57:15 gendalia 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 eval "${args#*!}" || retval=1 40 ;; 41 *) 42 eval "route -q $2 -$args" || retval=1 43 ;; 44 esac 45 done < /etc/route.conf ) 46 fi 47 48 return $retval 49} 50 51load_rc_config $name 52run_rc_command "$1" 53