support launching hostapd inside an interface block
As mentioned during the discussion at #498, support for launching hostapd inside an interface block would be desirable.
The syntax could be as follow:
interface wlp3s1
hostapd /etc/hostapd/wlp3s1.conf
static ip_address=192.168.1.1/24
What dhcpcd would send out as a command line:
hostapd -B -P /run/hostapd.wlp3s1.pid /etc/hostapd/wlp3s1.conf
This would get us one step closer to deprecating ifupdown.
Why can't the OS's RC system do this?
On NetBSD I would do this in /etc/rc.conf
# Start hostapd on the wlp3s1 interface
hostapd_flags="wlp3s1"
hostaps=YES
Anyway, right now you can do this in /etc/dhcpcd.enter-hook
if [ "$interface" = wlp3s1 ]; then
case "$reason" in
PREINIT) hostapd -B -P /run/hostapd.wlp3s1.pid /etc/hostapd/wlp3s1.conf;;
STOP|STOP6) if [ -s /run/hostapd.wlp3s1.pid ]; then
kill $(cat /run/hostapd.wlp3s1.pid)
rm /run/hostapd.wlp3s1.pid
fi;;
esac
fi
But IMHO this is a bad idea as is trying to mange a VPN from dhcpcd as well. It's just the wrong place for this.
Because if one needs to be able to launch several wireless devices as AP, each with its separate config, one won't go hacking DIY scripts.
You know hostapd supports many config files and thus many interfaces in one process right? Just like dhcpcd in manager mode.