diff options
Diffstat (limited to 'ImmaeEu-up')
-rw-r--r--[-rwxr-xr-x] | ImmaeEu-up | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/ImmaeEu-up b/ImmaeEu-up index 3a2e073..f57c2e3 100755..100644 --- a/ImmaeEu-up +++ b/ImmaeEu-up | |||
@@ -1,24 +1,18 @@ | |||
1 | #!/bin/sh | 1 | #!/system/xbin/sh |
2 | # This file sets up the tap device. | ||
3 | # It gives you the freedom to do anything you want with it. | ||
4 | # Use the correct name for the tap device: | ||
5 | # The environment variable $INTERFACE is set to the right name | ||
6 | # on most platforms, but if it doesn't work try to set it manually. | ||
7 | 2 | ||
8 | # Give it the right ip and netmask. Remember, the subnet of the | 3 | SUBDOMAIN=$(cat /sdcard/.tinc/tinc_domaine | tr -c -d "[a-zA-Z0-9.]") |
9 | # tap device must be larger than that of the individual Subnets | 4 | |
10 | # as defined in the host configuration file! | 5 | MYIPS=$(nslookup $SUBDOMAIN.immae.eu |sed -n "/$SUBDOMAIN.immae.eu/"',$p' | grep ^Address | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ') |
11 | SUBDOMAIN=`cat /etc/tinc/$NETNAME/tinc_domaine` | 6 | GWIP=$(nslookup vpn.immae.eu |sed -n "/vpn.immae.eu/"',$p' | grep ^Address | head -n1 | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ') |
12 | while [ -z "$MYIPS" -o -z "$GWIP" ]; do | 7 | |
13 | MYIPS=`getent hosts ${SUBDOMAIN}.immae.eu | cut -d' ' -f1 | tr "\\n" ' '` | 8 | echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /sdcard/.tinc/vars |
14 | GWIP=`getent hosts vpn.immae.eu | head -n1 | cut -d' ' -f1` | 9 | ip -6 link set vpn6 up mtu 1280 |
15 | sleep 5 | ||
16 | done | ||
17 | rm -f /tmp/tinc_$NETNAME | ||
18 | echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /tmp/tinc_$NETNAME | ||
19 | ip -6 link set $INTERFACE up mtu 1280 | ||
20 | for MYIP in $MYIPS; do | 10 | for MYIP in $MYIPS; do |
21 | ip -6 addr add $MYIP/96 dev $INTERFACE | 11 | ip -6 addr add $MYIP/96 dev vpn6 |
22 | done | 12 | done |
23 | ip -6 route add default via $GWIP | 13 | ORIGINAL_GATEWAY=$(for a in $(ip rule show | grep lookup | sed -r 's/.* lookup ([^ ]+).*/\1/'); do ip route show table $a | grep ^default | cut -d ' ' -f 2-5; done | head -1) |
24 | (cd /etc/tinc/$NETNAME/hosts && git pull -q origin master) || true | 14 | |
15 | ip -6 rule add prio 100 from all lookup 100 | ||
16 | ip route add table 100 $REMOTEADDRESS $ORIGINAL_GATEWAY | ||
17 | ip -6 route add table 100 $GWIP dev vpn6 | ||
18 | ip -6 route add table 100 ::/1 via $GWIP dev vpn6 | ||