1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00
iiab/roles/network/templates/hostapd/netd-disp2

20 lines
803 B
Text
Raw Normal View History

2020-05-04 16:09:31 +00:00
#!/bin/bash
if [ "$IFACE" == "{{ discovered_wireless_iface }}" ]; then
echo "NET-DISP-WiFi $IFACE $STATE"
2020-05-06 12:58:24 +00:00
# If we are here we have a dhcp ip address
2023-04-24 17:42:16 +00:00
CHAN=$(iw "$IFACE" info|grep channel|cut -d' ' -f2)
2020-05-05 01:28:37 +00:00
echo "Using channel $CHAN for carrier"
2023-04-24 17:42:16 +00:00
HOSTAPD=$(grep channel /etc/hostapd/hostapd.conf | awk -F = '{print $2}')
2020-05-04 16:09:31 +00:00
echo "Hostapd set for $HOSTAPD"
2020-05-06 12:58:24 +00:00
if [ $CHAN -ne $HOSTAPD ] && [ $CHAN -lt 14 ]; then
2020-05-04 16:09:31 +00:00
echo "Editing Hostapd for channel $CHAN"
cp /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf
2023-04-24 17:42:16 +00:00
sed -i "s/^channel.*/channel=$CHAN/" /etc/hostapd/hostapd.conf
2020-05-04 16:09:31 +00:00
systemctl restart hostapd
2020-05-06 12:58:24 +00:00
else
echo "Upstream Channel greater than 13 or is the same - not changing hostapd.conf"
2020-05-04 16:09:31 +00:00
fi
2020-05-06 12:58:24 +00:00
sleep 3
2020-05-04 16:09:31 +00:00
/usr/sbin/ip link set ap0 up
fi