parlay

yet another gentoo overlay
git clone https://git.parazyd.org/parlay
Log | Files | Refs | README

wpa_supplicant-init.d (1250B)


      1 #!/sbin/openrc-run
      2 # Copyright (c) 2009 Roy Marples <roy@marples.name>
      3 # All rights reserved. Released under the 2-clause BSD license.
      4 
      5 command=/usr/sbin/wpa_supplicant
      6 : ${wpa_supplicant_conf:=/etc/wpa_supplicant/wpa_supplicant.conf}
      7 wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if
      8 command_args="$wpa_supplicant_args -B -c$wpa_supplicant_conf $wpa_supplicant_if"
      9 name="WPA Supplicant Daemon"
     10 
     11 depend()
     12 {
     13 	need localmount
     14 	use logger
     15 	after bootmisc modules
     16 	before dns dhcpcd net
     17 	keyword -shutdown
     18 }
     19 
     20 find_wireless()
     21 {
     22 	local iface=
     23 
     24 	case "$RC_UNAME" in
     25 	Linux)
     26 		for iface in /sys/class/net/*; do
     27 			if [ -e "$iface"/wireless -o \
     28 				-e "$iface"/phy80211 ]
     29 			then
     30 				echo "${iface##*/}"
     31 				return 0
     32 			fi
     33 		done
     34 		;;
     35 	*)
     36 		for iface in /dev/net/* $(ifconfig -l 2>/dev/null); do
     37 			if ifconfig "${iface##*/}" 2>/dev/null | \
     38 				grep -q "[ ]*ssid "
     39 			then
     40 				echo "${iface##*/}"
     41 				return 0
     42 			fi
     43 		done
     44 		;;
     45 	esac
     46 	
     47 	return 1
     48 }
     49 
     50 append_wireless()
     51 {
     52 	local iface= i=
     53 
     54 	iface=$(find_wireless)
     55 	if [ -n "$iface" ]; then
     56 		for i in $iface; do
     57 			command_args="$command_args -i$i"
     58 		done
     59 	else
     60 		eerror "Could not find a wireless interface"
     61 	fi
     62 }
     63 
     64 start_pre()
     65 {
     66 	case " $command_args" in
     67 	*" -i"*) ;;
     68 	*) append_wireless;;
     69 	esac
     70 }