mirror of
https://github.com/iiab/iiab.git
synced 2025-02-15 04:32:11 +00:00
Merge pull request #3537 from jvonau/reg_dom
RFC 2210 2304 fixed https://bugs.launchpad.net/bugs/1951586 [netplan WiFi country code]
This commit is contained in:
commit
671343b9e9
7 changed files with 54 additions and 12 deletions
|
@ -71,8 +71,9 @@
|
||||||
when: wan_ip != "dhcp"
|
when: wan_ip != "dhcp"
|
||||||
|
|
||||||
- name: Use systemd-networkd to handle br0
|
- name: Use systemd-networkd to handle br0
|
||||||
include_tasks: sysd-netd-debian.yml
|
set_fact:
|
||||||
when: iiab_lan_iface == "br0" and not systemd_networkd_active
|
systemd_networkd_active: True
|
||||||
|
when: iiab_lan_iface == "br0"
|
||||||
|
|
||||||
- name: Reload systemd
|
- name: Reload systemd
|
||||||
systemd:
|
systemd:
|
||||||
|
|
|
@ -14,6 +14,16 @@
|
||||||
- wpa_supplicant
|
- wpa_supplicant
|
||||||
when: wifi_up_down and hostapd_enabled
|
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
|
- name: Create /etc/hostapd/hostapd.conf and backup .iiab from template if needed
|
||||||
template:
|
template:
|
||||||
owner: root
|
owner: root
|
||||||
|
@ -26,6 +36,14 @@
|
||||||
- { src: 'hostapd/hostapd.conf.j2', dest: '/etc/hostapd/hostapd.conf.iiab' }
|
- { src: 'hostapd/hostapd.conf.j2', dest: '/etc/hostapd/hostapd.conf.iiab' }
|
||||||
when: can_be_ap
|
when: can_be_ap
|
||||||
|
|
||||||
|
- name: Enable & Restart networkd-dispatcher.service
|
||||||
|
systemd:
|
||||||
|
name: networkd-dispatcher
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
masked: no
|
||||||
|
when: systemd_networkd_active
|
||||||
|
|
||||||
- name: Restart hostapd when WiFi is present but not when using WiFi as gateway with wifi_up_down False
|
- name: Restart hostapd when WiFi is present but not when using WiFi as gateway with wifi_up_down False
|
||||||
systemd:
|
systemd:
|
||||||
name: hostapd
|
name: hostapd
|
||||||
|
|
|
@ -87,6 +87,17 @@
|
||||||
systemd:
|
systemd:
|
||||||
daemon_reload: yes
|
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
|
- name: Clone wifi if needed
|
||||||
systemd:
|
systemd:
|
||||||
name: iiab-clone-wifi
|
name: iiab-clone-wifi
|
||||||
|
@ -107,9 +118,3 @@
|
||||||
enabled: yes
|
enabled: yes
|
||||||
masked: no
|
masked: no
|
||||||
|
|
||||||
- name: Enable & Restart networkd-dispatcher.service
|
|
||||||
systemd:
|
|
||||||
name: networkd-dispatcher
|
|
||||||
state: restarted
|
|
||||||
enabled: yes
|
|
||||||
masked: no
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ fi
|
||||||
echo -e "\nPlease reboot to enable upstream WiFi access.\n"
|
echo -e "\nPlease reboot to enable upstream WiFi access.\n"
|
||||||
exit 0
|
exit 0
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
#is_raspbian
|
||||||
|
{% endif %}
|
||||||
#wifi_up_down
|
#wifi_up_down
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
#network_enabled
|
||||||
|
|
|
@ -46,7 +46,10 @@ systemctl enable hostapd
|
||||||
echo -e "\nPlease reboot to activate hostapd feature.\n"
|
echo -e "\nPlease reboot to activate hostapd feature.\n"
|
||||||
exit 0
|
exit 0
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
#is_raspbian
|
||||||
|
{% endif %}
|
||||||
#wifi_up_down
|
#wifi_up_down
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
#can_be_ap
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
#network_enabled
|
||||||
|
|
|
@ -29,9 +29,19 @@ fi
|
||||||
if [ -f /run/netplan/wpa-$IFACE.conf ]; then
|
if [ -f /run/netplan/wpa-$IFACE.conf ]; then
|
||||||
NETPLAN=1
|
NETPLAN=1
|
||||||
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/\"//`
|
||||||
echo "cover netplan lack of country="
|
REG_DOM=$(grep country /run/netplan/wpa-$IFACE.conf | awk -F = '{ print $2 }')
|
||||||
sed -i 's|ctrl_interface=/run/wpa_supplicant|&\ncountry=US|' /run/netplan/wpa-$IFACE.conf
|
if [ -z "$REG_DOM" ]; then
|
||||||
|
echo "cover netplan wifi client lack of country="
|
||||||
|
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"
|
||||||
|
if [ -f /etc/hostapd/hostapd.conf.iiab ]; then
|
||||||
|
sed -i "s|^country.*|country_code=$REG_DOM|" /etc/hostapd/hostapd.conf.iiab
|
||||||
|
cp /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# IIAB hint for NetworkManager
|
# IIAB hint for NetworkManager
|
||||||
# could scrape /etc/NetworkManager/system-connections/ looking for ssid
|
# could scrape /etc/NetworkManager/system-connections/ looking for ssid
|
||||||
if [ -f /etc/iiab/iiab.env ]; then
|
if [ -f /etc/iiab/iiab.env ]; then
|
||||||
|
|
|
@ -13,6 +13,9 @@ if [ "$IFACE" == "{{ discovered_wireless_iface }}" ]; then
|
||||||
systemctl stop wpa_supplicant
|
systemctl stop wpa_supplicant
|
||||||
systemctl restart hostapd
|
systemctl restart hostapd
|
||||||
systemctl start wpa_supplicant
|
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
|
||||||
|
|
Loading…
Reference in a new issue