1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/network/templates/hostapd/test-wifi
2020-05-07 12:03:51 -05:00

25 lines
868 B
Text
Executable file

IFACE={{ discovered_wireless_iface }}
SSID=""
if [ -f /run/netplan/wpa-$IFACE.conf ]; then
SSID=`grep ssid /run/netplan/wpa-$IFACE.conf | awk -F = '{print $2}' | sed -r s/\"// | sed -r s/\">
fi
if [ -f /etc/wpa_supplicant/wpa_supplicant.conf ]; then
SSID=`grep ssid /etc/wpa_supplicant/wpa_supplicant.conf | awk -F = '{print $2}' | sed -r s/\"// | >
fi
if [ -f /etc/iiab/iiab.env ]; then
source /etc/iiab/iiab.env
if [ ! -z $CLIENT_SSID ]; then
SSID=$CLIENT_SSID
fi
fi
sleep 3
wpa_cli -i wlan0 scan > /dev/null
sleep 2
FREQ=`wpa_cli -i wlan0 scan_results | grep $SSID | awk '{print $2}'`
echo "frequency is $FREQ for $SSID"
CHAN=$(((($FREQ - 2407)) / 5 ))
echo "channel is $CHAN for $SSID"
cp /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf
sed -i -e "s/^channel.*/channel=$CHAN/" /etc/hostapd/hostapd.conf
systemctl reload-daemon