#!/bin/sh #---------------------------------------------------------------------------- # /etc/ppp/ipv6-down - called whenever a (i)ppp connection has been come down # # Creation: 26.09.2009 zone42 # Last Update: $Id$ #---------------------------------------------------------------------------- export PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin real_interface=$1 interface=$1 tty=$2 speed=$3 local=$4 remote=$5 lock_file=/var/lock/pppd.ipv6.$interface run_ipv6_down () { 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 # rm -f /var/run/pppoe.up # if [ -f /var/run/imond.pid ] # then # /usr/local/bin/imond-stat "pppoe: down" # fi ;; esac ;; esac rm -f /var/run/$interface.ipv6 # default route existing or last default route interface going down? if [ -f /etc/default-ipv6-route-interface ] then read default_route_interface def_gateway < /etc/default-ipv6-route-interface elif [ -f /etc/last-default-ipv6-route-interface ] then read default_route_interface def_gateway < /etc/last-default-ipv6-route-interface rm -f /etc/last-default-ipv6-route-interface else default_route_interface=`ip -f inet6 route show | grep '^default' | sed 's/^default.*dev //g'` case $default_route_interface in ppp0) default_route_interface=pppoe ;; esac fi if [ "$default_route_interface" = "$interface" ] then logger -t "ipv6-down[$$]" "default interface '$interface' goes down" rm -f /var/run/online.ipv6 is_default_route='yes' else is_default_route='no' fi # Call all custom ipv6-downs for j in /etc/ppp/ipv6-down[0-9][0-9][0-9].* do if [ -f $j ] then logger -t "ipv6-down[$$]" "executing $j" . $j fi done } # Wait for other ip-up/ipv6-down instances while [ -f $lock_file ] do sleep 3 done > $lock_file if [ -f /var/run/syslogd.pid ] # Log to syslog if available... then run_ipv6_down > /tmp/ipv6-down.$$ 2>&1 sed -e "s/`echo -e '\033'`\[[0-9]\+m//g" /tmp/ipv6-down.$$ | logger -t ipv6-down rm -f /tmp/ipv6-down.$$ else run_ipv6_down >/dev/console 2>&1 fi rm -f $lock_file exit 0