/rc0.d/S15wpa-ifupdown

http://github.com/brinkman83/bashrc · Shell · 88 lines · 54 code · 11 blank · 23 comment · 9 complexity · 87ca34ea160f4d1bd9adb18999668c35 MD5 · raw file

  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: wpa-ifupdown
  4. # Required-Start: $network
  5. # Required-Stop: $network $remote_fs
  6. # Should-Start:
  7. # Should-Stop:
  8. # Default-Start:
  9. # Default-Stop: 0 6
  10. # Short-Description: Stop wpa_supplicant processes started via ifupdown
  11. # Description: Run ifdown on interfaces authenticated via
  12. # wpa_supplicant. Sendsigs terminates wpa_supplicant
  13. # processes before networking is stopped causing each
  14. # network interface authenticated via a wpa_supplicant
  15. # daemon to be terminated abrubtly.
  16. # Since initscripts package version 2.86.ds1-48 an
  17. # interface exists to omit process id's from sendsigs. If
  18. # this interface is present this script is a no-op.
  19. ### END INIT INFO
  20. PATH=/usr/sbin:/usr/bin:/sbin:/bin
  21. test -d /var/run || exit 0
  22. test -x /sbin/ifdown || exit 0
  23. . /lib/lsb/init-functions
  24. stop_wpa_action () {
  25. test -x /sbin/wpa_action || return 0
  26. IFACES=$(find /var/run -maxdepth 1 -type f -name 'wpa_action.*.pid' -printf '%P\n' | \
  27. cut -d'.' -f2 2>/dev/null)
  28. if test -n "$IFACES"; then
  29. log_daemon_msg "Stopping wpa_action roaming interfaces"
  30. for iface in $IFACES; do
  31. log_progress_msg "$iface"
  32. # wpa_action executes /sbin/ifdown
  33. wpa_action "$iface" stop >/dev/null 2>&1
  34. done
  35. log_end_msg 0
  36. fi
  37. }
  38. stop_wpa_supplicant () {
  39. IFACES=$(find /var/run -maxdepth 1 -type f -name 'wpa_supplicant.*.pid' -printf '%P\n' | \
  40. grep -v wpa_supplicant.dbus.pid | cut -d'.' -f2 2>/dev/null)
  41. if test -n "$IFACES"; then
  42. log_daemon_msg "Stopping wpa_supplicant interfaces"
  43. for iface in $IFACES; do
  44. log_progress_msg "$iface"
  45. ifdown "$iface" >/dev/null 2>&1
  46. done
  47. log_end_msg 0
  48. fi
  49. }
  50. sendsigs_omission_support () {
  51. if [ -d /lib/init/rw/sendsigs.omit.d/ ]; then
  52. # Debian
  53. return 0
  54. elif [ -d /var/run/sendsigs.omit.d/ ]; then
  55. # Ubuntu, cf. https://bugs.launchpad.net/bugs/181541
  56. return 0
  57. fi
  58. return 1
  59. }
  60. case "$1" in
  61. start|restart|force-reload)
  62. # No-op
  63. ;;
  64. stop)
  65. if sendsigs_omission_support; then
  66. stop_wpa_action
  67. else
  68. stop_wpa_action
  69. stop_wpa_supplicant
  70. fi
  71. ;;
  72. *)
  73. echo "Usage: $0 {start|stop|restart|force-reload}" >&2
  74. exit 3
  75. ;;
  76. esac
  77. exit 0