mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
commit
553626d123
3 changed files with 36 additions and 21 deletions
|
@ -18,6 +18,7 @@ SSID=""
|
|||
# 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
|
||||
# the iiab-wifi-test.service unit file.
|
||||
# https://github.com/iiab/iiab/pull/3542#issuecomment-1519647266
|
||||
|
||||
echo "iiab-test-wifi called"
|
||||
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/\"//)
|
||||
REG_DOM=$(grep country /run/netplan/wpa-$IFACE.conf | awk -F = '{ print $2 }')
|
||||
if [ -z "$REG_DOM" ]; then
|
||||
NETPLAN=2
|
||||
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
|
||||
else
|
||||
|
@ -65,11 +67,32 @@ echo "ssid is $SSID"
|
|||
|
||||
if [ -z "$SSID" ]; then
|
||||
echo "Couldn't find ssid $SSID to use exiting"
|
||||
if [ $NETPLAN -eq 1 ]; then
|
||||
if [ $NETPLAN -gt 0 ]; then
|
||||
echo "Netplan1"
|
||||
fi
|
||||
exit 0
|
||||
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
|
||||
sleep 2
|
||||
FREQ=$(wpa_cli -i $IFACE scan_results | grep "$SSID" | awk '{print $2}')
|
||||
|
@ -85,21 +108,14 @@ done
|
|||
|
||||
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
|
||||
echo "Couldn't find frequency to use exiting"
|
||||
if [ $NETPLAN -eq 1 ]; then
|
||||
if [ $NETPLAN -gt 0 ]; then
|
||||
echo "Netplan3"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ubuntu on boot exits at this point timing - issue with wpa_cli and scanning
|
||||
CHAN=$((FREQ2 - 2407))
|
||||
CHAN=$((CHAN / 5))
|
||||
echo "channel is $CHAN for $SSID"
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
[Unit]
|
||||
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
|
||||
#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=iiab-clone-wifi.service
|
||||
|
||||
After=network-pre.target
|
||||
After=wpa_supplicant.service
|
||||
Wants=wpa_supplicant.service
|
||||
#After=network-pre.target
|
||||
#After=wpa_supplicant.service
|
||||
#Wants=wpa_supplicant.service
|
||||
|
||||
After=NetworkManager.service
|
||||
After=netplan-wpa-{{ discovered_wireless_iface }}.service
|
||||
Before=hostapd.service
|
||||
Before=dhcpcd.service
|
||||
Before=wpa_supplicant@{{ discovered_wireless_iface }}.service
|
||||
#Before=network.target
|
||||
|
||||
[Service]
|
||||
TimeoutStartSec=120
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/sbin/iiab-test-wifi
|
||||
|
|
|
@ -2,20 +2,15 @@
|
|||
if [ "$IFACE" == "{{ discovered_wireless_iface }}" ]; then
|
||||
echo "NET-DISP-WiFi $IFACE $STATE"
|
||||
# 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"
|
||||
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"
|
||||
if [ $CHAN -ne $HOSTAPD ] && [ $CHAN -lt 14 ]; 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
|
||||
sed -i "s/^channel.*/channel=$CHAN/" /etc/hostapd/hostapd.conf
|
||||
systemctl restart hostapd
|
||||
systemctl start wpa_supplicant
|
||||
if [ -f /run/netplan/wpa-$IFACE.conf ]; then
|
||||
systemctl restart netplan-wpa-$IFACE.service
|
||||
fi
|
||||
else
|
||||
echo "Upstream Channel greater than 13 or is the same - not changing hostapd.conf"
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue