1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00

Detect, recored if wifi can be AP and suppress installing supporting files

This commit is contained in:
Jerry Vonau 2021-12-17 04:10:31 -06:00
parent 35b0c7e3b2
commit 7113f87f32
3 changed files with 22 additions and 7 deletions

View file

@ -59,6 +59,7 @@ virtual_network_devices: "-e ap0 -e lo -e br0 -e tun -e br- -e docker -e bridge0
# Set defaults for discovery process as strings # Set defaults for discovery process as strings
wifi1: "not found-1" wifi1: "not found-1"
wifi2: "not found-2" wifi2: "not found-2"
can_be_ap: False
exclude_devices: none exclude_devices: none
device_gw: none device_gw: none
prior_gw_device: unset prior_gw_device: unset

View file

@ -101,6 +101,16 @@
set_fact: set_fact:
num_wifi_interfaces: "{{ count_wifi_interfaces.stdout|int }}" num_wifi_interfaces: "{{ count_wifi_interfaces.stdout|int }}"
- name: Check for Access Point capablility with 'iw list'
command: iw list | grep AP | wc -l
register: look_for_ap
when: discovered_wireless_iface != "none"
- name: Setting can_be_ap
set_fact:
can_be_ap: True
when: look_for_ap|int != "0"
- name: Detect wifi gateway active - name: Detect wifi gateway active
shell: ip r | grep default | grep {{ discovered_wireless_iface }} | wc -l shell: ip r | grep default | grep {{ discovered_wireless_iface }} | wc -l
register: wifi_gateway_found register: wifi_gateway_found
@ -260,6 +270,8 @@
value: "{{ iiab_lan_iface }}" value: "{{ iiab_lan_iface }}"
- option: iiab_wan_iface - option: iiab_wan_iface
value: "{{ iiab_wan_iface }}" value: "{{ iiab_wan_iface }}"
- option: can_be_ap
value: "{{ can_be_ap }}"
# well if there ever was a point to tell the user things are FUBAR this is it. # well if there ever was a point to tell the user things are FUBAR this is it.
# limit 2 network adapters wifi wired # limit 2 network adapters wifi wired

View file

@ -4,10 +4,10 @@
enabled: no enabled: no
masked: no masked: no
- name: Disable hostapd when not using ap0 and wifi gateway present, or no WiFi hardware present - name: Disable hostapd when not using ap0 and wifi gateway present, or no WiFi hardware present or support not detected
set_fact: set_fact:
hostapd_enabled: False hostapd_enabled: False
when: (not wifi_up_down and discovered_wireless_iface == iiab_wan_iface) or discovered_wireless_iface == "none" when: (not wifi_up_down and discovered_wireless_iface == iiab_wan_iface) or discovered_wireless_iface == "none" or not can_be_ap
- name: Detect current Wifi channel - name: Detect current Wifi channel
shell: iw {{ discovered_wireless_iface }} info | grep channel | cut -d' ' -f2 shell: iw {{ discovered_wireless_iface }} info | grep channel | cut -d' ' -f2
@ -29,7 +29,7 @@
with_items: with_items:
- { src: 'hostapd/hostapd.conf.j2', dest: '/etc/hostapd/hostapd.conf' } - { src: 'hostapd/hostapd.conf.j2', dest: '/etc/hostapd/hostapd.conf' }
- { src: 'hostapd/hostapd.conf.j2', dest: '/etc/hostapd/hostapd.conf.iiab' } - { src: 'hostapd/hostapd.conf.j2', dest: '/etc/hostapd/hostapd.conf.iiab' }
when: discovered_wireless_iface != "none" when: can_be_ap
- name: Generate new random mac address for ap0 - name: Generate new random mac address for ap0
shell: tr -dc A-F0-9 < /dev/urandom | head -c 10 | sed -r 's/(..)/\1:/g;s/:$//;s/^/02:/' shell: tr -dc A-F0-9 < /dev/urandom | head -c 10 | sed -r 's/(..)/\1:/g;s/:$//;s/^/02:/'
@ -51,7 +51,7 @@
- { src: 'hostapd/iiab-clone-wifi.service.j2', dest: '/etc/systemd/system/iiab-clone-wifi.service', mode: '0644' } - { src: 'hostapd/iiab-clone-wifi.service.j2', dest: '/etc/systemd/system/iiab-clone-wifi.service', mode: '0644' }
- { src: 'hostapd/iiab-wifi-test.service.j2', dest: '/etc/systemd/system/iiab-wifi-test.service', mode: '0644'} - { src: 'hostapd/iiab-wifi-test.service.j2', dest: '/etc/systemd/system/iiab-wifi-test.service', mode: '0644'}
- { src: 'hostapd/iiab-test-wifi.j2', dest: '/usr/sbin/iiab-test-wifi', mode: '0755' } - { src: 'hostapd/iiab-test-wifi.j2', dest: '/usr/sbin/iiab-test-wifi', mode: '0755' }
when: discovered_wireless_iface != "none" when: can_be_ap
- name: Use custom 'hostapd' systemd service unit file for {{ discovered_wireless_iface }} when not wifi_up_down - name: Use custom 'hostapd' systemd service unit file for {{ discovered_wireless_iface }} when not wifi_up_down
template: template:
@ -60,23 +60,25 @@
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
when: discovered_wireless_iface != "none" and not wifi_up_down when: not wifi_up_down and can_be_ap
- name: Create /usr/bin/iiab-hotspot-on from template - name: Create /usr/bin/iiab-hotspot-on from template when hardware supports AP
template: template:
src: network/iiab-hotspot-on src: network/iiab-hotspot-on
dest: /usr/bin/iiab-hotspot-on dest: /usr/bin/iiab-hotspot-on
owner: root owner: root
group: root group: root
mode: 0755 mode: 0755
when: can_be_ap
- name: Create /usr/bin/iiab-hotspot-off from template - name: Create /usr/bin/iiab-hotspot-off from template when hardware supports AP
template: template:
src: network/iiab-hotspot-off src: network/iiab-hotspot-off
dest: /usr/bin/iiab-hotspot-off dest: /usr/bin/iiab-hotspot-off
owner: root owner: root
group: root group: root
mode: 0755 mode: 0755
when: can_be_ap
- name: Create dhcpcd hook for hostapd and ap0 when wifi_up_down True - name: Create dhcpcd hook for hostapd and ap0 when wifi_up_down True
template: template: