stop-wifi.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. if pidof wpa_supplicant hostapd valgrind.bin hlr_auc_gw > /dev/null; then
  3. RUNNING=yes
  4. else
  5. RUNNING=no
  6. fi
  7. sudo killall -q hostapd
  8. sudo killall -q wpa_supplicant
  9. for i in `pidof valgrind.bin`; do
  10. if ps $i | grep -q -E "wpa_supplicant|hostapd"; then
  11. sudo kill $i
  12. fi
  13. done
  14. sudo killall -q wlantest
  15. sudo killall -q tcpdump
  16. if grep -q hwsim0 /proc/net/dev; then
  17. sudo ifconfig hwsim0 down
  18. fi
  19. killall -q hlr_auc_gw
  20. if [ "$RUNNING" = "yes" ]; then
  21. # give some time for hostapd and wpa_supplicant to complete deinit
  22. sleep 0.5
  23. for i in `seq 1 5`; do
  24. if pidof wpa_supplicant hostapd valgrind.bin hlr_auc_gw > /dev/null; then
  25. echo "Waiting for processes to exit (1)"
  26. sleep 1
  27. else
  28. break
  29. fi
  30. done
  31. fi
  32. if pidof wpa_supplicant hostapd hlr_auc_gw > /dev/null; then
  33. echo "wpa_supplicant/hostapd/hlr_auc_gw did not exit - try to force them to die"
  34. sudo killall -9 -q hostapd
  35. sudo killall -9 -q wpa_supplicant
  36. killall -9 -q hlr_auc_gw
  37. for i in `seq 1 5`; do
  38. if pidof wpa_supplicant hostapd hlr_auc_gw > /dev/null; then
  39. echo "Waiting for processes to exit (2)"
  40. sleep 1
  41. else
  42. break
  43. fi
  44. done
  45. fi
  46. for i in `pidof valgrind.bin`; do
  47. if ps $i | grep -q -E "wpa_supplicant|hostapd"; then
  48. echo "wpa_supplicant/hostapd(valgrind) did not exit - try to force it to die"
  49. sudo kill -9 $i
  50. fi
  51. done
  52. for i in /tmp/wpas-wlan0 /tmp/wpas-wlan1 /tmp/wpas-wlan2 /var/run/hostapd-global /tmp/hlr_auc_gw.sock /tmp/wpa_ctrl_* /tmp/eap_sim_db_*; do
  53. if [ -e $i ]; then
  54. echo "Waiting for ctrl_iface $i to disappear"
  55. sleep 1
  56. if [ -e $i ]; then
  57. echo "Control interface file $i exists - remove it"
  58. sudo rm $i
  59. fi
  60. fi
  61. done
  62. if grep -q mac80211_hwsim /proc/modules 2>/dev/null ; then
  63. sudo rmmod mac80211_hwsim
  64. sudo rmmod mac80211
  65. sudo rmmod cfg80211
  66. # wait at the end to avoid issues starting something new immediately after
  67. # this script returns
  68. sleep 1
  69. fi