#!/bin/sh #---------------------------------------------------------------------------- # /etc/ppp/ipv6-up - called whenever a (i)ppp connection has been come up # # Creation: 26.09.2009 zone42 # Last Update: $Id$ #---------------------------------------------------------------------------- run_ipv6_up () { case $interface in ppp0) # it's DSL, map interface case $tty in "" | eth*| br* | /dev/ttyp0 | /dev/ttyS[0-4] | /dev/ttyUSB0 | /dev/capi/0 | /dev/ttyACM0 ) # empty: PPPoE, eth[0-9] in_kernel, else PPTP interface=pppoe ;; esac ;; esac echo $local >/var/run/$interface.ipv6 # store my own ip address # # default route is either # default via dev # or # default dev def_gateway="" def_route=`ip -f inet6 route show | grep ^default` route_dev= route_gw="" if [ "$def_route" ]; then set $def_route case $# in 3) route_dev=$3 ;; 5) route_gw=$3 route_dev=$5 ;; *) logger -t "ipv6-up[$$]" "Unknown route format '$def_route'" ;; esac fi if [ -f /etc/default-route-interface ] # default route existing? then read default_route_interface def_gateway < /etc/default-route-interface else default_route_interface=$route_dev case $default_route_interface in ppp0) default_route_interface=pppoe ;; esac fi if [ "$default_route_interface" = "$interface" ] then logger -t "ipv6-up[$$]" "default route interface '$interface' comes up" is_default_route='yes' > /var/run/online.ipv6 : ${def_gateway:=""} if [ "$route_dev" ] then if [ "$route_dev" != "$default_route_interface" -o \ "$route_gw" != "$def_gateway" ]; then logger -t "ipv6-up[$$]" "changing default route from $route_gw:$route_dev to $def_gateway:$interface" case $def_gateway in "") ip -f inet6 route change default dev $real_interface ;; *) ip -f inet6 route change via $def_gateway ;; esac fi else ip -f inet6 route add default dev $real_interface fi else is_default_route='no' fi # if [ "$interface" = "pppoe" -a -f /var/run/imond.pid ] # then # /usr/local/bin/imond-stat "pppoe: up" # fi # Call all custom ipv6-ups for j in /etc/ppp/ipv6-up[0-9][0-9][0-9].* do if [ -f $j ] then logger -t "ipv6-up[$$]" "executing $j" . $j fi done if [ ! -f /var/run/ipv6-up.ppp-once ] then for j in /etc/ppp-once/ipv6-up[0-9][0-9][0-9].* do if [ -f $j ] then . $j fi done fi } export PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin # Wait for end of boot while [ ! -f /var/run/boot_finished ] do sleep 1 done if [ -f /var/run/syslogd.pid ]; then exec > /tmp/ipv6-up.$$ 2>&1 else exec >/dev/console 2>&1 fi [ -f /var/run/debug_ipv6up ] && set -x real_interface=$1 interface=$1 tty=$2 speed=$3 local=$4 remote=$5 lock_file=/var/lock/pppd.ipv6.$interface # Wait for other ipv6-up/ip-down instances while [ -f $lock_file ] do sleep 1 done > $lock_file run_ipv6_up set +x if [ -f /tmp/ipv6-up.$$ ] then sed -e "s/`echo -e '\033'`\[[0-9]\+m//g" /tmp/ipv6-up.$$ | logger -t ipv6-up rm -f /tmp/ipv6-up.$$ fi rm -f $lock_file exit 0