#!/bin/sh #---------------------------------------------------------------------------- # /etc/ppp/ip-down - called whenever a circuit connection goes offline # # Input: # $1 = network interface # $2 = TTY device (mostly useless, often set to /dev/null if there is no TTY) # $3 = TTY speed (may be empty, see above) # $4 = local IPv4 address (optionally with subnet mask in CIDR notation) # $5 = remote IPv4 address (if this is a point-to-point connection) # $6 = circuit identifier # $7 = if non-empty, we are called from within addr-down # # Creation: 29.03.2000 fm # Last Update: $Id$ #---------------------------------------------------------------------------- . /etc/boot.d/lazy.inc . /etc/boot.d/networking.inc run_ip_down () { circuit_lock ipv4updown-$circ_id "$script" echo "circuit $circ_id[$interface] goes down" [ -n "$local" ] && echo "$circ_id: local IPv4 address: $local" [ -n "$remote" ] && echo "$circ_id: remote IPv4 address: $remote" local is_default_route=no i= for i in $(seq 1 $circ_nets_ipv4_n) do eval local net=\$circ_nets_ipv4_$i if [ "$net" = "0.0.0.0/0" ] then is_default_route=yes break fi done # Call all custom ip-downs lazy_begin for j in /etc/ppp/ip-down[0-9][0-9][0-9].* do if [ -f $j ] then echo "executing $j" . $j fi done lazy_end circuit_lock $circ_id "$script" circuit_remove_routes $circ_id 4 setup-dynamic-iptables.sh for i in $(seq 1 $circ_nets_ipv4_n) do eval local net=\$circ_nets_ipv4_$i circuit_deregister_routed_network $circ_id ipv4 $net [ -f /var/run/imond.pid ] && imond-stat "$circ_id down $net" done # now the circuit is at most semionline circuit_go_offline_if_necessary $circ_id ipv4 circuit_unlock $circ_id "$script" circuit_unlock ipv4updown-$circ_id "$script" } interface=$1 tty=$2 speed=$3 local=${4:+$(netcalc canonicalize $4)} remote=$5 circ_id=$6 addrdown=$7 if [ -n "$local" -a -z "$addrdown" ] then /etc/ppp/addr-down $interface $circ_id "$local" 1 & fi ip=ip script_op=down . /etc/ppp/ip-up-down