mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 11:42:08 +00:00
94 lines
2.7 KiB
YAML
94 lines
2.7 KiB
YAML
- name: Turn off hostapd when no wifi interface present or in "Appliance Mode"
|
|
set_fact:
|
|
hostapd_enabled: False
|
|
when: iiab_wireless_lan_iface is undefined or iiab_network_mode == "Appliance"
|
|
|
|
- name: Detect current Wifi channel
|
|
shell: iw {{ discovered_wireless_iface }} info | grep channel | cut -d' ' -f2
|
|
register: current_host_channel
|
|
when: discovered_wireless_iface != "none"
|
|
|
|
- name: Setting WiFi channel to {{ current_host_channel.stdout }} on RPi hardware
|
|
set_fact:
|
|
host_channel: "{{ current_host_channel.stdout }}"
|
|
when: current_host_channel.stdout != "" and discovered_wireless_iface != "none" and rpi_model != "none"
|
|
|
|
- name: Create /etc/hostapd/hostapd.conf from template
|
|
template:
|
|
src: hostapd/hostapd.conf.j2
|
|
dest: /etc/hostapd/hostapd.conf
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
when: discovered_wireless_iface != "none"
|
|
|
|
- name: Create backup /etc/hostapd/hostapd.conf.iiab from template
|
|
template:
|
|
src: hostapd/iiab-hostapd.conf.j2
|
|
dest: /etc/hostapd/hostapd.conf.iiab
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
when: discovered_wireless_iface != "none"
|
|
|
|
- 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:/'
|
|
register: ap0_mac
|
|
|
|
- name: Setting ap0 mac address for use in hostapd service file
|
|
set_fact:
|
|
ap0_mac_addr: "{{ ap0_mac.stdout }}"
|
|
|
|
- name: Use custom systemd unit file to start 'hostapd' service
|
|
template:
|
|
src: hostapd/hostapd.service.j2
|
|
dest: /etc/systemd/system/hostapd.service
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
when: discovered_wireless_iface != "none"
|
|
|
|
- name: Create /usr/bin/iiab-hotspot-on from template
|
|
template:
|
|
src: network/iiab-hotspot-on
|
|
dest: /usr/bin/iiab-hotspot-on
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
|
|
- name: Create /usr/bin/iiab-hotspot-off from template
|
|
template:
|
|
src: network/iiab-hotspot-off
|
|
dest: /usr/bin/iiab-hotspot-off
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
|
|
- name: Create dhcpcd hook for hostapd
|
|
template:
|
|
src: hostapd/50-hostapd
|
|
dest: /lib/dhcpcd/dhcpcd-hooks/50-hostapd
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
when: is_raspbian
|
|
|
|
- name: Disable the Access Point 'hostapd' service
|
|
systemd:
|
|
name: hostapd
|
|
enabled: no
|
|
# cheap workaround for when /etc/init.d is populated
|
|
# when: not hostapd_enabled
|
|
|
|
- name: Enable the Access Point 'hostapd' service
|
|
systemd:
|
|
name: hostapd
|
|
enabled: yes
|
|
when: hostapd_enabled
|
|
|
|
- name: Record HOSTAPD_ENABLED to {{ iiab_env_file }}
|
|
lineinfile:
|
|
path: "{{ iiab_env_file }}"
|
|
regexp: '^HOSTAPD_ENABLED=*'
|
|
line: 'HOSTAPD_ENABLED={{ hostapd_enabled }}'
|
|
state: present
|