#!/bin/sh -e
#
# nethotplug	manage Debian-specific network interfaces state files
#

HOTPLUG_TIMEOUT=900 # Note: tenths

. /lib/lsb/init-functions

case "$1" in
    start)
	: > /etc/hotplug/.run/net.enable

	if [ -e /etc/hotplug/.run/net.busy ]; then
		log_begin_msg "Waiting for network interface to come up..."
		while [ -e /etc/hotplug/.run/net.busy ] &&
				[ $HOTPLUG_TIMEOUT != 0 ]; do
			sleep 0.1
			HOTPLUG_TIMEOUT=$(($HOTPLUG_TIMEOUT - 1))
		done
		if [ $HOTPLUG_TIMEOUT != 0 ]; then
			log_end_msg 0
		else
			log_end_msg 1
		fi
	fi	
	;;
    stop)
	if [ -e /etc/hotplug/.run/net.enable ]; then
	    rm -f /etc/hotplug/.run/net.enable
	fi
	;;
  restart|force-reload)
	;;
    *)
	echo "Usage: $0 {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac
