blob: 35a1aa639e2163411429e3804b7d48ff875f713c [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/sh
2
3
4WPA_SUP_BIN="/usr/sbin/wpa_supplicant"
5WPA_SUP_PNAME="wpa_supplicant"
6WPA_SUP_PIDFILE="/var/run/wpa_supplicant.$IFACE.pid"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05007WPA_COMMON_CTRL_IFACE="/var/run/wpa_supplicant"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008WPA_SUP_OPTIONS="-B -P $WPA_SUP_PIDFILE -i $IFACE"
9
10VERBOSITY=0
11
12
13if [ -s "$IF_WPA_CONF" ]; then
14 WPA_SUP_CONF="-c $IF_WPA_CONF"
15else
16 exit 0
17fi
18
19if [ ! -x "$WPA_SUP_BIN" ]; then
20
21 if [ "$VERBOSITY" = "1" ]; then
22 echo "$WPA_SUP_PNAME: binaries not executable or missing from $WPA_SUP_BIN"
23 fi
24
25 exit 1
26fi
27
28if [ "$MODE" = "start" ] ; then
29 # driver type of interface, defaults to wext when undefined
30 if [ -s "/etc/wpa_supplicant/driver.$IFACE" ]; then
31 IF_WPA_DRIVER=$(cat "/etc/wpa_supplicant/driver.$IFACE")
32 elif [ -z "$IF_WPA_DRIVER" ]; then
33
34 if [ "$VERBOSITY" = "1" ]; then
35 echo "$WPA_SUP_PNAME: wpa-driver not provided, using \"wext\""
36 fi
37
38 IF_WPA_DRIVER="wext"
39 fi
40
41 # if we have passed the criteria, start wpa_supplicant
42 if [ -n "$WPA_SUP_CONF" ]; then
43
44 if [ "$VERBOSITY" = "1" ]; then
45 echo "$WPA_SUP_PNAME: $WPA_SUP_BIN $WPA_SUP_OPTIONS $WPA_SUP_CONF -D $IF_WPA_DRIVER"
46 fi
47
48 start-stop-daemon --start --quiet \
49 --name $WPA_SUP_PNAME --startas $WPA_SUP_BIN --pidfile $WPA_SUP_PIDFILE \
50 -- $WPA_SUP_OPTIONS $WPA_SUP_CONF -D $IF_WPA_DRIVER
51 fi
52
53 # if the interface socket exists, then wpa_supplicant was invoked successfully
54 if [ -S "$WPA_COMMON_CTRL_IFACE/$IFACE" ]; then
55
56 if [ "$VERBOSITY" = "1" ]; then
57 echo "$WPA_SUP_PNAME: ctrl_interface socket located at $WPA_COMMON_CTRL_IFACE/$IFACE"
58 fi
59
60 exit 0
61
62 fi
63
64elif [ "$MODE" = "stop" ]; then
65
66 if [ -f "$WPA_SUP_PIDFILE" ]; then
67
68 if [ "$VERBOSITY" = "1" ]; then
69 echo "$WPA_SUP_PNAME: terminating $WPA_SUP_PNAME daemon"
70 fi
71
72 start-stop-daemon --stop --quiet \
73 --name $WPA_SUP_PNAME --pidfile $WPA_SUP_PIDFILE
74
75 if [ -S "$WPA_COMMON_CTRL_IFACE/$IFACE" ]; then
76 rm -f $WPA_COMMON_CTRL_IFACE/$IFACE
77 fi
78
79 if [ -f "$WPA_SUP_PIDFILE" ]; then
80 rm -f $WPA_SUP_PIDFILE
81 fi
82 fi
83
84fi
85
86exit 0