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