diff --git a/buildroot-external/board/raspberrypi/rootfs-overlay/etc/iptables.rules b/buildroot-external/board/raspberrypi/rootfs-overlay/etc/iptables.rules deleted file mode 100644 index a10b7f16..00000000 --- a/buildroot-external/board/raspberrypi/rootfs-overlay/etc/iptables.rules +++ /dev/null @@ -1,13 +0,0 @@ -*nat -:PREROUTING ACCEPT [14:1672] -:INPUT ACCEPT [13:1640] -:OUTPUT ACCEPT [24:1440] -:POSTROUTING ACCEPT [24:1440] --A PREROUTING -p tcp -m tcp --dport 80 -j DNAT --to-destination 172.16.127.1 --A PREROUTING -p tcp -m tcp --dport 443 -j DNAT --to-destination 172.16.127.1 -COMMIT -*filter -:INPUT ACCEPT [60540:12954317] -:FORWARD ACCEPT [0:0] -:OUTPUT ACCEPT [56210:7390098] -COMMIT diff --git a/buildroot-external/board/raspberrypi/rootfs-overlay/etc/nginx/nginx.conf b/buildroot-external/board/raspberrypi/rootfs-overlay/etc/nginx/nginx.conf index fe3a5ac9..cce3b5de 100644 --- a/buildroot-external/board/raspberrypi/rootfs-overlay/etc/nginx/nginx.conf +++ b/buildroot-external/board/raspberrypi/rootfs-overlay/etc/nginx/nginx.conf @@ -12,7 +12,7 @@ http { keepalive_timeout 65; server { - listen 80; + listen 172.16.127.1:80; server_name MycroftOS; root /opt/mycroft/wifisetup/templates; diff --git a/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/app.py b/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/app.py index ec1a803a..d51f2121 100644 --- a/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/app.py +++ b/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/app.py @@ -41,8 +41,6 @@ def save_credentials(): @app.route('/skip_wifi') def skip_wifi(): - empty_wpa_supplicant() - # Call reconfigure_device() in a thread otherwise the reconfigure will prevent # the response from getting to the browser def sleep_and_reconfigure(): @@ -89,25 +87,12 @@ def create_wpa_supplicant(ssid, wifi_key): os.system('mv wpa_supplicant-wlan0.conf.tmp /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') -def empty_wpa_supplicant(): - temp_conf_file = open('wpa_supplicant-wlan0.conf.tmp', 'w') - - temp_conf_file.write('ctrl_interface=DIR=/var/run/wpa_supplicant\n') - temp_conf_file.write('update_config=1\n') - temp_conf_file.write('\n') - temp_conf_file.write('network={\n') - - temp_conf_file.write('}\n') - - temp_conf_file.close - - os.system('mv wpa_supplicant-wlan0.conf.tmp /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') - - def reconfigure_device(): os.system('systemctl disable wpa_supplicant@ap0.service') os.system('systemctl enable wpa_supplicant@wlan0.service') + os.system('systemctl stop wpa_supplicant@ap0.service') + os.system('sleep 5') os.system('systemctl start wpa_supplicant@wlan0.service') if __name__ == '__main__': - app.run(host = '0.0.0.0', port = '88') + app.run(host = '172.16.127.1', port = '88') diff --git a/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/cancelled_wifi.html b/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/cancelled_wifi.html index ceb64a86..0b490b57 100644 --- a/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/cancelled_wifi.html +++ b/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/cancelled_wifi.html @@ -2,7 +2,7 @@ {% block body %}
-

Wifi connection skipped for now

-

Your device will now reboot without wifi.

+

Wifi connection cancelled

+

You can close this window now and reconnect again to your normal wifi network.

{% endblock %} diff --git a/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/hotspot.html b/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/hotspot.html index a6ae476c..e5f8b003 100644 --- a/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/hotspot.html +++ b/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/hotspot.html @@ -7,8 +7,8 @@ 2.0 1.0 1.0 -MycroftOS-WiFiSetup Configuration -MycroftOS-WiFiSetup +MYCROFT +MYCROFT http://172.16.127.1:88/ diff --git a/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/layout.html b/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/layout.html index 2b38b80d..b108c34a 100644 --- a/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/layout.html +++ b/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/layout.html @@ -6,7 +6,7 @@ - MycroftOS-WiFiSetup + MYCROFT {% block body %} diff --git a/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/save_credentials.html b/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/save_credentials.html index 27ea1c12..66d037f8 100644 --- a/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/save_credentials.html +++ b/buildroot-external/board/raspberrypi/rootfs-overlay/opt/mycroft/wifisetup/templates/save_credentials.html @@ -4,6 +4,7 @@

Wifi connection configured for:

{{ ssid }} -

Your device will now reboot and should be connected to your access point soon.

+

Your device will now reconfigure and connect to your access point.

+

You can close this window now and reconnect again to your normal wifi network.

{% endblock %} diff --git a/buildroot-external/package/wifi-ap/dnsmasq.service b/buildroot-external/package/wifi-ap/dnsmasq.service index 24dffc80..f66611ce 100644 --- a/buildroot-external/package/wifi-ap/dnsmasq.service +++ b/buildroot-external/package/wifi-ap/dnsmasq.service @@ -5,10 +5,6 @@ After=sys-subsystem-net-devices-ap0.device Before=network.target Wants=network.target -# check existence of configuration file -ConditionPathExists= /etc/wpa_supplicant/wpa_supplicant-ap0.conf -ConditionPathExists=!/etc/wpa_supplicant/wpa_supplicant-wlan0.conf - [Service] ExecStart=/usr/sbin/dnsmasq -k --conf-file=/etc/dnsmasq.conf ExecReload=/bin/kill -HUP $MAINPID diff --git a/buildroot-external/package/wifi-ap/iptables.service b/buildroot-external/package/wifi-ap/iptables.service deleted file mode 100644 index 339bc906..00000000 --- a/buildroot-external/package/wifi-ap/iptables.service +++ /dev/null @@ -1,18 +0,0 @@ -[Unit] -Description=Packet Filtering Framework -Before=network-pre.target -Wants=network-pre.target - -# check existence of configuration file -ConditionPathExists= /etc/wpa_supplicant/wpa_supplicant-ap0.conf -ConditionPathExists=!/etc/wpa_supplicant/wpa_supplicant-wlan0.conf - -[Service] -Type=oneshot -ExecStart=/sbin/iptables-restore /etc/iptables.rules -ExecReload=/sbin/iptables-restore /etc/iptables.rules -ExecStop=/usr/lib/systemd/scripts/iptables-flush -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target diff --git a/buildroot-external/package/wifi-ap/nginx.service b/buildroot-external/package/wifi-ap/nginx.service index 1b0f0681..c6c730ec 100644 --- a/buildroot-external/package/wifi-ap/nginx.service +++ b/buildroot-external/package/wifi-ap/nginx.service @@ -1,16 +1,13 @@ [Unit] Description=A high performance web server and a reverse proxy server BindsTo=sys-subsystem-net-devices-ap0.device -After=sys-subsystem-net-devices-ap0.device syslog.target network.target - -# check existence of configuration file -ConditionPathExists= /etc/wpa_supplicant/wpa_supplicant-ap0.conf -ConditionPathExists=!/etc/wpa_supplicant/wpa_supplicant-wlan0.conf +After=sys-subsystem-net-devices-ap0.device wpa_supplicant@ap0.service [Service] Type=forking PIDFile=/var/run/nginx.pid ExecStartPre=/usr/bin/mkdir -p /var/log/nginx /var/tmp/nginx +ExecStartPre=/usr/bin/sleep 5 ExecStartPre=/usr/sbin/nginx -t -q -g 'pid /var/run/nginx.pid; daemon on; master_process on;' ExecStart=/usr/sbin/nginx -g 'pid /var/run/nginx.pid; daemon on; master_process on;' ExecReload=/usr/sbin/nginx -g 'pid /var/run/nginx.pid; daemon on; master_process on;' -s reload @@ -18,4 +15,4 @@ ExecStop=/usr/sbin/nginx -g 'pid /var/run/nginx.pid;' -s quit PrivateDevices=yes [Install] -WantedBy=multi-user.target +WantedBy=wpa_supplicant@ap0.service diff --git a/buildroot-external/package/wifi-ap/wifi-ap.mk b/buildroot-external/package/wifi-ap/wifi-ap.mk index daf3423f..1ce26407 100644 --- a/buildroot-external/package/wifi-ap/wifi-ap.mk +++ b/buildroot-external/package/wifi-ap/wifi-ap.mk @@ -17,18 +17,15 @@ define WIFI_AP_INSTALL_TARGET_CMDS $(INSTALL) -D -m 644 $(@D)/wpa_supplicant@ap0.service \ $(TARGET_DIR)/usr/lib/systemd/system/wpa_supplicant@ap0.service - + $(INSTALL) -D -m 644 $(@D)/wifi-setup.service \ $(TARGET_DIR)/usr/lib/systemd/system/wifi-setup.service - + $(INSTALL) -D -m 644 $(@D)/dnsmasq.service \ $(TARGET_DIR)/usr/lib/systemd/system/dnsmasq.service - + $(INSTALL) -D -m 644 $(@D)/nginx.service \ $(TARGET_DIR)/usr/lib/systemd/system/nginx.service - - $(INSTALL) -D -m 644 $(@D)/iptables.service \ - $(TARGET_DIR)/usr/lib/systemd/system/iptables.service endef $(eval $(generic-package)) diff --git a/buildroot-external/package/wifi-ap/wifi-setup.service b/buildroot-external/package/wifi-ap/wifi-setup.service index d4d7fc5c..4a14c5aa 100644 --- a/buildroot-external/package/wifi-ap/wifi-setup.service +++ b/buildroot-external/package/wifi-ap/wifi-setup.service @@ -2,7 +2,6 @@ Description=MycroftOS WiFi Setup - webbased configurator After=wpa_supplicant@ap0.service Wants=wpa_supplicant@ap0.service -Conflicts=wpa_supplicant@wlan0.service Before=network.target Wants=network.target @@ -12,4 +11,4 @@ WorkingDirectory=/opt/mycroft/wifisetup ExecStart=/usr/bin/python3 app.py > /dev/null 2>&1 [Install] -WantedBy=multi-user.target +WantedBy=wpa_supplicant@ap0.service diff --git a/buildroot-external/package/wifi-ap/wpa_supplicant@ap0.service b/buildroot-external/package/wifi-ap/wpa_supplicant@ap0.service index cdb3e5db..3978b42c 100644 --- a/buildroot-external/package/wifi-ap/wpa_supplicant@ap0.service +++ b/buildroot-external/package/wifi-ap/wpa_supplicant@ap0.service @@ -6,8 +6,6 @@ Conflicts=wpa_supplicant@wlan0.service Before=network.target Wants=network.target -# NetworkManager users will probably want the dbus version instead. - [Service] Type=simple ExecStartPre=/usr/sbin/iw dev wlan0 interface add ap0 type __ap