From dbf5d2834a4e912a9787201313219a817b5c26a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 12 Feb 2020 16:48:50 +0100 Subject: Adjust scripts to remove the need of tinc_domaine --- ImmaeEu-down | 11 ++++++----- ImmaeEu-up | 14 +++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ImmaeEu-down b/ImmaeEu-down index d5e9ccf..8dc9fc4 100755 --- a/ImmaeEu-down +++ b/ImmaeEu-down @@ -1,11 +1,12 @@ #!/bin/sh # This file closes down the tap device. -. /tmp/tinc_$NETNAME -rm -f /tmp/tinc_$NETNAME -ip -6 route del default via $GWIP -for MYIP in $MYIPS; do - ip -6 addr del $MYIP/96 dev $INTERFACE +[ -e /tmp/tinc_$NETNAME ] && . /tmp/tinc_$NETNAME +[ -e /run/tinc_$NETNAME.vars ] && . /run/tinc_$NETNAME.vars +rm -f /tmp/tinc_$NETNAME /run/tinc_$NETNAME.vars +[ -n "$GWIP" ] && ip -6 route del default via $GWIP +for MYIP in "$MYIPS"; do + ip -6 addr del $MYIP/96 dev $INTERFACE done ip -6 link set $INTERFACE down diff --git a/ImmaeEu-up b/ImmaeEu-up index 56710a1..c2dc93a 100755 --- a/ImmaeEu-up +++ b/ImmaeEu-up @@ -8,17 +8,17 @@ # Give it the right ip and netmask. Remember, the subnet of the # tap device must be larger than that of the individual Subnets # as defined in the host configuration file! -SUBDOMAIN=`cat /etc/tinc/$NETNAME/tinc_domaine` +SUBDOMAIN=$(echo "$NAME" | sed -e "s/\([A-Z][a-z0-9]*\)/\L\1 /g;" | awk '{ for (i=NF; i>1; i--) printf("%s.",$i); print $1; }') while [ -z "$MYIPS" -o -z "$GWIP" ]; do - MYIPS=`getent hosts ${SUBDOMAIN}.immae.eu | cut -d' ' -f1 | tr "\\n" ' '` - GWIP=`getent hosts gw.vpn.immae.eu | head -n1 | cut -d' ' -f1` - sleep 5 + MYIPS=`getent hosts ${SUBDOMAIN}.immae.eu | cut -d' ' -f1 | tr "\\n" ' '` + GWIP=`getent hosts gw.vpn.immae.eu | head -n1 | cut -d' ' -f1` + sleep 5 done -rm -f /tmp/tinc_$NETNAME -echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /tmp/tinc_$NETNAME +rm -f /run/tinc_$NETNAME.vars +echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /run/tinc_$NETNAME.vars ip -6 link set $INTERFACE up mtu 1280 for MYIP in $MYIPS; do - ip -6 addr add $MYIP/96 dev $INTERFACE + ip -6 addr add $MYIP/96 dev $INTERFACE done ip -6 route add default via $GWIP (cd /etc/tinc/$NETNAME/hosts && git pull -q origin master) || true -- cgit v1.2.3