mirror of
https://github.com/iiab/iiab.git
synced 2025-02-12 19:22:24 +00:00
Merge pull request #3549 from holta/reg_dom2+iiab-hotspot-off_etc
Unified PR for WiFi hotspot testing of channel-changing, country code, etc
This commit is contained in:
commit
63b6724c4a
13 changed files with 167 additions and 128 deletions
|
@ -22,7 +22,7 @@
|
|||
dest: /etc/NetworkManager/conf.d/ap0-manage.conf
|
||||
src: network/ap0-manage.conf
|
||||
mode: 0644
|
||||
when: wifi_up_down
|
||||
when: discovered_wireless_iface != "none" and wifi_up_down
|
||||
|
||||
- name: Copy manage.conf for NetworkManager when wifi_up_down False
|
||||
template:
|
||||
|
|
|
@ -81,22 +81,3 @@
|
|||
value: "{{ dnsmasq_enabled }}"
|
||||
- option: no_net_restart
|
||||
value: "{{ no_net_restart }}"
|
||||
- option: hostapd_enabled
|
||||
value: "{{ hostapd_enabled }}"
|
||||
- option: host_ssid
|
||||
value: "{{ host_ssid }}"
|
||||
- option: host_wifi_mode
|
||||
value: "{{ host_wifi_mode }}"
|
||||
- option: host_channel
|
||||
value: "{{ host_channel }}"
|
||||
|
||||
- name: Add 'network' variable 'current_client_channel' value if defined, to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
dest: "{{ iiab_ini_file }}"
|
||||
section: network
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value | string }}"
|
||||
with_items:
|
||||
- option: client_wifi_channel
|
||||
value: "{{ current_client_channel.stdout }}"
|
||||
when: current_client_channel.stdout is defined
|
||||
|
|
|
@ -9,10 +9,21 @@
|
|||
enabled: no
|
||||
when: not hostapd_enabled
|
||||
|
||||
- name: Detect WiFi country code in use
|
||||
shell: iw reg get | grep country | grep -v UNSET | awk '{print $2}' | sed "s|:||"
|
||||
register: REG_DOM
|
||||
ignore_errors: True
|
||||
when: wifi_up_down and can_be_ap and has_wifi_gateway is defined
|
||||
|
||||
- name: Set Wifi Region country code for hostapd when present
|
||||
set_fact:
|
||||
host_country_code: "{{ REG_DOM.stdout }}"
|
||||
when: REG_DOM.stdout is defined and REG_DOM.stdout | length > 0
|
||||
|
||||
- name: Detect current Wifi channel
|
||||
shell: iw {{ discovered_wireless_iface }} info | grep channel | cut -d' ' -f2
|
||||
register: current_client_channel
|
||||
when: discovered_wireless_iface != "none"
|
||||
when: wifi_up_down and can_be_ap and has_wifi_gateway is defined
|
||||
|
||||
- name: Setting WiFi channel to {{ current_client_channel.stdout }}
|
||||
set_fact:
|
||||
|
@ -88,3 +99,32 @@
|
|||
regexp: '^HOSTAPD_ENABLED=*'
|
||||
line: 'HOSTAPD_ENABLED={{ hostapd_enabled }}'
|
||||
state: present
|
||||
|
||||
- name: Record host_country_code_applied and host_channel in network of {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
dest: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
|
||||
section: network
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value | string }}"
|
||||
with_items:
|
||||
- option: hostapd_enabled
|
||||
value: "{{ hostapd_enabled }}"
|
||||
- option: host_ssid
|
||||
value: "{{ host_ssid }}"
|
||||
- option: host_wifi_mode
|
||||
value: "{{ host_wifi_mode }}"
|
||||
- option: host_country_code_applied
|
||||
value: "{{ host_country_code }}"
|
||||
- option: host_channel
|
||||
value: "{{ host_channel }}"
|
||||
|
||||
- name: Add 'network' variable 'current_client_channel' value if defined, to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
dest: "{{ iiab_ini_file }}"
|
||||
section: network
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value | string }}"
|
||||
with_items:
|
||||
- option: client_wifi_channel
|
||||
value: "{{ current_client_channel.stdout }}"
|
||||
when: current_client_channel.stdout is defined
|
||||
|
|
|
@ -61,8 +61,6 @@
|
|||
# when: squid_install and FQDN_changed and iiab_stage|int == 9
|
||||
|
||||
#### Start services
|
||||
- name: hostapd
|
||||
include_tasks: hostapd.yml
|
||||
- name: computed_services
|
||||
include_tasks: computed_services.yml
|
||||
- name: enable_services
|
||||
|
@ -94,6 +92,9 @@
|
|||
#when: (not is_raspbian and not network_manager_active and not systemd_networkd_active and is_debuntu) or is_ubuntu_16
|
||||
#### end network layout
|
||||
|
||||
- name: hostapd
|
||||
include_tasks: hostapd.yml
|
||||
|
||||
- name: Restart services
|
||||
include_tasks: restart.yml
|
||||
|
||||
|
|
|
@ -14,16 +14,6 @@
|
|||
- wpa_supplicant
|
||||
when: wifi_up_down and hostapd_enabled
|
||||
|
||||
- name: Record host_country_code_applied in network of iiab_ini_file
|
||||
ini_file:
|
||||
dest: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
|
||||
section: network
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value | string }}"
|
||||
with_items:
|
||||
- option: host_country_code_applied
|
||||
value: "{{ host_country_code }}"
|
||||
|
||||
- name: Create /etc/hostapd/hostapd.conf and backup .iiab from template if needed
|
||||
template:
|
||||
owner: root
|
||||
|
|
|
@ -39,19 +39,21 @@
|
|||
shell: grep country /etc/wpa_supplicant/wpa_supplicant.conf | awk -F = '{print $2}'
|
||||
register: country_code
|
||||
ignore_errors: True
|
||||
when: wifi_up_down and can_be_ap
|
||||
|
||||
- name: Set country code for hostapd to value found in /etc/wpa_supplicant/wpa_supplicant.conf
|
||||
set_fact:
|
||||
host_country_code: "{{ country_code.stdout }}"
|
||||
when: country_code is defined and country_code.stdout | length > 0
|
||||
when: country_code.stdout is defined and country_code.stdout | length > 0
|
||||
|
||||
- name: Put country code ({{ host_country_code }}) in /etc/wpa_supplicant/wpa_supplicant.conf if nec
|
||||
lineinfile:
|
||||
path: /etc/wpa_supplicant/wpa_supplicant.conf
|
||||
regexp: "^country.*"
|
||||
line: country={{ host_country_code }}
|
||||
when: country_code is defined and country_code.stdout | length == 0
|
||||
when: country_code.stdout is defined and country_code.stdout | length == 0
|
||||
|
||||
# This should go away, should only be unblocked by raspi-config
|
||||
- name: Enable the WiFi with rfkill
|
||||
shell: rfkill unblock 0
|
||||
ignore_errors: True
|
||||
|
|
|
@ -87,17 +87,6 @@
|
|||
systemd:
|
||||
daemon_reload: yes
|
||||
|
||||
- name: Detect WiFi country code in use
|
||||
shell: iw reg get | grep country | grep -v UNSET | awk '{print $2}' | sed "s|:||"
|
||||
register: REG_DOM
|
||||
ignore_errors: True
|
||||
when: discovered_wireless_iface != "none"
|
||||
|
||||
- name: Set Wifi Region country code for hostapd when present
|
||||
set_fact:
|
||||
host_country_code: "{{ REG_DOM.stdout }}"
|
||||
when: REG_DOM is defined and REG_DOM.stdout | length > 0
|
||||
|
||||
- name: Clone wifi if needed
|
||||
systemd:
|
||||
name: iiab-clone-wifi
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
echo -e "Networking role disabled\n"
|
||||
echo -e "For details, see: https://github.com/iiab/iiab/pull/3302\n"
|
||||
{% else %}
|
||||
sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }}
|
||||
sed -i "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }}
|
||||
systemctl disable hostapd
|
||||
systemctl stop hostapd
|
||||
{% if wifi_up_down %}
|
||||
|
@ -11,13 +11,12 @@ systemctl disable iiab-clone-wifi.service
|
|||
systemctl disable iiab-wifi-test.service
|
||||
systemctl stop iiab-clone-wifi.service
|
||||
echo " IIAB hotspot access point Disabled"
|
||||
exit 0
|
||||
#exit 0
|
||||
{% else %}
|
||||
echo " IIAB hotspot access point Disabled"
|
||||
{% if is_raspbian %}
|
||||
# hotspot-off before ap0_updown
|
||||
sed -i -e "s/^denyinterfaces/#denyinterfaces/" /etc/dhcpcd.conf
|
||||
systemctl disable hostapd
|
||||
systemctl stop hostapd
|
||||
sed -i "s/^denyinterfaces/#denyinterfaces/" /etc/dhcpcd.conf
|
||||
#systemctl disable dnsmasq
|
||||
#systemctl stop dnsmasq
|
||||
systemctl daemon-reload
|
||||
|
@ -31,12 +30,12 @@ systemctl restart dhcpcd
|
|||
# ip link set dev wlan0 promisc on
|
||||
#fi
|
||||
{% else %}
|
||||
#ubuntu
|
||||
#ubuntu (or Mint, or pure Debian?)
|
||||
if [ -f /etc/NetworkManager/conf.d/wifi-manage.conf ]; then
|
||||
sed -i -e "s|managed=0|managed=1|" /etc/NetworkManager/conf.d/wifi-manage.conf
|
||||
sed -i "s|managed=0|managed=1|" /etc/NetworkManager/conf.d/wifi-manage.conf
|
||||
fi
|
||||
echo -e "\nPlease reboot to enable upstream WiFi access.\n"
|
||||
exit 0
|
||||
echo -e "\nIf you're enabling upstream WiFi, please reboot now.\n"
|
||||
#exit 0
|
||||
{% endif %}
|
||||
#is_raspbian
|
||||
{% endif %}
|
||||
|
|
|
@ -9,18 +9,17 @@ echo -e "If you add Wi-Fi hardware, run 'cd /opt/iiab/iiab' then 'sudo ./iiab-ne
|
|||
echo -e "For details, see: https://github.com/iiab/iiab/pull/3179\n"
|
||||
exit 1
|
||||
{% else %}
|
||||
sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }}
|
||||
sed -i "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }}
|
||||
{% if wifi_up_down %}
|
||||
systemctl enable iiab-clone-wifi.service
|
||||
systemctl enable hostapd
|
||||
systemctl enable iiab-wifi-test.service
|
||||
echo -e "\nPlease reboot to activate hostapd feature.\n"
|
||||
exit 0
|
||||
#exit 0
|
||||
{% else %}
|
||||
{% if is_raspbian %}
|
||||
# just do what we have always done in hotspot-on
|
||||
cp -f /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf
|
||||
sed -i -e "s/^#denyinterfaces/denyinterfaces/" /etc/dhcpcd.conf
|
||||
sed -i "s/^#denyinterfaces/denyinterfaces/" /etc/dhcpcd.conf
|
||||
# shut down wlan0 in case connected to network
|
||||
ip link set wlan0 down
|
||||
systemctl enable hostapd
|
||||
|
@ -38,13 +37,12 @@ systemctl start dnsmasq
|
|||
# ip link set dev wlan0 promisc off
|
||||
#fi
|
||||
{% else %}
|
||||
#ubuntu
|
||||
#ubuntu (or Mint, or pure Debian?)
|
||||
if [ -f /etc/NetworkManager/conf.d/wifi-manage.conf ]; then
|
||||
sed -i -e "s|managed=1|managed=0|" /etc/NetworkManager/conf.d/wifi-manage.conf
|
||||
sed -i "s|managed=1|managed=0|" /etc/NetworkManager/conf.d/wifi-manage.conf
|
||||
fi
|
||||
systemctl enable hostapd
|
||||
echo -e "\nPlease reboot to activate hostapd feature.\n"
|
||||
exit 0
|
||||
#exit 0
|
||||
{% endif %}
|
||||
#is_raspbian
|
||||
{% endif %}
|
||||
|
@ -53,3 +51,5 @@ exit 0
|
|||
#can_be_ap
|
||||
{% endif %}
|
||||
#network_enabled
|
||||
|
||||
echo -e "\nPlease reboot to activate hostapd feature.\n"
|
||||
|
|
|
@ -1,37 +1,52 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
# 2023-04-24 PR #3542 / PR #3549 context:
|
||||
# "systemd-network" "RasPiOS" have files with the client wifi info within them,
|
||||
# those can be parsed for the ssid without needing the related service running
|
||||
# first.
|
||||
# "Netplan systemd" "NetworkManager" need to be running to be able to parse for
|
||||
# the ssid, from the generated config file for "Netplan systemd" and from the
|
||||
# running environment for "NetworkManager".
|
||||
# "iiab-wifi-test.service" acts as a bit of a traffic cop keeping the ordering
|
||||
# of the services more deterministic when active and tries to catch a channel
|
||||
# mismatch between client wifi's current setting and what is contained within
|
||||
# hostapd.conf early in the boot process.
|
||||
|
||||
IFACE={{ discovered_wireless_iface }}
|
||||
RASPBIAN=0
|
||||
NETPLAN=0
|
||||
SSID="NA"
|
||||
# when we get here br0 should be available and dbus wpa_supplicant was started if enabled. None
|
||||
# of the backends that use wpa_supplicant should be active yet based on the Before= After= lines
|
||||
# in the iiab-wifi-test.service unit file.
|
||||
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 $$"
|
||||
|
||||
# covers systemd-networkd
|
||||
if [ -f /etc/wpa_supplicant/wpa_supplicant-$IFACE.conf ]; then
|
||||
SSID=`grep ssid /etc/wpa_supplicant/wpa_supplicant-$IFACE.conf | awk -F = '{print $2}' | sed -r s/\"// | sed -r s/\"//`
|
||||
echo "systemd-network"
|
||||
SSID=$(grep ssid /etc/wpa_supplicant/wpa_supplicant-$IFACE.conf | awk -F = '{print $2}' | sed -r s/\"// | sed -r s/\"//)
|
||||
fi
|
||||
|
||||
# covers raspbian
|
||||
if [ -f /etc/wpa_supplicant/wpa_supplicant.conf ]; then
|
||||
RASPBIAN=1
|
||||
if /usr/sbin/rfkill list wifi | grep -q "Soft blocked: yes" ; then
|
||||
echo "unblocking WiFi"
|
||||
rfkill unblock wifi
|
||||
fi
|
||||
SSID=`grep ssid /etc/wpa_supplicant/wpa_supplicant.conf | awk -F = '{print $2}' | sed -r s/\"// | sed -r s/\"//`
|
||||
# covers stock raspbian
|
||||
if [ -f /etc/wpa_supplicant/wpa_supplicant.conf ] && [ -n "$(pgrep dhcpcd)" ]; then
|
||||
echo "RasPiOS"
|
||||
SSID=$(grep ssid /etc/wpa_supplicant/wpa_supplicant.conf | awk -F = '{print $2}' | sed -r s/\"// | sed -r s/\"//)
|
||||
fi
|
||||
|
||||
# covers netplan's bugs workaround
|
||||
# https://bugs.launchpad.net/ubuntu/+source/linux-firmware/+bug/1862760
|
||||
# https://bugs.launchpad.net/netplan/+bug/1951586
|
||||
# WiFi country code progress on arm64 OS's discussed on #3078
|
||||
# covers netplan systemd use on server with bug workarounds
|
||||
if [ -f /run/netplan/wpa-$IFACE.conf ]; then
|
||||
NETPLAN=1
|
||||
SSID=`grep ssid /run/netplan/wpa-$IFACE.conf | awk -F = '{print $2}' | sed -r s/\"// | sed -r s/\"//`
|
||||
echo "Netplan systemd"
|
||||
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
|
||||
echo "cover netplan wifi client lack of country="
|
||||
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
|
||||
echo "set hostapd wifi country to $REG_DOM"
|
||||
|
@ -42,60 +57,76 @@ if [ -f /run/netplan/wpa-$IFACE.conf ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# IIAB hint for NetworkManager
|
||||
# could scrape /etc/NetworkManager/system-connections/ looking for ssid
|
||||
if [ -f /etc/iiab/iiab.env ]; then
|
||||
source /etc/iiab/iiab.env
|
||||
if [ ! -z $CLIENT_SSID ]; then
|
||||
SSID=$CLIENT_SSID
|
||||
fi
|
||||
# NetworkManager
|
||||
if [ -z "$SSID" ] && [ -n "$(pgrep NetworkManager)" ]; then
|
||||
echo "NetworkManager"
|
||||
sleep 15
|
||||
SSID=$(iw $IFACE info | grep ssid | awk '{print $2}' )
|
||||
fi
|
||||
echo "ssid is $SSID"
|
||||
if [[ $SSID == "" ]] || [[ $SSID == "NA" ]]; then
|
||||
echo "Couldn't find ssid $SSID to use exiting"
|
||||
if [ $NETPLAN -eq 1 ]; then
|
||||
|
||||
if [ -z "$SSID" ]; then
|
||||
echo "Couldn't find an UPSTREAM SSID in files like wpa_supplicant.conf -- so exiting."
|
||||
echo "CLARIF: This is normal when UPSTREAM WIFI is not active, as there would be no"
|
||||
echo "UPSTREAM SSID to extract, e.g. if 'wifi_up_down: False'"
|
||||
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}'`
|
||||
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 ] && [ $result -gt 2407 ]; then
|
||||
if [ "$result" -lt 2485 ] && [ "$result" -gt 2407 ]; then
|
||||
FREQ2=$result
|
||||
break
|
||||
else
|
||||
echo "channel $result is 5Ghz - ignoring"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Using $FREQ2 for $SSID"
|
||||
if [[ $FREQ2 == "" ]]; then
|
||||
|
||||
if [ -z "$FREQ2" ]; then
|
||||
echo "Couldn't find frequency to use exiting"
|
||||
if [ $NETPLAN -eq 1 ]; then
|
||||
echo "Netplan2"
|
||||
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 ))
|
||||
|
||||
CHAN=$((FREQ2 - 2407))
|
||||
CHAN=$((CHAN / 5))
|
||||
echo "channel is $CHAN for $SSID"
|
||||
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 ]; then
|
||||
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
|
||||
/bin/systemctl --no-block restart hostapd
|
||||
echo "Restarted hostapd"
|
||||
fi
|
||||
systemctl stop wpa_supplicant
|
||||
systemctl stop hostapd
|
||||
systemctl start hostapd
|
||||
systemctl start wpa_supplicant
|
||||
if [ $NETPLAN -eq 1 ]; then
|
||||
echo "Netplan3"
|
||||
# This is more of a netplan workaround should go away.
|
||||
systemctl restart netplan-wpa-$IFACE.service
|
||||
fi
|
||||
exit 0
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
[Unit]
|
||||
Description=IIAB find channel freq for ssid
|
||||
After=wpa_supplicant.service
|
||||
Wants=wpa_supplicant.service
|
||||
Before=hostapd.service
|
||||
Requisite=sys-subsystem-net-devices-{{ discovered_wireless_iface }}.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
|
||||
#BindsTo=sys-subsystem-net-devices-{{ discovered_wireless_iface }}.device
|
||||
#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=NetworkManager.service
|
||||
After=netplan-wpa-{{ discovered_wireless_iface }}.service
|
||||
Before=dhcpcd.service
|
||||
Before=wpa_supplicant@{{ discovered_wireless_iface }}.service
|
||||
Before=NetworkManager.service
|
||||
Before=netplan-wpa-{{ discovered_wireless_iface }}.service
|
||||
Before=network.target
|
||||
#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
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ "$IFACE" == "{{ iiab_lan_iface }}" ]; then
|
||||
echo "Restarting dnsmasq in 5 seconds"
|
||||
/bin/sleep 5 && /bin/systemctl --no-block restart dnsmasq.service
|
||||
echo "Restarted dnsmasq"
|
||||
/bin/systemctl --no-block start dnsmasq.service
|
||||
echo "Started dnsmasq"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue