3 # run /sbin/{ifup,ifdown} with the --allow=hotplug option.
6 . /lib/udev/hotplug.functions
8 if [ -z "$INTERFACE" ]; then
9 mesg "Bad net.agent invocation: \$INTERFACE is not set"
16 mesg "ERROR: $1 not found. You need to install the ifupdown package."
17 mesg "net.agent $ACTION event for $INTERFACE not handled."
21 wait_for_interface() {
25 local state="$(cat /sys/class/net/$interface/operstate 2>/dev/null || true)"
26 if [ "$state" != down ]; then
34 check_program /sbin/ifup
36 if grep -q '^auto[[:space:]].*\<'"$INTERFACE"'\>' \
37 /etc/network/interfaces; then
38 # this $INTERFACE is marked as "auto"
39 IFUPARG='\('$INTERFACE'\|-a\|--all\)'
44 if ps -C ifup ho args | grep -q "$IFUPARG"; then
45 debug_mesg "Already ifup-ing interface $INTERFACE"
50 if [ -e /bin/systemctl ]; then
51 wait_for_file /dev/log
54 exec ifup --allow=hotplug $INTERFACE
58 check_program /sbin/ifdown
60 if ps -C ifdown ho args | grep -q $INTERFACE; then
61 debug_mesg "Already ifdown-ing interface $INTERFACE"
65 exec ifdown --allow=hotplug $INTERFACE
72 # these interfaces generate hotplug events *after* they are brought up
74 ppp*|ippp*|isdn*|plip*|lo|irda*|ipsec*)
82 # the pppd persist option may have been used, so it should not be killed
92 debug_mesg "NET $ACTION event not supported"
99 # When udev_log="debug" stdout and stderr are pipes connected to udevd.
100 # They need to be closed or udevd will wait for this process which will
101 # deadlock with udevsettle until the timeout.
102 do_everything > /dev/null 2> /dev/null &