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
nohook wpa_supplicantfor both devices todhcpcd.conf. And I addeduntil pidof hostapd; do sleep 0.5; donebefore I starthostapd_cli... – jake Dec 08 '18 at 15:24SysVinit system because of this discussion. I have decided to use systemd. I believe its the mainstream. – Ingo Dec 08 '18 at 17:03sudo systemctl [start|stop] hostapd.service. Because you refer to wlan1 I guess you are using two wifi devices (one usb/wifi dongle?). Then you can look at RPI3 Raspbian Stretch regular connection on wlan0 AP on wlan1. – Ingo Dec 08 '18 at 17:18systemdon a fresh install. – jake Dec 08 '18 at 18:09/etc/systemd/network/00-default.link? – jake Dec 08 '18 at 21:41hostapdbysystemd. Just create a unit file or do I have to disable the old init.d service before? – jake Dec 27 '18 at 18:05systemctl status|start|stop|restart|cat hostapdand others like any other service. – Ingo Dec 27 '18 at 21:17/lib/systemd/systemor/etc/systemd/systembut there is one in/init.d. Just trying to get used to systemd :). – jake Dec 27 '18 at 21:57/run/systemd/generator.late/hostapd.serviceso it's an emulated service and I thought it might be better to use a »real« one... – jake Dec 27 '18 at 21:59systemctl cat hostapd. But the Debian maintainer Kel Modderman for this package seems not to be willing to go with the time. He has nothing done since 2005 for managing hostapd process(es). Look atcat /usr/share/doc/hostapd/README.Debian. – Ingo Dec 27 '18 at 22:23/etc/init.d/hostapdit seems you only need start and reload. Others is managed automatically by systemd. An issue would be the dependencies shown in the INIT INFO. – Ingo Dec 28 '18 at 00:45