#!/bin/sh
#
# Network hotplug policy agent for LFS
#
# Kernel NET hotplug params include:
#	
#	ACTION=%s [register or unregister]
#	INTERFACE=%s
#
# HISTORY:
#
# 05-Mar-2005	Initial version of LFS Version
#
#

cd /etc/hotplug
. ./hotplug.functions
#DEBUG=yes export DEBUG

if [ "$INTERFACE" = "" ]; then
    mesg Bad NET invocation: \$INTERFACE is not set
    exit 1
fi

case $ACTION in
add|register)

    case $INTERFACE in
	# interfaces that are registered after being "up" (?)
	ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
	    debug_mesg assuming $INTERFACE is already up
	    exit 0
	    ;;
	# interfaces that are registered then brought up
	*)
	    # LFS
	    export IN_HOTPLUG=1
	    debug_mesg invoke ifup $INTERFACE
	    exec /etc/sysconfig/network-devices/ifup $INTERFACE
	    ;;
    esac
    mesg $1 $ACTION event not handled
    ;;

remove|unregister)

    case $INTERFACE in
	# interfaces that are unregistered after being "down" (?)
	ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
	    debug_mesg assuming $INTERFACE is already down
	    exit 0
	    ;;
	*)
	    # LFS
	    export IN_HOTPLUG=1
		debug_mesg invoke ifdown $INTERFACE
		exec /etc/sysconfig/network-devices/ifdown $INTERFACE
	    ;;
    esac
    mesg $1 $ACTION event not handled
    ;;

*)
    debug_mesg NET $ACTION event for $INTERFACE not supported
    exit 1 ;;

esac
