tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: proposed /etc/rc.d/staticroute change to allow variables

On Wed, Oct 19, 2011 at 10:44 AM, Alan Barrett <> 
> On Wed, 19 Oct 2011, Tracy Di Marco White wrote:
>> I misunderstood what Alan was suggesting. So, staticroute_doit should be
>> this:
> Yes, that's what I had in mind.  Although, looking at it again now,
> I'd add double quotes to the args in all the evals, not just the
> new one.
> Like this:
>>                              [ $2 = "add" ] && eval "${args#*+}"
> [...]
>>                              [ $2 = "delete" ] && eval "${args#*-}"
> [...]
>>                              eval "${args#*!}"
> [...]
>>                              eval "route -q $2 -$args"
> The quotes in the eval make a difference if the string to be eval'd contains
> spaces or other IFS characters in a context where the difference between
> exactly one space and some other amount of white space is important.

Ok, that sounds good to me.

I'll need to change the route.conf(5) as well. Does this sound ok?

     Lines starting with a hash (`#') are comments and ignored.  Lines start-
     ing with a plus sign (`+') are run during start-up, while lines starting
     with a minus sign (`-') are run during system shutdown.  If a line starts
     with a '!', the rest of the line will get evaluated as a shell
script fragment.
     All other lines are passed to route(8).  During start-up, they are passed
     behind an ``eval route add -'' command and during shutdown behind an
     ``eval route delete -'' command.
     In this example, the interface for the desired routing changes is set, the
     IP address on that interface is determined, and a route is added during
     startup, or deleted during system shutdown.

           # Set interface and determine current IP address for added route.
           !ipaddr=$(/sbin/ifconfig ${ifname} | awk '$1 == "inet" {print $2}')
           net 10.10.1 -interface ${ipaddr}

And leave the other example in place, excepting that route.conf(5)
currently says "In this example, if the staticroute script is enabled
in rc.conf(5)", but all staticroute actually needs to run is


Home | Main Index | Thread Index | Old Index