#!/bin/bash
sed -i -e "s/^denyinterfaces/#denyinterfaces/" /etc/dhcpcd.conf
systemctl disable hostapd
systemctl stop hostapd
systemctl disable dhcpd
systemctl stop dhcpd
systemctl daemon-reload
systemctl restart dhcpcd
systemctl restart networking

# Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease"
# Set wlan0 to promiscuous when AP's OFF (for possible WiFi gateway)
# SEE ALSO iiab-hotspot-on + /usr/libexec/iiab-startup.sh
# https://github.com/iiab/iiab/issues/638#issuecomment-355455454
if grep -qi raspbian /etc/*release; then
    ip link set dev wlan0 promisc on
fi

sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }}
