1#!/sbin/openrc-run 2# Copyright (c) 2009 Roy Marples <roy@marples.name> 3# All rights reserved. Released under the 2-clause BSD license. 4supervisor=supervise-daemon 5 6name="WPA Supplicant" 7description="Wi-Fi Protected Access client and IEEE 802.1X supplicant" 8 9command=/sbin/wpa_supplicant10wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if11command_args="$wpa_supplicant_args $wpa_supplicant_if"1213default_conf=/etc/wpa_supplicant/wpa_supplicant.conf1415depend() {16 need localmount17 use logger18 after bootmisc modules entropy udev-settle19 before dns dhcpcd net20 keyword -shutdown21 provide wlan22}2324find_wireless() {25 local iface=26 for iface in /sys/class/net/*; do27 if [ -e "$iface"/wireless -o -e "$iface"/phy80211 ]; then28 echo "${iface##*/}"29 return 030 fi31 done3233 return 134}3536append_wireless() {37 local iface= i=3839 iface=$(find_wireless)40 if [ -n "$iface" ]; then41 for i in $iface; do42 command_args="$command_args -i$i"43 done44 else45 eerror "Could not find a wireless interface"46 fi47}4849start_pre() {50 case " $command_args" in51 *" -i"*) ;;52 *) append_wireless;;53 esac5455 # set default conf if dbus is explicitly disabled56 if [ -n "${wpa_supplicant_dbus}" ] && ! yesno "${wpa_supplicant_dbus}"; then57 : ${wpa_supplicant_conf:=${default_conf}}58 fi5960 # use default conf if it exists61 if [ -f "${default_conf}" ]; then62 : ${wpa_supplicant_conf:=${default_conf}}63 fi6465 # enable default dbus if we still dont have a config66 if [ -z "${wpa_supplicant_conf}" ]; then67 : ${wpa_supplicant_dbus:=yes}68 else69 command_args="${command_args} -c$wpa_supplicant_conf"70 fi71 case " ${command_args}" in72 *" -u"*);;73 *) if yesno "{wpa_supplicant_dbus}"; then74 command_args="-u ${command_args}"75 fi76 ;;77 esac7879 checkpath -d -m 0755 -o root:root /var/run/wpa_supplicant80}