head 1.6; access; symbols netbsd-10-0-RELEASE:1.6 netbsd-10-0-RC6:1.6 netbsd-10-0-RC5:1.6 netbsd-10-0-RC4:1.6 netbsd-10-0-RC3:1.6 netbsd-10-0-RC2:1.6 netbsd-10-0-RC1:1.6 netbsd-10:1.6.0.44 netbsd-10-base:1.6 netbsd-9-3-RELEASE:1.6 cjep_sun2x-base1:1.6 cjep_sun2x:1.6.0.42 cjep_sun2x-base:1.6 cjep_staticlib_x-base1:1.6 netbsd-9-2-RELEASE:1.6 cjep_staticlib_x:1.6.0.40 cjep_staticlib_x-base:1.6 netbsd-9-1-RELEASE:1.6 phil-wifi-20200421:1.6 phil-wifi-20200411:1.6 is-mlppp:1.6.0.38 is-mlppp-base:1.6 phil-wifi-20200406:1.6 netbsd-8-2-RELEASE:1.6 netbsd-9-0-RELEASE:1.6 netbsd-9-0-RC2:1.6 netbsd-9-0-RC1:1.6 phil-wifi-20191119:1.6 netbsd-9:1.6.0.36 netbsd-9-base:1.6 phil-wifi-20190609:1.6 netbsd-8-1-RELEASE:1.6 netbsd-8-1-RC1:1.6 pgoyette-compat-merge-20190127:1.6 pgoyette-compat-20190127:1.6 pgoyette-compat-20190118:1.6 pgoyette-compat-1226:1.6 pgoyette-compat-1126:1.6 pgoyette-compat-1020:1.6 pgoyette-compat-0930:1.6 pgoyette-compat-0906:1.6 netbsd-7-2-RELEASE:1.6 pgoyette-compat-0728:1.6 netbsd-8-0-RELEASE:1.6 phil-wifi:1.6.0.34 phil-wifi-base:1.6 pgoyette-compat-0625:1.6 netbsd-8-0-RC2:1.6 pgoyette-compat-0521:1.6 pgoyette-compat-0502:1.6 pgoyette-compat-0422:1.6 netbsd-8-0-RC1:1.6 pgoyette-compat-0415:1.6 pgoyette-compat-0407:1.6 pgoyette-compat-0330:1.6 pgoyette-compat-0322:1.6 pgoyette-compat-0315:1.6 netbsd-7-1-2-RELEASE:1.6 pgoyette-compat:1.6.0.32 pgoyette-compat-base:1.6 netbsd-7-1-1-RELEASE:1.6 matt-nb8-mediatek:1.6.0.30 matt-nb8-mediatek-base:1.6 perseant-stdc-iso10646:1.6.0.28 perseant-stdc-iso10646-base:1.6 netbsd-8:1.6.0.26 netbsd-8-base:1.6 prg-localcount2-base3:1.6 prg-localcount2-base2:1.6 prg-localcount2-base1:1.6 prg-localcount2:1.6.0.24 prg-localcount2-base:1.6 pgoyette-localcount-20170426:1.6 bouyer-socketcan-base1:1.6 pgoyette-localcount-20170320:1.6 netbsd-7-1:1.6.0.22 netbsd-7-1-RELEASE:1.6 netbsd-7-1-RC2:1.6 netbsd-7-nhusb-base-20170116:1.6 bouyer-socketcan:1.6.0.20 bouyer-socketcan-base:1.6 pgoyette-localcount-20170107:1.6 netbsd-7-1-RC1:1.6 pgoyette-localcount-20161104:1.6 netbsd-7-0-2-RELEASE:1.6 localcount-20160914:1.6 netbsd-7-nhusb:1.6.0.18 netbsd-7-nhusb-base:1.6 pgoyette-localcount-20160806:1.6 pgoyette-localcount-20160726:1.6 pgoyette-localcount:1.6.0.16 pgoyette-localcount-base:1.6 netbsd-7-0-1-RELEASE:1.6 netbsd-7-0:1.6.0.14 netbsd-7-0-RELEASE:1.6 netbsd-7-0-RC3:1.6 netbsd-7-0-RC2:1.6 netbsd-7-0-RC1:1.6 netbsd-5-2-3-RELEASE:1.3.12.1 netbsd-5-1-5-RELEASE:1.3 netbsd-6-0-6-RELEASE:1.5.8.1 netbsd-6-1-5-RELEASE:1.5.8.1 netbsd-7:1.6.0.12 netbsd-7-base:1.6 yamt-pagecache-base9:1.6 yamt-pagecache-tag8:1.5.6.1 netbsd-6-1-4-RELEASE:1.5.8.1 netbsd-6-0-5-RELEASE:1.5.8.1 tls-earlyentropy:1.6.0.10 tls-earlyentropy-base:1.6 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.6 riastradh-drm2-base3:1.6 netbsd-6-1-3-RELEASE:1.5.8.1 netbsd-6-0-4-RELEASE:1.5.8.1 netbsd-5-2-2-RELEASE:1.3.12.1 netbsd-5-1-4-RELEASE:1.3 netbsd-6-1-2-RELEASE:1.5.8.1 netbsd-6-0-3-RELEASE:1.5.8.1 netbsd-5-2-1-RELEASE:1.3.12.1 netbsd-5-1-3-RELEASE:1.3 netbsd-6-1-1-RELEASE:1.5.8.1 riastradh-drm2-base2:1.6 riastradh-drm2-base1:1.6 riastradh-drm2:1.6.0.4 riastradh-drm2-base:1.6 netbsd-6-1:1.5.8.1.0.6 netbsd-6-0-2-RELEASE:1.5.8.1 netbsd-6-1-RELEASE:1.5.8.1 khorben-n900:1.6.0.8 netbsd-6-1-RC4:1.5.8.1 netbsd-6-1-RC3:1.5.8.1 agc-symver:1.6.0.6 agc-symver-base:1.6 netbsd-6-1-RC2:1.5.8.1 netbsd-6-1-RC1:1.5.8.1 yamt-pagecache-base8:1.6 netbsd-5-2:1.3.12.1.0.2 netbsd-6-0-1-RELEASE:1.5.8.1 yamt-pagecache-base7:1.6 netbsd-5-2-RELEASE:1.3.12.1 netbsd-5-2-RC1:1.3.12.1 matt-nb6-plus-nbase:1.5.8.1 yamt-pagecache-base6:1.6 netbsd-6-0:1.5.8.1.0.4 netbsd-6-0-RELEASE:1.5.8.1 netbsd-6-0-RC2:1.5.8.1 tls-maxphys:1.6.0.2 tls-maxphys-base:1.6 matt-nb6-plus:1.5.8.1.0.2 matt-nb6-plus-base:1.5.8.1 netbsd-6-0-RC1:1.5.8.1 yamt-pagecache-base5:1.6 yamt-pagecache-base4:1.5 netbsd-6:1.5.0.8 netbsd-6-base:1.5 netbsd-5-1-2-RELEASE:1.3 netbsd-5-1-1-RELEASE:1.3 yamt-pagecache-base3:1.5 yamt-pagecache-base2:1.5 yamt-pagecache:1.5.0.6 yamt-pagecache-base:1.5 cherry-xenmp:1.5.0.4 cherry-xenmp-base:1.5 bouyer-quota2-nbase:1.5 bouyer-quota2:1.5.0.2 bouyer-quota2-base:1.5 matt-mips64-premerge-20101231:1.5 matt-nb5-mips64-premerge-20101231:1.3 matt-nb5-pq3:1.3.0.22 matt-nb5-pq3-base:1.3 netbsd-5-1:1.3.0.20 netbsd-5-1-RELEASE:1.3 netbsd-5-1-RC4:1.3 matt-nb5-mips64-k15:1.3 netbsd-5-1-RC3:1.3 netbsd-5-1-RC2:1.3 netbsd-5-1-RC1:1.3 netbsd-5-0-2-RELEASE:1.3 matt-nb5-mips64-premerge-20091211:1.3 matt-premerge-20091211:1.5 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.3 matt-nb4-mips64-k7-u2a-k9b:1.3 matt-nb5-mips64-u1-k1-k5:1.3 matt-nb5-mips64:1.3.0.18 netbsd-5-0-1-RELEASE:1.3 jym-xensuspend-nbase:1.3 netbsd-5-0:1.3.0.16 netbsd-5-0-RELEASE:1.3 netbsd-5-0-RC4:1.3 netbsd-5-0-RC3:1.3 netbsd-5-0-RC2:1.3 jym-xensuspend:1.3.0.14 jym-xensuspend-base:1.3 netbsd-5-0-RC1:1.3 mjf-devfs2-base2:1.3 netbsd-5:1.3.0.12 netbsd-5-base:1.3 matt-mips64-base2:1.3 matt-mips64:1.2.0.22 netbsd-4-0-1-RELEASE:1.2 wrstuden-revivesa-base-3:1.3 wrstuden-revivesa-base-2:1.3 wrstuden-fixsa-newbase:1.2 wrstuden-revivesa-base-1:1.3 yamt-pf42-base4:1.3 yamt-pf42-base3:1.3 hpcarm-cleanup-nbase:1.3 yamt-pf42-baseX:1.3 yamt-pf42-base2:1.3 wrstuden-revivesa:1.3.0.10 wrstuden-revivesa-base:1.3 yamt-pf42:1.3.0.8 yamt-pf42-base:1.3 mjf-devfs2:1.3.0.6 mjf-devfs2-base:1.3 keiichi-mipv6:1.3.0.4 keiichi-mipv6-base:1.3 mjf-devfs:1.3.0.2 mjf-devfs-base:1.3 matt-armv6-nbase:1.3 matt-armv6-prevmlocking:1.2 wrstuden-fixsa-base-1:1.2 netbsd-4-0:1.2.0.20 netbsd-4-0-RELEASE:1.2 cube-autoconf:1.2.0.18 cube-autoconf-base:1.2 netbsd-4-0-RC5:1.2 netbsd-4-0-RC4:1.2 netbsd-4-0-RC3:1.2 netbsd-4-0-RC2:1.2 netbsd-4-0-RC1:1.2 matt-armv6:1.2.0.16 matt-armv6-base:1.2 matt-mips64-base:1.2 hpcarm-cleanup:1.2.0.14 hpcarm-cleanup-base:1.3 netbsd-3-1-1-RELEASE:1.2 netbsd-3-0-3-RELEASE:1.2 wrstuden-fixsa:1.2.0.12 wrstuden-fixsa-base:1.2 abandoned-netbsd-4-base:1.2 abandoned-netbsd-4:1.2.0.6 netbsd-3-1:1.2.0.8 netbsd-3-1-RELEASE:1.2 netbsd-3-0-2-RELEASE:1.2 netbsd-3-1-RC4:1.2 netbsd-3-1-RC3:1.2 netbsd-3-1-RC2:1.2 netbsd-3-1-RC1:1.2 netbsd-4:1.2.0.10 netbsd-4-base:1.2 netbsd-3-0-1-RELEASE:1.2 netbsd-3-0:1.2.0.4 netbsd-3-0-RELEASE:1.2 netbsd-3-0-RC6:1.2 netbsd-3-0-RC5:1.2 netbsd-3-0-RC4:1.2 netbsd-3-0-RC3:1.2 netbsd-3-0-RC2:1.2 netbsd-3-0-RC1:1.2 netbsd-2-0-3-RELEASE:1.1 netbsd-2-1:1.1.0.6 netbsd-2-1-RELEASE:1.1 netbsd-2-1-RC6:1.1 netbsd-2-1-RC5:1.1 netbsd-2-1-RC4:1.1 netbsd-2-1-RC3:1.1 netbsd-2-1-RC2:1.1 netbsd-2-1-RC1:1.1 netbsd-2-0-2-RELEASE:1.1 netbsd-3:1.2.0.2 netbsd-3-base:1.2 netbsd-2-0-1-RELEASE:1.1 netbsd-2:1.1.0.4 netbsd-2-base:1.1 netbsd-2-0-RELEASE:1.1 netbsd-2-0-RC5:1.1 netbsd-2-0-RC4:1.1 netbsd-2-0-RC3:1.1 netbsd-2-0-RC2:1.1 netbsd-2-0-RC1:1.1 netbsd-2-0:1.1.0.2 netbsd-2-0-base:1.1; locks; strict; comment @# @; 1.6 date 2012.05.02.15.57.15; author gendalia; state Exp; branches; next 1.5; 1.5 date 2009.10.07.08.06.11; author tron; state Exp; branches 1.5.6.1 1.5.8.1; next 1.4; 1.4 date 2009.10.07.07.51.28; author tron; state Exp; branches; next 1.3; 1.3 date 2008.01.31.15.21.32; author reed; state Exp; branches 1.3.2.1 1.3.12.1; next 1.2; 1.2 date 2004.08.13.18.08.03; author mycroft; state Exp; branches 1.2.16.1; next 1.1; 1.1 date 2003.01.09.15.57.02; author christos; state Exp; branches; next ; 1.5.6.1 date 2012.05.23.10.07.21; author yamt; state Exp; branches; next ; 1.5.8.1 date 2012.05.07.03.16.45; author riz; state Exp; branches; next ; 1.3.2.1 date 2008.01.31.15.21.32; author reed; state dead; branches; next 1.3.2.2; 1.3.2.2 date 2008.01.31.15.21.33; author reed; state Exp; branches; next ; 1.3.12.1 date 2012.05.19.16.48.36; author riz; state Exp; branches; next ; 1.2.16.1 date 2008.03.23.00.23.49; author matt; state Exp; branches; next ; desc @@ 1.6 log @Add the ability for staticroute to evaluate lines from /etc/route.conf as shell script fragments, add example to the route.conf man page of evaluating variables. Remove route.conf man page statement that staticroute is enabled in rc.conf since that's incorrect. Wrap the staticroute while in parens, per & , and quote all the arguments for the evals. @ text @#!/bin/sh # # $NetBSD: staticroute,v 1.5 2009/10/07 08:06:11 tron Exp $ # # PROVIDE: staticroute # REQUIRE: network # BEFORE: NETWORKING # See the route.conf(5) manual page for details. $_rc_subr_loaded . /etc/rc.subr name="staticroute" start_cmd="staticroute_doit Adding add" stop_cmd="staticroute_doit Deleting delete" staticroute_doit() { retval=0 if [ -s /etc/route.conf ]; then echo "$1 static routes." ( while read args; do [ -z "$args" ] && continue case "$args" in "#"*) ;; "+"*) if [ $2 = "add" ]; then eval "${args#*+}" || retval=1 fi ;; "-"*) if [ $2 = "delete" ]; then eval "${args#*-}" || retval=1 fi ;; "!"*) eval "${args#*!}" || retval=1 ;; *) eval "route -q $2 -$args" || retval=1 ;; esac done < /etc/route.conf ) fi return $retval } load_rc_config $name run_rc_command "$1" @ 1.5 log @Add proper error reporting via the return code: Remember if any of the "route" commands failed and return an error in that case. @ text @d3 1 a3 1 # $NetBSD: staticroute,v 1.4 2009/10/07 07:51:28 tron Exp $ d23 1 a23 1 while read args; do d30 1 a30 1 eval ${args#*+} || retval=1 d35 1 a35 1 eval ${args#*-} || retval=1 d38 3 d42 1 a42 1 route -q $2 -$args || retval=1 d45 1 a45 1 done < /etc/route.conf @ 1.5.6.1 log @sync with head. @ text @d3 1 a3 1 # $NetBSD: staticroute,v 1.5 2009/10/07 08:06:11 tron Exp $ d23 1 a23 1 ( while read args; do d30 1 a30 1 eval "${args#*+}" || retval=1 d35 1 a35 1 eval "${args#*-}" || retval=1 a37 3 "!"*) eval "${args#*!}" || retval=1 ;; d39 1 a39 1 eval "route -q $2 -$args" || retval=1 d42 1 a42 1 done < /etc/route.conf ) @ 1.5.8.1 log @Pull up following revision(s) (requested by gendalia in ticket #211): share/man/man5/route.conf.5: revision 1.4 etc/rc.d/staticroute: revision 1.6 Add the ability for staticroute to evaluate lines from /etc/route.conf as shell script fragments, add example to the route.conf man page of evaluating variables. Remove route.conf man page statement that staticroute is enabled in rc.conf since that's incorrect. Wrap the staticroute while in parens, per & , and quote all the arguments for the evals. @ text @d3 1 a3 1 # $NetBSD$ d23 1 a23 1 ( while read args; do d30 1 a30 1 eval "${args#*+}" || retval=1 d35 1 a35 1 eval "${args#*-}" || retval=1 a37 3 "!"*) eval "${args#*!}" || retval=1 ;; d39 1 a39 1 eval "route -q $2 -$args" || retval=1 d42 1 a42 1 done < /etc/route.conf ) @ 1.4 log @Add a "return 0" to avoid incorrect error returns because we ran out of lines to read from "/etc/route.conf". @ text @d3 1 a3 1 # $NetBSD: staticroute,v 1.3 2008/01/31 15:21:32 reed Exp $ d19 2 d29 3 a31 1 [ $2 = "add" ] && eval ${args#*+} d34 3 a36 1 [ $2 = "delete" ] && eval ${args#*-} d39 1 a39 1 route -q $2 -$args d45 1 a45 1 return 0 @ 1.3 log @Add comment to point to manual page for details. @ text @d3 1 a3 1 # $NetBSD: staticroute,v 1.2 2004/08/13 18:08:03 mycroft Exp $ d38 2 @ 1.3.12.1 log @Pull up following revision(s) (requested by gendalia in ticket #1757): share/man/man5/route.conf.5: revision 1.4 etc/rc.d/staticroute: revision 1.4 etc/rc.d/staticroute: revision 1.5 etc/rc.d/staticroute: revision 1.6 Add a "return 0" to avoid incorrect error returns because we ran out of lines to read from "/etc/route.conf". Add proper error reporting via the return code: Remember if any of the "route" commands failed and return an error in that case. Add the ability for staticroute to evaluate lines from /etc/route.conf as shell script fragments, add example to the route.conf man page of evaluating variables. Remove route.conf man page statement that staticroute is enabled in rc.conf since that's incorrect. Wrap the staticroute while in parens, per & , and quote all the arguments for the evals. @ text @d3 1 a3 1 # $NetBSD$ a18 2 retval=0 d21 1 a21 1 ( while read args; do d27 1 a27 3 if [ $2 = "add" ]; then eval "${args#*+}" || retval=1 fi d30 1 a30 6 if [ $2 = "delete" ]; then eval "${args#*-}" || retval=1 fi ;; "!"*) eval "${args#*!}" || retval=1 d33 1 a33 1 eval "route -q $2 -$args" || retval=1 d36 1 a36 1 done < /etc/route.conf ) a37 2 return $retval @ 1.3.2.1 log @file staticroute was added on branch mjf-devfs on 2008-01-31 15:21:33 +0000 @ text @d1 41 @ 1.3.2.2 log @Add comment to point to manual page for details. @ text @a0 41 #!/bin/sh # # $NetBSD: staticroute,v 1.3 2008/01/31 15:21:32 reed Exp $ # # PROVIDE: staticroute # REQUIRE: network # BEFORE: NETWORKING # See the route.conf(5) manual page for details. $_rc_subr_loaded . /etc/rc.subr name="staticroute" start_cmd="staticroute_doit Adding add" stop_cmd="staticroute_doit Deleting delete" staticroute_doit() { if [ -s /etc/route.conf ]; then echo "$1 static routes." while read args; do [ -z "$args" ] && continue case "$args" in "#"*) ;; "+"*) [ $2 = "add" ] && eval ${args#*+} ;; "-"*) [ $2 = "delete" ] && eval ${args#*-} ;; *) route -q $2 -$args ;; esac done < /etc/route.conf fi } load_rc_config $name run_rc_command "$1" @ 1.2 log @Add an _rc_subr_loaded variable, set to ":" by rc.subr. Scripts can use this for a speedup by doing: $_rc_subr_loaded . /etc/rc.subr @ text @d3 1 a3 1 # $NetBSD: staticroute,v 1.1 2003/01/09 15:57:02 christos Exp $ d10 2 @ 1.2.16.1 log @sync with HEAD @ text @d3 1 a3 1 # staticroute,v 1.2 2004/08/13 18:08:03 mycroft Exp a9 2 # See the route.conf(5) manual page for details. @ 1.1 log @Script to add and remove static routes: eg: $ cat /etc/route.conf # Turn on/off IP forwarding. +sysctl -w net.inet.ip.forwarding=1 -sysctl -w net.inet.ip.forwarding=0 net 192.168.2.0 -netmask 255.255.255.0 192.168.150.2 @ text @d3 1 a3 1 # $NetBSD: route,v 1.42 2003/01/09 15:12:47 christos Exp $ d10 1 a10 1 . /etc/rc.subr @