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

29 lines
1 KiB
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-05 01:28:37 +00:00
FREQ=`wpa_cli -i $IFACE scan_results | grep : | awk '{print $2}'`
2020-05-04 16:09:31 +00:00
for result in $FREQ; do
2020-05-05 01:28:37 +00:00
echo "frequency is $result for carrier"
if [ $result -lt 2485 ] && [ ! -z $result ]; then
2020-05-04 16:09:31 +00:00
FREQ2=$result
2020-05-05 01:28:37 +00:00
else
FREQ2="NA"
2020-05-04 16:09:31 +00:00
fi
done
2020-05-05 01:28:37 +00:00
echo "Using $FREQ2 for carrier"
2020-05-04 16:09:31 +00:00
CHAN=$(($FREQ2 - 2407 ))
CHAN=$(($CHAN / 5 ))
2020-05-05 01:28:37 +00:00
echo "Using channel $CHAN for carrier"
2020-05-04 16:09:31 +00:00
HOSTAPD=`grep channel /etc/hostapd/hostapd.conf | awk -F = '{print $2}'`
echo "Hostapd set for $HOSTAPD"
2020-05-05 01:28:37 +00:00
if [ $CHAN -ne $HOSTAPD ] && [[ ! $FREQ2 == "NA" ]]; 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
sed -i -e "s/^channel.*/channel=$CHAN/" /etc/hostapd/hostapd.conf
systemctl stop wpa_supplicant
systemctl restart hostapd
systemctl start wpa_supplicant
fi
/usr/sbin/ip link set ap0 up
fi