summaryrefslogtreecommitdiff
path: root/recipes/wlan-ng/files/wlan.agent
blob: 945d646984f9268558ba1a77a36f18f710f3bb33 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
#
# p80211/wlan hotplug policy agent.
#
# wlan hotplug params include:
#	
#	ACTION=%s [register|remove|shutdown|startup|suspend|resume]
#	INTERFACE=%s
#       NSDNAME=%s
#

cd /etc/hotplug
# must have ./ here or busybox shell barfs
. ./hotplug.functions

#DEBUG=yes export DEBUG

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

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

debug_mesg WLAN $ACTION on $INTERFACE \($NSDNAME\)

if [ "$NSDNAME" = "prism2_cs" ] ; then
    mesg "WLAN Hotplug bypassed for pcmcia"
    exit 0
fi

# load up the shared scripts
if [ ! -f /etc/wlan/shared ] ; then
    mesg "/etc/wlan/shared not present, aborting"
    exit 1
fi

ECHO=mesg
. /etc/wlan/shared

case $ACTION in
'register'|'resume')
	eval 'WLAN_ENABLE=$ENABLE_'$INTERFACE
	if ! is_true $WLAN_ENABLE ; then
	    mesg "WLAN $ACTION - interface $INTERFACE not enabled, aborting"
	    exit 1
	fi
	debug_mesg WLAN $INTERFACE registered.
	wlan_bring_it_up $INTERFACE
	if [ $? = 0 ] ; then
	    mesg WLAN $INTERFACE brought up successfully.
		if [ -x /etc/wlan/network ] ; then
			mesg "WLAN bringing up layer 3+ with /etc/wlan/network"
			/etc/wlan/network start $INTERFACE
		elif [ -x /etc/wlan/pre-ifup ] ; then
			# pre-ifup is presumed to call ifup if it
			#  wants to...it may choose to skip it.
			mesg "WLAN bringing up layer 3+ with /etc/wlan/pre-ifup"
			/etc/wlan/pre-ifup $INTERFACE
		else
			mesg "WLAN bringing up layer 3+ with /sbin/ifup"
			/sbin/ifup $INTERFACE
		fi
	else
	    mesg WLAN Could not bring up $INTERFACE
		 exit 1
	fi
	# eventually invoke net.agent on $INTERFACE w/ REGISTER
;;
'remove'|'suspend')
	debug_mesg WLAN $INTERFACE removed.
	eval 'WLAN_ENABLE=$ENABLE_'$INTERFACE
	if ! is_true $WLAN_ENABLE ; then
	    mesg "WLAN $ACTION - interface $INTERFACE not enabled, aborting"
	    exit 1
	fi
	if [ -x /etc/wlan/network ] ; then
		mesg "WLAN taking down layer 3+ with /etc/wlan/network"
		/etc/wlan/network stop $INTERFACE
	elif [ -x /etc/wlan/post-ifdown ] ; then
		# post-ifdown is presumed to call ifdown if it
		#  wants to...it may choose to skip it.
		mesg "WLAN taking down layer 3+ with /etc/wlan/post-ifdown"
		/etc/wlan/post-ifdown $INTERFACE
	else
		mesg "WLAN taking down layer 3+ with /sbin/ifdown"
		/sbin/ifdown $INTERFACE
	fi
	wlan_disable $INTERFACE
;;
'startup')
	# kick off wland.
	debug_mesg WLAN p80211 starting!
	start_wland
;;
'shutdown')
	debug_mesg WLAN p80211 shutting down!
	stop_wland
;;
*)
    debug_mesg WLAN $ACTION event not supported
    exit 1 ;;

esac