diff options
-rw-r--r--[-rwxr-xr-x] | ImmaeEu-down | 18 | ||||
-rw-r--r--[-rwxr-xr-x] | ImmaeEu-up | 37 |
2 files changed, 27 insertions, 28 deletions
diff --git a/ImmaeEu-down b/ImmaeEu-down index 8459778..1b6260e 100755..100644 --- a/ImmaeEu-down +++ b/ImmaeEu-down | |||
@@ -1,12 +1,16 @@ | |||
1 | #!/bin/sh | 1 | #!/system/xbin/sh |
2 | # This file closes down the tap device. | 2 | # This file closes down the tap device. |
3 | 3 | ||
4 | [ -e /tmp/tinc_$NETNAME ] && . /tmp/tinc_$NETNAME | 4 | source /sdcard/.tinc/vars |
5 | [ -e /run/tinc_$NETNAME.vars ] && . /run/tinc_$NETNAME.vars | 5 | rm /sdcard/.tinc/vars |
6 | rm -f /tmp/tinc_$NETNAME /run/tinc_$NETNAME.vars | 6 | |
7 | [ -n "$GWIP" ] && ip -6 route del default via $GWIP | 7 | ip -6 rule del from all lookup 100 |
8 | ip route del table 100 $REMOTEADDRESS | ||
9 | ip -6 route del table 100 $GWIP dev vpn6 | ||
10 | ip -6 route del table 100 ::/1 via $GWIP dev vpn6 | ||
8 | for MYIP in $MYIPS; do | 11 | for MYIP in $MYIPS; do |
9 | ip -6 addr del $MYIP/96 dev $INTERFACE | 12 | ip -6 addr del $MYIP/96 dev vpn6 |
10 | done | 13 | done |
11 | ip -6 link set $INTERFACE down | 14 | ip -6 link set vpn6 down |
15 | |||
12 | 16 | ||
diff --git a/ImmaeEu-up b/ImmaeEu-up index c2dc93a..b24eed8 100755..100644 --- a/ImmaeEu-up +++ b/ImmaeEu-up | |||
@@ -1,24 +1,19 @@ | |||
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 | # Cannot expect awk to be present |
9 | # tap device must be larger than that of the individual Subnets | 4 | SUBDOMAIN=$(echo "$NAME" | sed -e "s/\([A-Z][a-z0-9]*\)\([A-Z][a-z0-9]*\)/\L\2.\L\1/;") |
10 | # as defined in the host configuration file! | 5 | |
11 | 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; }') | 6 | MYIPS=$(nslookup $SUBDOMAIN.immae.eu |sed -n "/$SUBDOMAIN.immae.eu/"',$p' | grep ^Address | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ') |
12 | while [ -z "$MYIPS" -o -z "$GWIP" ]; do | 7 | GWIP=$(nslookup gw.vpn.immae.eu |sed -n "/gw.vpn.immae.eu/"',$p' | grep ^Address | head -n1 | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ') |
13 | MYIPS=`getent hosts ${SUBDOMAIN}.immae.eu | cut -d' ' -f1 | tr "\\n" ' '` | 8 | |
14 | GWIP=`getent hosts gw.vpn.immae.eu | head -n1 | cut -d' ' -f1` | 9 | echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /sdcard/.tinc/vars |
15 | sleep 5 | 10 | ip -6 link set vpn6 up mtu 1280 |
16 | done | ||
17 | rm -f /run/tinc_$NETNAME.vars | ||
18 | echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /run/tinc_$NETNAME.vars | ||
19 | ip -6 link set $INTERFACE up mtu 1280 | ||
20 | for MYIP in $MYIPS; do | 11 | for MYIP in $MYIPS; do |
21 | ip -6 addr add $MYIP/96 dev $INTERFACE | 12 | ip -6 addr add $MYIP/96 dev vpn6 |
22 | done | 13 | done |
23 | ip -6 route add default via $GWIP | 14 | 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 | 15 | |
16 | ip -6 rule add prio 100 from all lookup 100 | ||
17 | ip route add table 100 $REMOTEADDRESS $ORIGINAL_GATEWAY | ||
18 | ip -6 route add table 100 $GWIP dev vpn6 | ||
19 | ip -6 route add table 100 ::/1 via $GWIP dev vpn6 | ||