diff --git a/roles/2-common/tasks/iiab-startup.yml b/roles/2-common/tasks/iiab-startup.yml new file mode 100644 index 000000000..fa0e60d2c --- /dev/null +++ b/roles/2-common/tasks/iiab-startup.yml @@ -0,0 +1,26 @@ +- name: Does systemd startup service exist + stat: path="{{ systemd_location }}/iiab-startup.service" + register: startup_unit + +- name: Copy startup service to /etc/systemd/system + template: src=iiab-startup.service + dest=/etc/systemd/system/ + when: startup_unit.stat.exists is defined and not startup_unit.stat.exists + +- name: Copy startup script + template: src=iiab-startup.sh + dest=/usr/libexec/ + mode=0755 + when: startup_unit.stat.exists is defined and not startup_unit.stat.exists + +- name: Ask systemd to recognize the changes + shell: systemctl daemon-reload + when: startup_unit.stat.exists is defined and not startup_unit.stat.exists + +- name: Restart so systemd recognizes the changes + shell: systemctl restart iiab-startup.service + when: startup_unit.stat.exists is defined and not startup_unit.stat.exists + +- name: Enable the reload service + shell: systemctl enable iiab-startup.service + when: startup_unit.stat.exists is defined and not startup_unit.stat.exists diff --git a/roles/2-common/tasks/main.yml b/roles/2-common/tasks/main.yml index 638457f5f..44cbdc41c 100644 --- a/roles/2-common/tasks/main.yml +++ b/roles/2-common/tasks/main.yml @@ -44,6 +44,8 @@ - include_tasks: udev.yml +- include_tasks: iiab-startup.yml + - name: Recording STAGE 2 HAS COMPLETED ========================== lineinfile: dest=/etc/iiab/iiab.env regexp='^STAGE=*' diff --git a/roles/2-common/templates/iiab-startup.service b/roles/2-common/templates/iiab-startup.service new file mode 100644 index 000000000..6e9490466 --- /dev/null +++ b/roles/2-common/templates/iiab-startup.service @@ -0,0 +1,10 @@ +[Unit] +Description=Execute startup script +After=network-online.target + +[Service] +Type=oneshot +ExecStart=/usr/libexec/iiab-startup.sh + +[Install] +WantedBy=multi-user.target diff --git a/roles/2-common/templates/iiab-startup.sh b/roles/2-common/templates/iiab-startup.sh new file mode 100644 index 000000000..afb2c1d98 --- /dev/null +++ b/roles/2-common/templates/iiab-startup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# put initialization that needs to happen at every startup for IIAB here + +if [ ! -f /etc/iiab/uuid ]; then + uuidgen > /etc/iiab/uuid +fi +exit 0 + diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 2f8ac6c07..9a815591a 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -8,7 +8,7 @@ - name: Create a config template for hostapd template: src=hostapd/iiab-hostapd.conf.j2 - dest=/etc/hostapd/hostapd.conf.template + dest=/etc/hostapd/hostapd.conf.iiab owner=root group=root mode=0644 diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index 77b131b71..0e51de1be 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -8,13 +8,13 @@ - network - network-discover -- name: RPi hack for AP post install via wifi so the services are right +- name: RPi - reboot to AP post install - installed via wifi so the services are ready set_fact: iiab_lan_iface: br0 iiab_wan_iface: "{{ discovered_wired_iface }}" iiab_wireless_lan_iface: "{{ discovered_wireless_iface }}" iiab_wired_lan_iface: "" - when: is_rpi and discovered_wireless_iface is defined and discovered_wireless_iface == iiab_wan_iface + when: is_rpi and discovered_wireless_iface is defined and discovered_wireless_iface == iiab_wan_iface and reboot_to_AP is defined - include_tasks: computed_network.yml when: not installing @@ -27,7 +27,7 @@ - network - AP -- name: RPi hack for AP post install via wifi don't blow away current network +- name: RPi reboot to AP post install - installed via wifi - don't blow away current network set_fact: no_net_restart: True hostapd_enabled: False diff --git a/roles/network/templates/network/iiab-hotspot-off b/roles/network/templates/network/iiab-hotspot-off index ca266dcb5..3f187a21e 100755 --- a/roles/network/templates/network/iiab-hotspot-off +++ b/roles/network/templates/network/iiab-hotspot-off @@ -2,6 +2,8 @@ sed -i -e "s/^denyinterfaces*/#denyinterfaces/" /etc/dhcpcd.conf systemctl disable hostapd systemctl stop hostapd +systemctl disable dhcpd +systemctl stop dhcpd systemctl daemon-reload systemctl restart dhcpcd systemctl restart networking diff --git a/roles/network/templates/network/iiab-hotspot-on b/roles/network/templates/network/iiab-hotspot-on index 0f1310110..7ab35962a 100755 --- a/roles/network/templates/network/iiab-hotspot-on +++ b/roles/network/templates/network/iiab-hotspot-on @@ -1,7 +1,10 @@ #!/bin/bash +cp -f /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf sed -i -e "s/#denyinterfaces*/denyinterfaces/" /etc/dhcpcd.conf systemctl enable hostapd +systemctl enable dhcpd systemctl daemon-reload systemctl restart dhcpcd systemctl restart networking systemctl start hostapd +systemctl start dhcpd