#!/bin/sh #---------------------------------------------------------------------------- # /etc/ppp/addr-up - called whenever a circuit receives a local IPv4 address # # Input: # $1 = network interface # $2 = circuit identifier # $3 = local IPv4 address # $4 = if non-empty, we are called from within ip-up # # Last Update: $Id$ #---------------------------------------------------------------------------- . /etc/boot.d/forking.inc . /etc/boot.d/lazy.inc . /etc/boot.d/locking.inc . /etc/boot.d/networking.inc script_name="$(basename $0)" script="$script_name[$$]" facility=$circuit_logfacility logmsgprio=$facility.notice . /usr/share/logfunc.sh export PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin interface=$1 circ_id=$2 address=$3 ipup=$4 { fork_call_handlers sync_lock_resource addrupdown-$circ_id "$script" echo "$circ_id[$interface]: IPv4 address $address has appeared" is_default_route=no circuit_read_field $circ_id circ_nets_ipv4_n for i in $(seq 1 $circ_nets_ipv4_n) do circuit_read_field $circ_id circ_nets_ipv4_$i net if [ "$net" = "0.0.0.0/0" ] then is_default_route=yes break fi done if [ "$is_default_route" = yes ] then # a local address connected to a gateway is assumed to be externally # visible, so put it into dynamic.ip sync_lock_resource dynamic.ip addr-up echo $address >> /var/run/dynamic.ip sync_unlock_resource dynamic.ip addr-up fi addresses=$(circuit_get_local_addresses $circ_id ipv4) circuit_register_local_address $circ_id ipv4 $address setup-dynamic-iptables.sh # Call all custom addr-ups lazy_begin for j in /etc/ppp/addr-up[0-9][0-9][0-9].* do if [ -f $j ] then echo "executing $j" . $j fi done lazy_end if [ -z "$addresses" -a -z "$ipup" ] then # call ip-up when the first address has appeared /etc/ppp/ip-up $interface /dev/null 0 $address "" $circ_id 1 & fi sync_unlock_resource addrupdown-$circ_id "$script" } 2>&1 | logmsg "$script" $logmsgprio