Config script environment variables consistency

Sandy McArthur Jr sandy at mcarthur.org
Mon Sep 30 17:00:45 CEST 2013


I'd like to request more consistent availability of the environment
variables when the tinc per-network scripts run.

One thing I noticed is which environment variables are available during
{tinc,host,subnet,hosts/[node]}-{up,down} scripts are inconsistent. I
realize some don't make sense, eg: $SUBNET in tinc-up . But the $NAME var
is only available in tinc-{up,down} and not the others. For example it
makes sense to me that a subnet-up script executes in a context where "the
name of this tinc daemon" would be known to Tinc and could be supplied via
$NAME.


I'm running Tinc 1.0.19 as provided by OpenWrt on my gateway router to vpn
between some friends and family home lans. Works great one you adapt to the
weirdness of OpenWrt's init/config layout. If this request has been
satisfied in newer Tinc versions, please disregard this post.

Where I wanted this particular example is in the subnet-up script. I would
have liked to have written a more generic tinc subnet-up script with the
line below to abort the subnet-up script when it executes for the local
node's subnet:

[ $NODE = $NAME ] && exit

Instead I figured out this version which has OpenWrt specific stuff
embedded into it to provide a NAME:

[ $NODE = `uci get tinc.$NETNAME.Name` ] && exit


The reason I'm doing this is because I wish to route between 192.168.. and
10... lans and the docs suggestion of a broad netmask it a bit much for
both private IP ranges. Instead my subnet-up executes `route add -net
$SUBNET dev $INTERFACE`

My almost completely generic tinc scripts for more context if helpful:

tinc-up:
#!/bin/sh
#ifconfig $INTERFACE 192.168.123.1
ip=`uci get network.lan.ipaddr`
ifconfig $INTERFACE $ip

tinc-down
#!/bin/sh
ifconfig $INTERFACE down

subnet-up:
#!/bin/sh
[ $NODE = `uci get tinc.$NETNAME.Name` ] && exit
route add -net $SUBNET dev $INTERFACE

subnet-down:
#!/bin/sh
[ $NODE = `uci get tinc.$NETNAME.Name` ] && exit
route del -net $SUBNET dev $INTERFACE


-- 
Sandy McArthur, Jr.

"No nation could preserve its freedom in the midst of continual warfare."
- Letters and Other Writings of James Madison (1865), Vol. IV, p. 491
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.tinc-vpn.org/pipermail/tinc/attachments/20130930/ab3f43fe/attachment.html>


More information about the tinc mailing list