Update openembedded-core / meta-openembedded / bitbake (1.25.0)
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-connectivity / wpa-supplicant / wpa-supplicant / action_wpa.sh
1 #!/bin/sh
2
3 # Action script to enable/disable wpa-roam interfaces in reaction to
4 # ifplugd events.
5 #
6 # Copyright: Copyright (c) 2008-2010, Kel Modderman <kel@otaku42.de>
7 # License:   GPL-2
8 #
9
10 PATH=/sbin:/usr/sbin:/bin:/usr/bin
11
12 if [ ! -x /usr/sbin/wpa_action ]; then
13         exit 0
14 fi
15
16 # ifplugd(8) - <iface> <action>
17 #
18 # If an ifplugd managed interface is brought up, disconnect any
19 # wpa-roam managed interfaces so that only one "roaming" interface
20 # remains active on the system.
21
22 IFPLUGD_IFACE="${1}"
23
24 case "${2}" in
25         up)
26                 COMMAND=disconnect
27                 ;;
28         down)
29                 COMMAND=reconnect
30                 ;;
31         *)
32                 echo "$0: unknown arguments: ${@}" >&2
33                 exit 1
34                 ;;
35 esac
36
37 for CTRL in /var/run/wpa_supplicant/*; do
38         [ -S "${CTRL}" ] || continue
39
40         IFACE="${CTRL#/var/run/wpa_supplicant/}"
41
42         # skip if ifplugd is managing this interface
43         if [ "${IFPLUGD_IFACE}" = "${IFACE}" ]; then
44                 continue
45         fi
46
47         if wpa_action "${IFACE}" check; then
48                 wpa_cli -i "${IFACE}" "${COMMAND}"
49         fi
50 done