I use my RPI as wifi repeater using hostapd and dnsmasq.
Since I'm using hostapd_cli to disconnect the pi from the internet if the repeater is not in use, I often can’t connect to my access point and I have to restart hostapd or dnsmasq.
How is it possible that hostapd_cli makes my access point inaccessible?
I start hostapd_cli by using rc.local:
hostapd_cli -a /home/pi/autoConnectWLAN.sh &
The script contains:
#!/bin/bash
if sudo hostapd_cli all_sta | grep -q "ASSOC" && ! ip link show wlan1 | grep -q "UP"; then
sudo ip link set wlan1 up
if ! pgrep -x "wpa_supplicant"; then
sudo wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-wlan1.conf -Dnl80211,wext -iwlan1 -B
fi
elif ! sudo hostapd_cli all_sta | grep -q "ASSOC" && ip link show wlan1 | grep -q "UP"; then
sudo ip link set wlan1 down
fi