]> git.immae.eu Git - perso/Immae/Config/tinc/hosts.git/blob - ImmaeEu-up
Merge branch 'master' into android
[perso/Immae/Config/tinc/hosts.git] / ImmaeEu-up
1 #!/system/xbin/sh
2
3 # Cannot expect awk to be present
4 SUBDOMAIN=$(echo "$NAME" | sed -e "s/\([A-Z][a-z0-9]*\)\([A-Z][a-z0-9]*\)/\L\2.\L\1/;")
5
6 MYIPS=$(nslookup $SUBDOMAIN.immae.eu |sed -n "/$SUBDOMAIN.immae.eu/"',$p' | grep ^Address | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ')
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' ' ')
8
9 echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /sdcard/.tinc/vars
10 ip -6 link set vpn6 up mtu 1280
11 for MYIP in $MYIPS; do
12 ip -6 addr add $MYIP/96 dev vpn6
13 done
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)
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