#! /bin/sh #---------------------------------------------------------------------------- # add-default-route - add default route # # called by imond # # Creation: 14.11.2000 fm # Last Update: $Id$ #---------------------------------------------------------------------------- device=$1 wait_for_device () { for i in `seq 1 20` do if ip link show $device 2>/dev/null | grep -q "[<,]UP[,>]" then if [ -f /var/run/$device.gw ]; then read gw < /var/run/$device.gw [ "$gw" ] && gw="via $gw" fi logger -t add-default-route "ip route add default dev $device $gw" exec ip route add default dev $device $gw fi sleep 1 done logger -t add-default-route "giving up after $i seconds" } logger -t add-default-route "adding route for $device" if [ "$device" = "pppoe" ] then device=`cat /var/run/pppoe-device` device='ppp0' fi if ip link show $device 2>/dev/null | grep -q "[<,]UP[,>]" then wait_for_device else wait_for_device & fi