stop-wifi.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. if pidof wpa_supplicant hostapd valgrind.bin > /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. if [ "$RUNNING" = "yes" ]; then
  20. # give some time for hostapd and wpa_supplicant to complete deinit
  21. sleep 4
  22. fi
  23. if pidof wpa_supplicant hostapd > /dev/null; then
  24. echo "wpa_supplicant/hostapd did not exit - try to force them to die"
  25. sudo killall -9 -q hostapd
  26. sudo killall -9 -q wpa_supplicant
  27. sleep 5
  28. fi
  29. for i in `pidof valgrind.bin`; do
  30. if ps $i | grep -q -E "wpa_supplicant|hostapd"; then
  31. echo "wpa_supplicant/hostapd(valgrind) did not exit - try to force it to die"
  32. sudo kill -9 $i
  33. fi
  34. done
  35. for i in /tmp/wpas-wlan0 /tmp/wpas-wlan1 /tmp/wpas-wlan2 /var/run/hostapd-global; do
  36. if [ -e $i ]; then
  37. sleep 1
  38. if [ -e $i ]; then
  39. echo "Control interface file $i exists - remove it"
  40. sudo rm $i
  41. fi
  42. fi
  43. done
  44. if grep -q mac80211_hwsim /proc/modules ; then
  45. sudo rmmod mac80211_hwsim
  46. # wait at the end to avoid issues starting something new immediately after
  47. # this script returns
  48. sleep 1
  49. fi