2013-03-02 04:39:54 -05:00
#!/bin/sh
2013-10-15 10:07:35 -04:00
if pidof wpa_supplicant hostapd valgrind.bin hlr_auc_gw > /dev/null; then
2013-08-26 09:38:13 -04:00
RUNNING = yes
else
RUNNING = no
fi
2013-03-02 04:39:54 -05:00
sudo killall -q hostapd
sudo killall -q wpa_supplicant
2013-08-26 04:28:32 -04:00
for i in ` pidof valgrind.bin` ; do
if ps $i | grep -q -E "wpa_supplicant|hostapd" ; then
sudo kill $i
fi
done
2013-03-09 10:39:11 -05:00
sudo killall -q wlantest
if grep -q hwsim0 /proc/net/dev; then
sudo ifconfig hwsim0 down
fi
2013-08-26 09:38:13 -04:00
2014-02-15 08:57:21 -05:00
sudo killall -q hlr_auc_gw
2013-09-29 12:14:16 -04:00
2013-08-26 09:38:13 -04:00
if [ " $RUNNING " = "yes" ] ; then
# give some time for hostapd and wpa_supplicant to complete deinit
2014-12-22 12:37:08 -05:00
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
if ! pidof wpa_supplicant hostapd valgrind.bin hlr_auc_gw > /dev/null; then
break
fi
if [ $i -gt 10 ] ; then
2013-09-28 03:54:10 -04:00
echo "Waiting for processes to exit (1)"
sleep 1
else
2014-12-22 12:37:08 -05:00
sleep 0.06
2013-09-28 03:54:10 -04:00
fi
done
2013-08-26 09:38:13 -04:00
fi
2013-10-15 10:07:35 -04:00
if pidof wpa_supplicant hostapd hlr_auc_gw > /dev/null; then
echo "wpa_supplicant/hostapd/hlr_auc_gw did not exit - try to force them to die"
2013-08-26 09:38:13 -04:00
sudo killall -9 -q hostapd
sudo killall -9 -q wpa_supplicant
2014-02-15 08:57:21 -05:00
sudo killall -9 -q hlr_auc_gw
2013-09-28 03:54:10 -04:00
for i in ` seq 1 5` ; do
2013-10-15 10:07:35 -04:00
if pidof wpa_supplicant hostapd hlr_auc_gw > /dev/null; then
2013-09-28 03:54:10 -04:00
echo "Waiting for processes to exit (2)"
sleep 1
else
break
fi
done
2013-08-26 09:38:13 -04:00
fi
for i in ` pidof valgrind.bin` ; do
if ps $i | grep -q -E "wpa_supplicant|hostapd" ; then
echo "wpa_supplicant/hostapd(valgrind) did not exit - try to force it to die"
sudo kill -9 $i
fi
done
2013-12-30 16:08:25 -05:00
count = 0
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
count = $(( $count + 1 ))
if [ $count -lt 7 -a -e $i ] ; then
2013-09-28 03:54:10 -04:00
echo " Waiting for ctrl_iface $i to disappear "
2013-08-27 09:02:15 -04:00
sleep 1
2013-12-30 16:08:25 -05:00
fi
if [ -e $i ] ; then
echo " Control interface file $i exists - remove it "
sudo rm $i
2013-08-27 09:02:15 -04:00
fi
done
2013-10-30 18:14:55 -04:00
if grep -q mac80211_hwsim /proc/modules 2>/dev/null ; then
2013-11-02 09:40:36 -04:00
sudo rmmod mac80211_hwsim
2013-10-26 17:08:51 -04:00
sudo rmmod mac80211
sudo rmmod cfg80211
2013-08-26 09:38:13 -04:00
# wait at the end to avoid issues starting something new immediately after
# this script returns
sleep 1
2013-03-02 04:39:54 -05:00
fi