From d6a51cb175b32cf3f9cd767ed44d99cb0c5d62a0 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 19:36:38 -0500 Subject: [PATCH 01/23] iiab-startup.yml clarifications --- roles/2-common/tasks/iiab-startup.yml | 39 +++++++++++++++------------ 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/roles/2-common/tasks/iiab-startup.yml b/roles/2-common/tasks/iiab-startup.yml index fa0e60d2c..345b69b9d 100644 --- a/roles/2-common/tasks/iiab-startup.yml +++ b/roles/2-common/tasks/iiab-startup.yml @@ -1,26 +1,31 @@ -- name: Does systemd startup service exist - stat: path="{{ systemd_location }}/iiab-startup.service" +- name: Does systemd iiab-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/ +- name: Copy iiab-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 +- name: Copy template script to /usr/libexec/iiab-startup.sh + 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 +- name: Do a systemd daemon-reload + # shell: systemctl daemon-reload + systemd: + daemon_reload: yes 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 +- name: Enable & restart the systemd service + # shell: systemctl restart iiab-startup.service + # shell: systemctl enable iiab-startup.service + service: + enabled: yes + restarted: yes when: startup_unit.stat.exists is defined and not startup_unit.stat.exists From ff07ba716a9d21e11810633b77ec29959247661c Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 19:43:34 -0500 Subject: [PATCH 02/23] tighten conditionals (gratuitous "startup_unit.stat.exists is defined") --- roles/2-common/tasks/iiab-startup.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/2-common/tasks/iiab-startup.yml b/roles/2-common/tasks/iiab-startup.yml index 345b69b9d..bdcb75e1c 100644 --- a/roles/2-common/tasks/iiab-startup.yml +++ b/roles/2-common/tasks/iiab-startup.yml @@ -7,20 +7,20 @@ template: src: iiab-startup.service dest: /etc/systemd/system/ - when: startup_unit.stat.exists is defined and not startup_unit.stat.exists + when: not startup_unit.stat.exists - name: Copy template script to /usr/libexec/iiab-startup.sh template: src: iiab-startup.sh dest: /usr/libexec/ mode: 0755 - when: startup_unit.stat.exists is defined and not startup_unit.stat.exists + when: not startup_unit.stat.exists - name: Do a systemd daemon-reload # shell: systemctl daemon-reload systemd: daemon_reload: yes - when: startup_unit.stat.exists is defined and not startup_unit.stat.exists + when: not startup_unit.stat.exists - name: Enable & restart the systemd service # shell: systemctl restart iiab-startup.service @@ -28,4 +28,4 @@ service: enabled: yes restarted: yes - when: startup_unit.stat.exists is defined and not startup_unit.stat.exists + when: not startup_unit.stat.exists From fbe58d0ba681dd147af0d3578a7384290e0ea53e Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 20:06:20 -0500 Subject: [PATCH 03/23] consolidate 3 commands w/ Ansible's systemd module --- roles/2-common/tasks/iiab-startup.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/roles/2-common/tasks/iiab-startup.yml b/roles/2-common/tasks/iiab-startup.yml index bdcb75e1c..a90a0cdb2 100644 --- a/roles/2-common/tasks/iiab-startup.yml +++ b/roles/2-common/tasks/iiab-startup.yml @@ -16,16 +16,13 @@ mode: 0755 when: not startup_unit.stat.exists -- name: Do a systemd daemon-reload +- name: Enable & restart the systemd service after daemon-reload # shell: systemctl daemon-reload - systemd: - daemon_reload: yes - when: not startup_unit.stat.exists - -- name: Enable & restart the systemd service # shell: systemctl restart iiab-startup.service # shell: systemctl enable iiab-startup.service - service: + systemd: + name: iiab-startup + daemon_reload: yes enabled: yes restarted: yes when: not startup_unit.stat.exists From e8a781230c4eaae4610fbdf4d67be2f5c2f131d4 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 20:09:35 -0500 Subject: [PATCH 04/23] fix "state: restarted" in Ansible's systemd module --- roles/2-common/tasks/iiab-startup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/2-common/tasks/iiab-startup.yml b/roles/2-common/tasks/iiab-startup.yml index a90a0cdb2..178115443 100644 --- a/roles/2-common/tasks/iiab-startup.yml +++ b/roles/2-common/tasks/iiab-startup.yml @@ -24,5 +24,5 @@ name: iiab-startup daemon_reload: yes enabled: yes - restarted: yes + state: restarted when: not startup_unit.stat.exists From 847a49917fdace202c7ec30f76649f1d190ecb00 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 20:26:52 -0500 Subject: [PATCH 05/23] condition on /usr/libexec/iiab-startup.sh (NOT unit file!) --- roles/2-common/tasks/iiab-startup.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/roles/2-common/tasks/iiab-startup.yml b/roles/2-common/tasks/iiab-startup.yml index 178115443..fd4cbb7c5 100644 --- a/roles/2-common/tasks/iiab-startup.yml +++ b/roles/2-common/tasks/iiab-startup.yml @@ -1,20 +1,20 @@ -- name: Does systemd iiab-startup.service exist? +- name: Does /usr/libexec/iiab-startup.sh exist? stat: - path: "{{ systemd_location }}/iiab-startup.service" - register: startup_unit - -- name: Copy iiab-startup.service to /etc/systemd/system - template: - src: iiab-startup.service - dest: /etc/systemd/system/ - when: not startup_unit.stat.exists + path: /usr/libexec/iiab-startup.sh + register: startup_script - name: Copy template script to /usr/libexec/iiab-startup.sh template: src: iiab-startup.sh dest: /usr/libexec/ mode: 0755 - when: not startup_unit.stat.exists + when: not startup_script.stat.exists + +- name: Copy iiab-startup.service to /etc/systemd/system + template: + src: iiab-startup.service + dest: "{{ systemd_location }}" + when: not startup_script.stat.exists - name: Enable & restart the systemd service after daemon-reload # shell: systemctl daemon-reload @@ -25,4 +25,4 @@ daemon_reload: yes enabled: yes state: restarted - when: not startup_unit.stat.exists + when: not startup_script.stat.exists From 2e8bb9c00d4fc1deb6c049804e2885904495fa45 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 20:41:05 -0500 Subject: [PATCH 06/23] Ansible output: "iiab-startup.service to {{ systemd_location }}" --- roles/2-common/tasks/iiab-startup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/2-common/tasks/iiab-startup.yml b/roles/2-common/tasks/iiab-startup.yml index fd4cbb7c5..8509bba5b 100644 --- a/roles/2-common/tasks/iiab-startup.yml +++ b/roles/2-common/tasks/iiab-startup.yml @@ -10,7 +10,7 @@ mode: 0755 when: not startup_script.stat.exists -- name: Copy iiab-startup.service to /etc/systemd/system +- name: Copy iiab-startup.service to {{ systemd_location }} template: src: iiab-startup.service dest: "{{ systemd_location }}" From c438c13fb1c15b4a0e0cd74f092027d92db57416 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 22:42:09 -0500 Subject: [PATCH 07/23] Enable Promiscuous WiFi on boot IFF AP's OFF --- roles/2-common/templates/iiab-startup.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/roles/2-common/templates/iiab-startup.sh b/roles/2-common/templates/iiab-startup.sh index 012a32746..0b89d9251 100644 --- a/roles/2-common/templates/iiab-startup.sh +++ b/roles/2-common/templates/iiab-startup.sh @@ -5,8 +5,17 @@ if [ ! -f /etc/iiab/uuid ]; then uuidgen > /etc/iiab/uuid fi -# Experimental/Temporary workaround for WiFi "10SEC disease" +# Temporary promiscuous-mode workaround for WiFi "10SEC disease" # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 -if grep -qi raspbian /etc/*release; then ip link set dev wlan0 promisc on; fi +if [[ $(grep -i raspbian /etc/*release) && + ($(grep "hostapd_enabled = False" /etc/iiab/config_vars.yml) || + ((! $(grep "hostapd_enabled = True" /etc/iiab/config_vars.yml)) && + $(grep "hostapd_enabled = False" /etc/iiab/iiab.ini) + ) + ) + ]]; +then + ip link set dev wlan0 promisc on +fi exit 0 From e61b3bd03d55912985b3cfce3d25ba109bc3f93a Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 23:04:17 -0500 Subject: [PATCH 08/23] AIM: Promiscuous WiFi Only When Nec (on boot, etc) --- roles/2-common/templates/iiab-startup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/roles/2-common/templates/iiab-startup.sh b/roles/2-common/templates/iiab-startup.sh index 0b89d9251..f7e34b3be 100644 --- a/roles/2-common/templates/iiab-startup.sh +++ b/roles/2-common/templates/iiab-startup.sh @@ -5,7 +5,9 @@ if [ ! -f /etc/iiab/uuid ]; then uuidgen > /etc/iiab/uuid fi -# Temporary promiscuous-mode workaround for WiFi "10SEC disease" +# Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease" +# Set wlan0 to promiscuous on boot if needed as gateway (i.e. AP's OFF) +# Scripts iiab-hotspot-on + iiab-hotspot-off SHOULD toggle this boot flag! # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 if [[ $(grep -i raspbian /etc/*release) && ($(grep "hostapd_enabled = False" /etc/iiab/config_vars.yml) || From 12b02ae99146480093ec7de92618826537d5e760 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 23:29:32 -0500 Subject: [PATCH 09/23] Ignore /etc/iiab/config_vars.yml for now (too complex; TBD w/ Admin Console) --- roles/2-common/templates/iiab-startup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/2-common/templates/iiab-startup.sh b/roles/2-common/templates/iiab-startup.sh index f7e34b3be..955fb23b8 100644 --- a/roles/2-common/templates/iiab-startup.sh +++ b/roles/2-common/templates/iiab-startup.sh @@ -10,11 +10,11 @@ fi # Scripts iiab-hotspot-on + iiab-hotspot-off SHOULD toggle this boot flag! # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 if [[ $(grep -i raspbian /etc/*release) && - ($(grep "hostapd_enabled = False" /etc/iiab/config_vars.yml) || - ((! $(grep "hostapd_enabled = True" /etc/iiab/config_vars.yml)) && + #($(grep "hostapd_enabled = False" /etc/iiab/config_vars.yml) || + #((! $(grep "hostapd_enabled = True" /etc/iiab/config_vars.yml)) && $(grep "hostapd_enabled = False" /etc/iiab/iiab.ini) - ) - ) + #) + #) ]]; then ip link set dev wlan0 promisc on From 35aab1938388976d43d9ba97fd7e593e29b8bdbb Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 23:33:22 -0500 Subject: [PATCH 10/23] iiab-hotspot-off sets "hostapd_enabled = False" in /etc/iiab/iiab.ini --- roles/network/templates/network/iiab-hotspot-off | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/network/templates/network/iiab-hotspot-off b/roles/network/templates/network/iiab-hotspot-off index 9e0027d6f..14f790d3a 100755 --- a/roles/network/templates/network/iiab-hotspot-off +++ b/roles/network/templates/network/iiab-hotspot-off @@ -8,6 +8,11 @@ systemctl daemon-reload systemctl restart dhcpcd systemctl restart networking -# Experimental/Temporary workaround for WiFi "10SEC disease" +# Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease" +# Set wlan0 to promiscuous when needed as gateway (i.e. AP's OFF) +# SEE ALSO iiab-hotspot-on + /usr/libexec/iiab-startup.sh # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 -if grep -qi raspbian /etc/*release; then ip link set dev wlan0 promisc on; fi +if grep -qi raspbian /etc/*release; then + ip link set dev wlan0 promisc on + sed -i -e "s/hostapd_enabled.*/hostapd_enabled = False/" /etc/iiab/iiab.ini +fi From de2550ed57ccf29bfa6fdda89d237dd30318105e Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 23:40:23 -0500 Subject: [PATCH 11/23] Update iiab-hotspot-off --- roles/network/templates/network/iiab-hotspot-off | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/templates/network/iiab-hotspot-off b/roles/network/templates/network/iiab-hotspot-off index 14f790d3a..5ceef7f18 100755 --- a/roles/network/templates/network/iiab-hotspot-off +++ b/roles/network/templates/network/iiab-hotspot-off @@ -9,7 +9,7 @@ systemctl restart dhcpcd systemctl restart networking # Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease" -# Set wlan0 to promiscuous when needed as gateway (i.e. AP's OFF) +# Set wlan0 to promiscuous when AP's OFF (for possible WiFi gateway) # SEE ALSO iiab-hotspot-on + /usr/libexec/iiab-startup.sh # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 if grep -qi raspbian /etc/*release; then From c138027c080f9fe68fb76e7411c2b8b347282dc0 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 23:41:18 -0500 Subject: [PATCH 12/23] iiab-hotspot-on sets "hostapd_enabled = True" in /etc/iiab/iiab.ini --- roles/network/templates/network/iiab-hotspot-on | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/roles/network/templates/network/iiab-hotspot-on b/roles/network/templates/network/iiab-hotspot-on index d34ce438a..34ea0e932 100755 --- a/roles/network/templates/network/iiab-hotspot-on +++ b/roles/network/templates/network/iiab-hotspot-on @@ -8,3 +8,12 @@ systemctl restart dhcpcd systemctl restart networking systemctl start hostapd systemctl start dhcpd + +# Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease" +# Disable "promiscuous" on wlan0 when AP (i.e. no WiFi gateway) +# SEE ALSO iiab-hotspot-off + /usr/libexec/iiab-startup.sh +# https://github.com/iiab/iiab/issues/638#issuecomment-355455454 +if grep -qi raspbian /etc/*release; then + ip link set dev wlan0 promisc off + sed -i -e "s/hostapd_enabled.*/hostapd_enabled = True/" /etc/iiab/iiab.ini +fi From 91b0e4cf177e631c888bde8228360b345e8d0f03 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 23:47:32 -0500 Subject: [PATCH 13/23] Update iiab-hotspot-on --- roles/network/templates/network/iiab-hotspot-on | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/network/templates/network/iiab-hotspot-on b/roles/network/templates/network/iiab-hotspot-on index 34ea0e932..5d1cb8faa 100755 --- a/roles/network/templates/network/iiab-hotspot-on +++ b/roles/network/templates/network/iiab-hotspot-on @@ -15,5 +15,6 @@ systemctl start dhcpd # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 if grep -qi raspbian /etc/*release; then ip link set dev wlan0 promisc off - sed -i -e "s/hostapd_enabled.*/hostapd_enabled = True/" /etc/iiab/iiab.ini fi + +sed -i -e "s/hostapd_enabled.*/hostapd_enabled = True/" /etc/iiab/iiab.ini From 2cd342f180ae8c5195eba831eacedd707e0c4a88 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 10 Jan 2018 23:47:39 -0500 Subject: [PATCH 14/23] Update iiab-hotspot-off --- roles/network/templates/network/iiab-hotspot-off | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/network/templates/network/iiab-hotspot-off b/roles/network/templates/network/iiab-hotspot-off index 5ceef7f18..00054812a 100755 --- a/roles/network/templates/network/iiab-hotspot-off +++ b/roles/network/templates/network/iiab-hotspot-off @@ -14,5 +14,6 @@ systemctl restart networking # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 if grep -qi raspbian /etc/*release; then ip link set dev wlan0 promisc on - sed -i -e "s/hostapd_enabled.*/hostapd_enabled = False/" /etc/iiab/iiab.ini fi + +sed -i -e "s/hostapd_enabled.*/hostapd_enabled = False/" /etc/iiab/iiab.ini From 50cdc51fd5716b9898bb824ea23b0b85c139d932 Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 11 Jan 2018 00:01:51 -0500 Subject: [PATCH 15/23] Update iiab-hotspot-off --- roles/network/templates/network/iiab-hotspot-off | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/templates/network/iiab-hotspot-off b/roles/network/templates/network/iiab-hotspot-off index 00054812a..ebd04eeb2 100755 --- a/roles/network/templates/network/iiab-hotspot-off +++ b/roles/network/templates/network/iiab-hotspot-off @@ -16,4 +16,4 @@ if grep -qi raspbian /etc/*release; then ip link set dev wlan0 promisc on fi -sed -i -e "s/hostapd_enabled.*/hostapd_enabled = False/" /etc/iiab/iiab.ini +sed -i -e "s/^hostapd_enabled.*/hostapd_enabled = False/" /etc/iiab/iiab.ini From 1007a343477ee5b7e02fb706b1b82c29c8536911 Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 11 Jan 2018 00:02:09 -0500 Subject: [PATCH 16/23] Update iiab-hotspot-on --- roles/network/templates/network/iiab-hotspot-on | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/templates/network/iiab-hotspot-on b/roles/network/templates/network/iiab-hotspot-on index 5d1cb8faa..9c17a4828 100755 --- a/roles/network/templates/network/iiab-hotspot-on +++ b/roles/network/templates/network/iiab-hotspot-on @@ -17,4 +17,4 @@ if grep -qi raspbian /etc/*release; then ip link set dev wlan0 promisc off fi -sed -i -e "s/hostapd_enabled.*/hostapd_enabled = True/" /etc/iiab/iiab.ini +sed -i -e "s/^hostapd_enabled.*/hostapd_enabled = True/" /etc/iiab/iiab.ini From 8d36117fd9639c4663033c001377cd4e732fe2d1 Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 11 Jan 2018 00:06:27 -0500 Subject: [PATCH 17/23] Update iiab-startup.sh --- roles/2-common/templates/iiab-startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/2-common/templates/iiab-startup.sh b/roles/2-common/templates/iiab-startup.sh index 955fb23b8..8e99b0f92 100644 --- a/roles/2-common/templates/iiab-startup.sh +++ b/roles/2-common/templates/iiab-startup.sh @@ -12,7 +12,7 @@ fi if [[ $(grep -i raspbian /etc/*release) && #($(grep "hostapd_enabled = False" /etc/iiab/config_vars.yml) || #((! $(grep "hostapd_enabled = True" /etc/iiab/config_vars.yml)) && - $(grep "hostapd_enabled = False" /etc/iiab/iiab.ini) + $(grep "^hostapd_enabled = False" /etc/iiab/iiab.ini) #) #) ]]; From f700843f69579b3c9800aea0682dc5e386af4112 Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 11 Jan 2018 00:32:41 -0500 Subject: [PATCH 18/23] Readability tweaks --- roles/network/tasks/computed_network.yml | 65 ++++++++++++------------ 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/roles/network/tasks/computed_network.yml b/roles/network/tasks/computed_network.yml index 6b3eba538..d2f7bdb1d 100644 --- a/roles/network/tasks/computed_network.yml +++ b/roles/network/tasks/computed_network.yml @@ -3,7 +3,7 @@ # ifcfg-rh acts on /etc/sys*/net*/ifcfg-* where we search for devices. - name: Setting XO has WiFi gateway set_fact: - user_wan_iface: "{{ discovered_wan_iface }}" + user_wan_iface: "{{ discovered_wan_iface }}" when: discovered_wan_iface != "none" and xo_model != "none" and has_ifcfg_gw == "none" #- name: Checking for NetworkManager-config-server @@ -22,7 +22,7 @@ - name: XO laptop wants USB WiFi interface as AP mode set_fact: - iiab_wireless_lan_iface: "{{ discovered_lan_iface }}" + iiab_wireless_lan_iface: "{{ discovered_lan_iface }}" when: num_wifi_interfaces >= "2" and xo_model != "none" and discovered_wan_iface != "none" and discovered_wireless_iface == "eth0" # static backout suppy new template file @@ -34,7 +34,7 @@ - name: Undo gui-static-wan by requesting new template file set_fact: - has_WAN: False + has_WAN: False when: gui_static_wan_ip != "unset" and not gui_static_wan # figure out more than one interfaces to detect. @@ -77,7 +77,7 @@ - name: Setting user_lan_iface for 'LanController' for single interface set_fact: - user_lan_iface: "{{ discovered_wan_iface }}" + user_lan_iface: "{{ discovered_wan_iface }}" when: discovered_wan_iface != "none" and num_lan_interfaces == "0" and gui_desired_network_role is defined and gui_desired_network_role == "LanController" # override with user_wan_iface setting if no longer in auto @@ -108,10 +108,10 @@ # make it so number 2 vars should use user_wan_iface but we can cover a single # wired if dhcp fails the interface should revert to LAN, static address should -# stick around but testing gateway response is not preformed. +# stick around but testing gateway response is not performed. - name: User wants single wired interface as static or dhcp gateway set_fact: - user_wan_iface: "{{ discovered_lan_iface }}" + user_wan_iface: "{{ discovered_lan_iface }}" when: num_lan_interfaces == "1" and user_lan_iface == "auto" and user_wan_iface == "auto" - name: No LAN configured - 'Appliance' mode @@ -154,30 +154,31 @@ when: adapter_count.stdout|int >= "5" and device_gw == "none" and gui_wan_iface == "unset" and gui_static_wan is defined - name: Add location section to config file - ini_file: dest='{{ iiab_config_file }}' - section=computed_network - option='{{ item.option }}' - value='{{ item.value }}' + ini_file: + dest: "{{ iiab_config_file }}" + section: computed_network + option: "{{ item.option }}" + value: "{{ item.value }}" with_items: - - option: 'iiab_wan_enabled' - value: '{{ iiab_wan_enabled }}' - - option: 'user_wan_iface' - value: '{{ user_wan_iface }}' - - option: 'iiab_wan_iface' - value: '{{ iiab_wan_iface }}' - - option: 'iiab_lan_enabled' - value: '{{ iiab_lan_enabled }}' - - option: 'user_lan_iface' - value: '{{ user_lan_iface }}' - - option: 'iiab_lan_iface' - value: '{{ iiab_lan_iface }}' - - option: 'iiab_network_mode' - value: '{{ iiab_network_mode }}' - - 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 }}' + - option: iiab_wan_enabled + value: "{{ iiab_wan_enabled }}" + - option: user_wan_iface + value: "{{ user_wan_iface }}" + - option: iiab_wan_iface + value: "{{ iiab_wan_iface }}" + - option: iiab_lan_enabled + value: "{{ iiab_lan_enabled }}" + - option: user_lan_iface + value: "{{ user_lan_iface }}" + - option: iiab_lan_iface + value: "{{ iiab_lan_iface }}" + - option: iiab_network_mode + value: "{{ iiab_network_mode }}" + - 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 }}" From 236580eff6c372bc54217710e8ccb895b18df7d8 Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 11 Jan 2018 09:02:24 -0500 Subject: [PATCH 19/23] Clarify how hostapd_enabled is RECORDED into /etc/iiab/iiab.ini --- roles/network/tasks/main.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index 98dc85c29..1735dcc91 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -11,9 +11,13 @@ no_net_restart: True # used below in (1) sysd-netd-debian.yml, # (2) debian.yml, (3) rpi_debian.yml when: discovered_wireless_iface == iiab_wan_iface and not reboot_to_AP -# Idea, Not Without Risks: should WiFi-as-gateway detection logic -# be encapsulated into roles/network/tasks/hostapd.yml in future? -# Today "./runtags hostapd" doesn't exist & "./runtags AP" is at yr own risk. +# EITHER WAY: hostapd_enabled's state is RECORDED into /etc/iiab/iiab.ini +# (by computed_ntetwork.yml below) for later use by... +# /usr/libexec/iiab-startup.sh, iiab-hotspot-off & iiab-hotspot-on +# +# Separate Idea, Not Without Risks: should WiFi-as-gateway detection logic +# be encapsulated into roles/network/tasks/hostapd.yml in future? Whereas +# today "./runtags hostapd" doesn't exist & "./runtags AP" is UNSUPPORTED! #- name: RPi - reboot to AP post install - installed via wifi so the services are ready # set_fact: From 9a689d8af9119951bb4b01b9de8791db94113376 Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 11 Jan 2018 09:56:26 -0500 Subject: [PATCH 20/23] discovered_lan_iface depr so TRY discovered_wan_iface --- roles/network/tasks/computed_network.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/computed_network.yml b/roles/network/tasks/computed_network.yml index d2f7bdb1d..0fa9505a9 100644 --- a/roles/network/tasks/computed_network.yml +++ b/roles/network/tasks/computed_network.yml @@ -111,7 +111,7 @@ # stick around but testing gateway response is not performed. - name: User wants single wired interface as static or dhcp gateway set_fact: - user_wan_iface: "{{ discovered_lan_iface }}" + user_wan_iface: "{{ discovered_wan_iface }}" # Jan 2018: discovered_lan_iface was UNDEFINED on WiFi-installed RPi when: num_lan_interfaces == "1" and user_lan_iface == "auto" and user_wan_iface == "auto" - name: No LAN configured - 'Appliance' mode From 1b86d291b0508b0a995729eeefaa26f5e6b27efb Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 11 Jan 2018 11:41:51 -0500 Subject: [PATCH 21/23] computed_network.yml workaround discovered_lan_iface -> discovered_wan_iface --- roles/network/tasks/computed_network.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/network/tasks/computed_network.yml b/roles/network/tasks/computed_network.yml index 0fa9505a9..9a466533a 100644 --- a/roles/network/tasks/computed_network.yml +++ b/roles/network/tasks/computed_network.yml @@ -111,7 +111,10 @@ # stick around but testing gateway response is not performed. - name: User wants single wired interface as static or dhcp gateway set_fact: - user_wan_iface: "{{ discovered_wan_iface }}" # Jan 2018: discovered_lan_iface was UNDEFINED on WiFi-installed RPi + user_wan_iface: "{{ discovered_wan_iface }}" # Jan 2018: Holt discovered_lan_iface was UNDEFINED on WiFi-installed + # RPi (when re-running ./iiab-network) so "discovered_wan_iface" is a + # workaround -- please see https://github.com/iiab/iiab/pull/649 + # This workaround can and should evolve as IIAB 6.5 matures! when: num_lan_interfaces == "1" and user_lan_iface == "auto" and user_wan_iface == "auto" - name: No LAN configured - 'Appliance' mode From 7ce1278d7b014787472cb2ef35146888af0b7060 Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 11 Jan 2018 13:48:27 -0500 Subject: [PATCH 22/23] fix iiab-startup.sh when hostapd_enabled = False (bash syntax/comment error) --- roles/2-common/templates/iiab-startup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/2-common/templates/iiab-startup.sh b/roles/2-common/templates/iiab-startup.sh index 8e99b0f92..595099799 100644 --- a/roles/2-common/templates/iiab-startup.sh +++ b/roles/2-common/templates/iiab-startup.sh @@ -9,13 +9,13 @@ fi # Set wlan0 to promiscuous on boot if needed as gateway (i.e. AP's OFF) # Scripts iiab-hotspot-on + iiab-hotspot-off SHOULD toggle this boot flag! # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 -if [[ $(grep -i raspbian /etc/*release) && +if [[ $(grep -i raspbian /etc/*release) && \ #($(grep "hostapd_enabled = False" /etc/iiab/config_vars.yml) || #((! $(grep "hostapd_enabled = True" /etc/iiab/config_vars.yml)) && - $(grep "^hostapd_enabled = False" /etc/iiab/iiab.ini) + $(grep "^hostapd_enabled = False" /etc/iiab/iiab.ini) ]]; #) #) - ]]; + #]]; then ip link set dev wlan0 promisc on fi From 1178c452a7cf47e7f9f7f9e78c3205085f292f4d Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 11 Jan 2018 13:51:22 -0500 Subject: [PATCH 23/23] backslash not needed (in bash conditional) --- roles/2-common/templates/iiab-startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/2-common/templates/iiab-startup.sh b/roles/2-common/templates/iiab-startup.sh index 595099799..0b2cf5db9 100644 --- a/roles/2-common/templates/iiab-startup.sh +++ b/roles/2-common/templates/iiab-startup.sh @@ -9,7 +9,7 @@ fi # Set wlan0 to promiscuous on boot if needed as gateway (i.e. AP's OFF) # Scripts iiab-hotspot-on + iiab-hotspot-off SHOULD toggle this boot flag! # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 -if [[ $(grep -i raspbian /etc/*release) && \ +if [[ $(grep -i raspbian /etc/*release) && #($(grep "hostapd_enabled = False" /etc/iiab/config_vars.yml) || #((! $(grep "hostapd_enabled = True" /etc/iiab/config_vars.yml)) && $(grep "^hostapd_enabled = False" /etc/iiab/iiab.ini) ]];