ifupdown.sh 1005 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. # This file is executed by ifupdown in pre-up, post-up, pre-down and
  3. # post-down phases of network interface configuration.
  4. WPA_SUP_BIN="/usr/sbin/wpa_supplicant"
  5. # run this script only for interfaces which have wpa-conf option
  6. [ -z "$IF_WPA_CONF" ] && exit 0
  7. # Allow wpa_supplicant interface to be specified via wpa-iface
  8. # useful for starting wpa_supplicant on one interface of a bridge
  9. if [ -n "$IF_WPA_IFACE" ]; then
  10. WPA_IFACE="$IF_WPA_IFACE"
  11. else
  12. WPA_IFACE="$IFACE"
  13. fi
  14. WPA_SUP_PIDFILE="/run/wpa_supplicant.${WPA_IFACE}.pid"
  15. do_start () {
  16. if [ ! -s "$IF_WPA_CONF" ]; then
  17. echo "cannot read contents of $IF_WPA_CONF"
  18. exit 1
  19. fi
  20. WPA_SUP_CONF="-c $IF_WPA_CONF"
  21. }
  22. case "$MODE" in
  23. start)
  24. do_start
  25. case "$PHASE" in
  26. post-up)
  27. start-stop-daemon -S -q -x ${WPA_SUP_BIN} \
  28. -- -B -i ${WPA_IFACE} ${WPA_SUP_CONF} -P ${WPA_SUP_PIDFILE}
  29. ;;
  30. esac
  31. ;;
  32. stop)
  33. case "$PHASE" in
  34. pre-down)
  35. start-stop-daemon -K -p ${WPA_SUP_PIDFILE}
  36. ;;
  37. esac
  38. ;;
  39. esac
  40. exit 0