]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/wlan-ng/files/wlan.agent
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / wlan-ng / files / wlan.agent
1 #!/bin/sh
2 #
3 # p80211/wlan hotplug policy agent.
4 #
5 # wlan hotplug params include:
6 #       
7 #       ACTION=%s [register|remove|shutdown|startup|suspend|resume]
8 #       INTERFACE=%s
9 #       NSDNAME=%s
10 #
11
12 cd /etc/hotplug
13 # must have ./ here or busybox shell barfs
14 . ./hotplug.functions
15
16 #DEBUG=yes export DEBUG
17
18 if [ "$INTERFACE" = "" ]; then
19     mesg Bad WLAN invocation: \$INTERFACE is not set
20     exit 1
21 fi
22
23 if [ "$NSDNAME" = "" ]; then
24     mesg Bad WLAN invocation: \$NSDNAME is not set
25     exit 1
26 fi
27
28 debug_mesg WLAN $ACTION on $INTERFACE \($NSDNAME\)
29
30 if [ "$NSDNAME" = "prism2_cs" ] ; then
31     mesg "WLAN Hotplug bypassed for pcmcia"
32     exit 0
33 fi
34
35 # load up the shared scripts
36 if [ ! -f /etc/wlan/shared ] ; then
37     mesg "/etc/wlan/shared not present, aborting"
38     exit 1
39 fi
40
41 ECHO=mesg
42 . /etc/wlan/shared
43
44 case $ACTION in
45 'register'|'resume')
46         eval 'WLAN_ENABLE=$ENABLE_'$INTERFACE
47         if ! is_true $WLAN_ENABLE ; then
48             mesg "WLAN $ACTION - interface $INTERFACE not enabled, aborting"
49             exit 1
50         fi
51         debug_mesg WLAN $INTERFACE registered.
52         wlan_bring_it_up $INTERFACE
53         if [ $? = 0 ] ; then
54             mesg WLAN $INTERFACE brought up successfully.
55                 if [ -x /etc/wlan/network ] ; then
56                         mesg "WLAN bringing up layer 3+ with /etc/wlan/network"
57                         /etc/wlan/network start $INTERFACE
58                 elif [ -x /etc/wlan/pre-ifup ] ; then
59                         # pre-ifup is presumed to call ifup if it
60                         #  wants to...it may choose to skip it.
61                         mesg "WLAN bringing up layer 3+ with /etc/wlan/pre-ifup"
62                         /etc/wlan/pre-ifup $INTERFACE
63                 else
64                         mesg "WLAN bringing up layer 3+ with /sbin/ifup"
65                         /sbin/ifup $INTERFACE
66                 fi
67         else
68             mesg WLAN Could not bring up $INTERFACE
69                  exit 1
70         fi
71         # eventually invoke net.agent on $INTERFACE w/ REGISTER
72 ;;
73 'remove'|'suspend')
74         debug_mesg WLAN $INTERFACE removed.
75         eval 'WLAN_ENABLE=$ENABLE_'$INTERFACE
76         if ! is_true $WLAN_ENABLE ; then
77             mesg "WLAN $ACTION - interface $INTERFACE not enabled, aborting"
78             exit 1
79         fi
80         if [ -x /etc/wlan/network ] ; then
81                 mesg "WLAN taking down layer 3+ with /etc/wlan/network"
82                 /etc/wlan/network stop $INTERFACE
83         elif [ -x /etc/wlan/post-ifdown ] ; then
84                 # post-ifdown is presumed to call ifdown if it
85                 #  wants to...it may choose to skip it.
86                 mesg "WLAN taking down layer 3+ with /etc/wlan/post-ifdown"
87                 /etc/wlan/post-ifdown $INTERFACE
88         else
89                 mesg "WLAN taking down layer 3+ with /sbin/ifdown"
90                 /sbin/ifdown $INTERFACE
91         fi
92         wlan_disable $INTERFACE
93 ;;
94 'startup')
95         # kick off wland.
96         debug_mesg WLAN p80211 starting!
97         start_wland
98 ;;
99 'shutdown')
100         debug_mesg WLAN p80211 shutting down!
101         stop_wland
102 ;;
103 *)
104     debug_mesg WLAN $ACTION event not supported
105     exit 1 ;;
106
107 esac