aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/net.hotplug
blob: 543fb541c40b641ce6be15ab1ba096a77685be7e (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
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh

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

if [ "$INTERFACE" = "" ]; then
    exit 1
fi

case $ACTION in
add|register)
    # Don't do anything if the network is stopped
    if [ -f /dev/.in_sysinit ] ; then
	exit 0
    fi
    if [ ! -f /var/lock/subsys/network ]; then
	exit 0
    fi
    
    case $INTERFACE in
	# interfaces that are registered after being "up" (?)
	ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
	    exit 0
	    ;;
	# interfaces that are registered then brought up
	*)
	    export IN_HOTPLUG=1
	    if [ -x /sbin/ifup ]; then
	        addr=$(get_hwaddr ${INTERFACE})
		if [ -n "$addr" ]; then
			nconfig=$(get_config_by_hwaddr ${addr})
			[ -n "$nconfig" ] && INTERFACE=$nconfig
		fi
		exec /sbin/ifup $INTERFACE
	    fi	
	    ;;
    esac
    ;;

remove|unregister)
    case $INTERFACE in
	# interfaces that are unregistered after being "down" (?)
	ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
	    exit 0
	    ;;
	*)
	    # RedHat and similar
	    export IN_HOTPLUG=1
	    if [ -x /sbin/ifdown ]; then
		exec /sbin/ifdown $INTERFACE
	    fi
	    ;;
    esac
    ;;

*)
    exit 1 ;;

esac