#!/bin/sh
# This should be called whenever an interface goes down, not just when
# it is brought down explicitly.

PATH=/sbin:/usr/sbin:/bin:/usr/bin

cd /etc/sysconfig/network-scripts
. network-functions

CONFIG=$1
source_config

DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"`

if [ "$DEVICETYPE" = "ppp" -o "$DEVICETYPE" = "ippp" ]; then
	if [ -f /etc/resolv.conf.save ]; then
		cat /etc/resolv.conf.save >/etc/resolv.conf
		rm -f /etc/resolv.conf.save
	fi
fi

# Reset the default route if this interface had a special one
if ! check_default_route; then
    add_default_route
fi

# Notify programs that have requested notification
do_netreport

IFDOWN_LOCAL=/usr/local/sbin/ifdown-local
if [ -x "$IFDOWN_LOCAL" ]; then
    "$IFDOWN_LOCAL" "$DEVICE"
fi

exit 0
