#!/bin/sh

# IPv6 part of the setup script, to be called with
# wan-interface-name my-address gateway-address aftr-end-point tsv-address

# from
# /usr/sbin/dhclient -6 -q -nw -D LL -cf /etc/sdb4/confs/dhclient6.conf \
#  -lf /tmp/lease6 $WANIF

WANIF=$1
MYADDR6=$2
GW6=$3
AFTR6=$4
TSV=$5

echo "my WAN interface is:" $WANIF
echo "my WAN IPv6 address is:" $MYADDR6
echo "the gateway address is:" $GW6
echo "the AFTR end-point address is:" $AFTR6
echo "the TSV address is:" $TSV

#set -x

ip -6 tunnel add tun0 mode ipip6 remote $AFTR6 \
  local $MYADDR6 dev $WANIF encaplimit none
ip link set tun0 up
ip addr add 192.0.0.2 peer 192.0.0.1 dev tun0
ip route add default via 192.0.0.1
ip -6 route add default via $GW6

#/usr/sbin/dhccra -q -S node -i $WANIF $TSV
/usr/sbin/dhccra -q -L -i $WANIF $TSV

/usr/sbin/dhclient -4 -q -nw -cf /etc/sdb4/confs/dhclient4.conf \
  -lf /tmp/lease4 $WANIF
