1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

ubuntu hook for channel change

This commit is contained in:
Jerry Vonau 2020-05-04 11:09:31 -05:00
parent 7ca4664473
commit 050722f3a0
3 changed files with 27 additions and 2 deletions

View file

@ -119,7 +119,7 @@
with_items:
- { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/carrier.d/iiab-wifi' }
- { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/no-carrier.d/iiab-wifi' }
- { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi' }
- { src: 'hostapd/netd-disp2', dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi2' }
when: systemd_networkd_active and discovered_wireless_iface != "none" and wifi_up_down
- name: Remove networkd-dispatcher hook wifi_up_down False
@ -130,6 +130,7 @@
- { dest: '/etc/networkd-dispatcher/carrier.d/iiab-wifi' }
- { dest: '/etc/networkd-dispatcher/no-carrier.d/iiab-wifi' }
- { dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi' }
- { dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi2' }
when: systemd_networkd_active and discovered_wireless_iface != "none" and not wifi_up_down
- name: Enable the Access Point 'hostapd' service

View file

@ -1,5 +1,4 @@
#!/bin/bash
if [ "$IFACE" == "{{ discovered_wireless_iface }}" ]; then
echo "NET-DISP-WiFi $IFACE $STATE"
/usr/sbin/ip link set ap0 up

View file

@ -0,0 +1,25 @@
#!/bin/bash
if [ "$IFACE" == "{{ discovered_wireless_iface }}" ]; then
echo "NET-DISP-WiFi $IFACE $STATE"
FREQ=`wpa_cli -i $IFACE scan_results | grep $SSID | awk '{print $2}'`
for result in $FREQ; do
echo "frequency is $result for $SSID"
if [ $result -lt 2485 ]; then
FREQ2=$result
fi
done
echo "Using $FREQ2 for $SSID"
CHAN=$(($FREQ2 - 2407 ))
CHAN=$(($CHAN / 5 ))
HOSTAPD=`grep channel /etc/hostapd/hostapd.conf | awk -F = '{print $2}'`
echo "Hostapd set for $HOSTAPD"
if [ $CHAN -ne $HOSTAPD ]; then
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