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