wpa-supplicant 1.9 KB

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