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

Merge pull request #511 from jvonau/reg_dom3

Reg dom3
This commit is contained in:
A Holt 2023-04-24 14:14:50 -04:00 committed by GitHub
commit 553626d123
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 21 deletions

View file

@ -18,6 +18,7 @@ SSID=""
# when we get here br0 should be available and dbus wpa_supplicant was started if enabled. Some # when we get here br0 should be available and dbus wpa_supplicant was started if enabled. Some
# of the backends that use wpa_supplicant should be active based on the Before= After= lines in # of the backends that use wpa_supplicant should be active based on the Before= After= lines in
# the iiab-wifi-test.service unit file. # the iiab-wifi-test.service unit file.
# https://github.com/iiab/iiab/pull/3542#issuecomment-1519647266
echo "iiab-test-wifi called" echo "iiab-test-wifi called"
echo "running pid $$" echo "running pid $$"
@ -44,6 +45,7 @@ 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/\"//) SSID=$(grep ssid /run/netplan/wpa-$IFACE.conf | awk -F = '{print $2}' | sed -r s/\"// | sed -r s/\"//)
REG_DOM=$(grep country /run/netplan/wpa-$IFACE.conf | awk -F = '{ print $2 }') REG_DOM=$(grep country /run/netplan/wpa-$IFACE.conf | awk -F = '{ print $2 }')
if [ -z "$REG_DOM" ]; then if [ -z "$REG_DOM" ]; then
NETPLAN=2
echo "cover netplan wifi client lack of country= setting to {{ host_country_code }}" echo "cover netplan wifi client lack of country= setting to {{ host_country_code }}"
sed -i "s|ctrl_interface=/run/wpa_supplicant|&\ncountry={{ host_country_code }}|" /run/netplan/wpa-$IFACE.conf sed -i "s|ctrl_interface=/run/wpa_supplicant|&\ncountry={{ host_country_code }}|" /run/netplan/wpa-$IFACE.conf
else else
@ -65,11 +67,32 @@ echo "ssid is $SSID"
if [ -z "$SSID" ]; then if [ -z "$SSID" ]; then
echo "Couldn't find ssid $SSID to use exiting" echo "Couldn't find ssid $SSID to use exiting"
if [ $NETPLAN -eq 1 ]; then if [ $NETPLAN -gt 0 ]; then
echo "Netplan1" echo "Netplan1"
fi fi
exit 0 exit 0
fi fi
if [ $NETPLAN -gt 0 ]; then
echo "Netplan2 sleep 10"
sleep 10
wifi_processes=$(ps -A | grep wpa_supplicant | wc -l)
if [ $wifi_processes -eq 1 ]; then
# This is more of a netplan workaround should go away.
echo "Problem - Now Starting netplan wifi"
NETPLAN=2
else
echo "Not Restarting netplan wifi sleep 20"
sleep 20
fi
# This one handles the changing of the country code from above
if [ $NETPLAN -eq 2 ]; then
echo "Restarting netplan-wpa-$IFACE sleep 20"
/bin/systemctl --no-block restart netplan-wpa-$IFACE.service
sleep 20
fi
fi
sleep 10
wpa_cli -i $IFACE scan > /dev/null wpa_cli -i $IFACE scan > /dev/null
sleep 2 sleep 2
FREQ=$(wpa_cli -i $IFACE scan_results | grep "$SSID" | awk '{print $2}') FREQ=$(wpa_cli -i $IFACE scan_results | grep "$SSID" | awk '{print $2}')
@ -85,21 +108,14 @@ done
echo "Using $FREQ2 for $SSID" echo "Using $FREQ2 for $SSID"
if [ $NETPLAN -eq 1 ]; then
echo "Netplan2"
# This is more of a netplan workaround should go away.
/bin/systemctl restart netplan-wpa-$IFACE.service
fi
if [ -z "$FREQ2" ]; then if [ -z "$FREQ2" ]; then
echo "Couldn't find frequency to use exiting" echo "Couldn't find frequency to use exiting"
if [ $NETPLAN -eq 1 ]; then if [ $NETPLAN -gt 0 ]; then
echo "Netplan3" echo "Netplan3"
fi fi
exit 0 exit 0
fi fi
# ubuntu on boot exits at this point timing - issue with wpa_cli and scanning
CHAN=$((FREQ2 - 2407)) CHAN=$((FREQ2 - 2407))
CHAN=$((CHAN / 5)) CHAN=$((CHAN / 5))
echo "channel is $CHAN for $SSID" echo "channel is $CHAN for $SSID"

View file

@ -1,5 +1,8 @@
[Unit] [Unit]
Description=IIAB find channel freq for ssid Description=IIAB find channel freq for ssid
Requisite=sys-subsystem-net-devices-wlan0.device
Requisite=iiab-clone-wifi.service
Requisite=wpa_supplicant.service
# 2023-04-24 PR #3549: c49adcf went too far and broke netplan-systemd # 2023-04-24 PR #3549: c49adcf went too far and broke netplan-systemd
#Requires=network-pre.target #Requires=network-pre.target
@ -7,17 +10,18 @@ Description=IIAB find channel freq for ssid
#After=sys-subsystem-net-devices-{{ discovered_wireless_iface }}.device #After=sys-subsystem-net-devices-{{ discovered_wireless_iface }}.device
#After=iiab-clone-wifi.service #After=iiab-clone-wifi.service
After=network-pre.target #After=network-pre.target
After=wpa_supplicant.service #After=wpa_supplicant.service
Wants=wpa_supplicant.service #Wants=wpa_supplicant.service
After=NetworkManager.service After=NetworkManager.service
After=netplan-wpa-{{ discovered_wireless_iface }}.service After=netplan-wpa-{{ discovered_wireless_iface }}.service
Before=hostapd.service
Before=dhcpcd.service Before=dhcpcd.service
Before=wpa_supplicant@{{ discovered_wireless_iface }}.service Before=wpa_supplicant@{{ discovered_wireless_iface }}.service
#Before=network.target #Before=network.target
[Service] [Service]
TimeoutStartSec=120
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecStart=/usr/sbin/iiab-test-wifi ExecStart=/usr/sbin/iiab-test-wifi

View file

@ -2,20 +2,15 @@
if [ "$IFACE" == "{{ discovered_wireless_iface }}" ]; then if [ "$IFACE" == "{{ discovered_wireless_iface }}" ]; then
echo "NET-DISP-WiFi $IFACE $STATE" echo "NET-DISP-WiFi $IFACE $STATE"
# If we are here we have a dhcp ip address # If we are here we have a dhcp ip address
CHAN=`iw $IFACE info|grep channel|cut -d' ' -f2` CHAN=$(iw "$IFACE" info|grep channel|cut -d' ' -f2)
echo "Using channel $CHAN for carrier" echo "Using channel $CHAN for carrier"
HOSTAPD=`grep channel /etc/hostapd/hostapd.conf | awk -F = '{print $2}'` HOSTAPD=$(grep channel /etc/hostapd/hostapd.conf | awk -F = '{print $2}')
echo "Hostapd set for $HOSTAPD" echo "Hostapd set for $HOSTAPD"
if [ $CHAN -ne $HOSTAPD ] && [ $CHAN -lt 14 ]; then if [ $CHAN -ne $HOSTAPD ] && [ $CHAN -lt 14 ]; then
echo "Editing Hostapd for channel $CHAN" echo "Editing Hostapd for channel $CHAN"
cp /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf cp /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf
sed -i -e "s/^channel.*/channel=$CHAN/" /etc/hostapd/hostapd.conf sed -i "s/^channel.*/channel=$CHAN/" /etc/hostapd/hostapd.conf
systemctl stop wpa_supplicant
systemctl restart hostapd systemctl restart hostapd
systemctl start wpa_supplicant
if [ -f /run/netplan/wpa-$IFACE.conf ]; then
systemctl restart netplan-wpa-$IFACE.service
fi
else else
echo "Upstream Channel greater than 13 or is the same - not changing hostapd.conf" echo "Upstream Channel greater than 13 or is the same - not changing hostapd.conf"
fi fi