stop.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. sudo 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. sudo 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. count=0
  53. for i in /tmp/wpas-wlan0 /tmp/wpas-wlan1 /tmp/wpas-wlan2 /tmp/wpas-wlan5 /var/run/hostapd-global /tmp/hlr_auc_gw.sock /tmp/wpa_ctrl_* /tmp/eap_sim_db_*; do
  54. count=$(($count + 1))
  55. if [ $count -lt 7 -a -e $i ]; then
  56. echo "Waiting for ctrl_iface $i to disappear"
  57. sleep 1
  58. fi
  59. if [ -e $i ]; then
  60. echo "Control interface file $i exists - remove it"
  61. sudo rm $i
  62. fi
  63. done
  64. if grep -q mac80211_hwsim /proc/modules 2>/dev/null ; then
  65. sudo rmmod mac80211_hwsim
  66. sudo rmmod mac80211
  67. sudo rmmod cfg80211
  68. # wait at the end to avoid issues starting something new immediately after
  69. # this script returns
  70. sleep 1
  71. fi