#!/usr/bin/sh #---------------------------------------------------------------------------- # /etc/ppp/ip-down - called whenever a (i)ppp connection has been come down # # Creation: 2002-11-24 fm # Last Update: $Id$ # # Copyright (c) 2002-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- real_interface=${1} interface=${1} tty=${2} speed=${3} local=${4} remote=${5} rm -f /run/${interface}.ip # default route existing or last default route interface going down? if [ -f /etc/default-route-interface ] then default_route_interface=$(/usr/bin/cat /etc/default-route-interface) elif [ -f /etc/last-default-route-interface ] then default_route_interface=$(/usr/bin/cat /etc/last-default-route-interface) rm -f /etc/last-default-route-interface fi if [ "${default_route_interface}" = "${interface}" ] then # Call all custom ip-downs for j in /etc/ppp/ip-down.* do if [ -f ${j} ] then . ${j} fi done fi if [ -f /run/${interface}.route-fix -a -f /run/${interface}.conf ] then # get configuration from file, format: # local remote netmask {network real_netmask}* conf=$(/usr/bin/cat /run/${interface}.conf) set ${conf} ip=${1} subnet=${3} network=$(/usr/bin/netcalc network ${ip}:${subnet}) netmaskbits="/$(/usr/bin/netcalc netmaskbits ${network}:${subnet})" # restore original device configuration /usr/sbin/ip link set dev ${interface} down /usr/sbin/ip addr add ${ip}/${netmaskbits} peer ${2} dev ${interface} /usr/sbin/ip link set dev ${interface} up shift 3 # setup routes again while [ -n "${1}" ] do ip=${1} subnet=${2} network=$(/usr/bin/netcalc network ${ip}:${subnet}) netmaskbits="$(/usr/bin/netcalc netmaskbits ${network}:${subnet})" /usr/sbin/ip route add ${ip}${netmaskbits} dev ${interface} shift 2 done #setup default route if our interface is the default routes interface if [ -f /etc/default-route-interface ] # default route existing? then default_route_interface=$(/usr/bin/cat /etc/default-route-interface) if [ "${default_route_interface}" = "${interface}" ] then /usr/sbin/ip route add default ${interface} fi fi fi exit 0