stop.sh 2.0 KB

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