summaryrefslogtreecommitdiff
path: root/debian/ifplugd.hotplug
blob: acfec6a3f8a5f6de256fc68a6e883fc2a23837f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
# hotplug agent script

DAEMON_NAME=ifplugd

DAEMON=/usr/sbin/$DAEMON_NAME
CFG=/etc/default/$DAEMON_NAME

[ -x $DAEMON ] || exit 0

HOTPLUGFUNCS=/etc/hotplug/hotplug.functions
[ -f $HOTPLUGFUNCS ] || exit 1
. $HOTPLUGFUNCS
DEBUG=yes export DEBUG

[ "$INTERFACE" ] || { mesg Bad invocation: \$INTERFACE is not set ; exit 1 ; }

[ -f $CFG ] || { mesg No $DAEMON_NAME configuration file ; exit 1 ; }
. $CFG

if [ -x /sbin/ifrename -a -r /etc/iftab ] ; then
	IFACE_RENAMED=$(/sbin/ifrename -i $INTERFACE)
	if [ $? == 0 ] ; then
		debug_mesg $INTERFACE renamed to $IFACE_RENAMED
		INTERFACE=$IFACE_RENAMED
	else
		debug_mesg ifrename failed
	fi
fi

case $ACTION in
add|register)
	for IF in $HOTPLUG_INTERFACES ; do
		if [ "$INTERFACE" = "$IF" -o "$IF" = "all" ] ; then
			debug_mesg Invoking $DAEMON_NAME for $INTERFACE
			/etc/init.d/$DAEMON_NAME start $INTERFACE
			break
		fi
	done
	;;
remove|unregister)
	debug_mesg Stopping $DAEMON_NAME for $INTERFACE
	/etc/init.d/$DAEMON_NAME stop $INTERFACE
	;;
esac