wpa_supplicant.initd 1.2 KB

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