Debian Codegraph @

support/init.d.examples/wpa_supplicant.in

raw
1 #!@SBINDIR@/openrc-run
2 # Copyright (c) 2007-2015 The OpenRC Authors.
3 # See the Authors file at the top-level directory of this distribution and
4 # https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
5 #
6 # This file is part of OpenRC. It is subject to the license terms in
7 # the LICENSE file found in the top-level directory of this
8 # distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE
9 # This file may not be copied, modified, propagated, or distributed
10 # except according to the terms contained in the LICENSE file.
11
12 command=/usr/sbin/wpa_supplicant
13 : ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf}
14 wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if
15 command_args="$wpa_supplicant_args -B -c$wpa_supplicant_conf $wpa_supplicant_if"
16 name="WPA Supplicant Daemon"
17
18 depend()
19 {
20 need localmount
21 use logger
22 after bootmisc modules
23 before dns dhcpcd net
24 keyword -shutdown
25 }
26
27 find_wireless()
28 {
29 local iface=
30
31 case "$RC_UNAME" in
32 Linux)
33 for iface in /sys/class/net/*; do
34 if [ -e "$iface"/wireless -o \
35 -e "$iface"/phy80211 ]
36 then
37 echo "${iface##*/}"
38 return 0
39 fi
40 done
41 ;;
42 FreeBSD)
43 for iface in $(sysctl -b net.wlan.devices 2>/dev/null); do
44 echo "${iface##*/}"
45 done
46 ;;
47 *)
48 for iface in /dev/net/* $(ifconfig -l 2>/dev/null); do
49 if ifconfig "${iface##*/}" 2>/dev/null | \
50 grep -q "[ ]*ssid "
51 then
52 echo "${iface##*/}"
53 return 0
54 fi
55 done
56 ;;
57 esac
58
59 return 1
60 }
61
62 append_wireless()
63 {
64 local iface= i=
65
66 iface=$(find_wireless)
67 if [ -n "$iface" ]; then
68 for i in $iface; do
69 command_args="$command_args -i$i"
70 done
71 else
72 eerror "Could not find a wireless interface"
73 fi
74 }
75
76 start_pre()
77 {
78 case " $command_args" in
79 *" -i"*) ;;
80 *) append_wireless;;
81 esac
82 }