From bbe3d612a4a5e1ef32c26b5cb49fc549762d4b35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 17 Jun 2015 18:51:07 +0200 Subject: [PATCH] Android scripts --- ImmaeEu-down | 11 ++++++----- ImmaeEu-up | 28 +++++++++------------------- 2 files changed, 15 insertions(+), 24 deletions(-) mode change 100755 => 100644 ImmaeEu-down mode change 100755 => 100644 ImmaeEu-up diff --git a/ImmaeEu-down b/ImmaeEu-down old mode 100755 new mode 100644 index 8e562a4..db41301 --- a/ImmaeEu-down +++ b/ImmaeEu-down @@ -1,11 +1,12 @@ -#!/bin/sh +#!/bin/sh # This file closes down the tap device. -source /tmp/tinc_$NETNAME -rm -f /tmp/tinc_$NETNAME +source /sdcard/.tinc/vars +rm /sdcard/.tinc/vars + ip -6 route del default via $GWIP for MYIP in $MYIPS; do - ip -6 addr del $MYIP/96 dev $INTERFACE + ip -6 addr del $MYIP/96 dev vpn6 done -ip -6 link set $INTERFACE down +ip -6 link set vpn6 down diff --git a/ImmaeEu-up b/ImmaeEu-up old mode 100755 new mode 100644 index 00eb60f..95004f3 --- a/ImmaeEu-up +++ b/ImmaeEu-up @@ -1,23 +1,13 @@ -#!/bin/sh -# This file sets up the tap device. -# It gives you the freedom to do anything you want with it. -# Use the correct name for the tap device: -# The environment variable $INTERFACE is set to the right name -# on most platforms, but if it doesn't work try to set it manually. +#!/system/xbin/sh -# 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` -while [ -z "$MYIPS" -o -z "$GWIP" ]; do - MYIPS=`getent hosts ${SUBDOMAIN}.immae.eu | cut -d' ' -f1 | tr "\\n" ' '` - GWIP=`getent hosts 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 -ip -6 link set $INTERFACE up mtu 1280 +SUBDOMAIN=$(cat /sdcard/.tinc/tinc_domaine | tr -c -d "[a-zA-Z0-9.]") + +MYIPS=$(nslookup $SUBDOMAIN.immae.eu |sed -n "/$SUBDOMAIN.immae.eu/"',$p' | grep ^Address | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ') +GWIP=$(nslookup vpn.immae.eu |sed -n "/vpn.immae.eu/"',$p' | grep ^Address | head -n1 | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ') + +echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /sdcard/.tinc/vars +ip -6 link set vpn6 up mtu 1280 for MYIP in $MYIPS; do - ip -6 addr add $MYIP/96 dev $INTERFACE + ip -6 addr add $MYIP/96 dev vpn6 done ip -6 route add default via $GWIP -- 2.41.0