From 1d34c51fa926f8ac497c30dd23f96e381972b621 Mon Sep 17 00:00:00 2001 From: Emannuel Silva Date: Wed, 7 Nov 2018 21:00:53 -0200 Subject: [PATCH 1/2] implements fix on issue 56 --- libs/configuration_app/app.py | 1 + libs/reset_device/reset_lib.py | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libs/configuration_app/app.py b/libs/configuration_app/app.py index f51553b7..497e4cc5 100644 --- a/libs/configuration_app/app.py +++ b/libs/configuration_app/app.py @@ -76,6 +76,7 @@ def create_wpa_supplicant(ssid, wifi_key): os.system('mv wpa_supplicant.conf.tmp /etc/wpa_supplicant/wpa_supplicant.conf') def set_ap_client_mode(): + os.system('rm -f /etc/raspiwifi/host_mode') os.system('rm /etc/cron.raspiwifi/aphost_bootstrapper') os.system('cp /usr/lib/raspiwifi/reset_device/static_files/apclient_bootstrapper /etc/cron.raspiwifi/') os.system('chmod +x /etc/cron.raspiwifi/apclient_bootstrapper') diff --git a/libs/reset_device/reset_lib.py b/libs/reset_device/reset_lib.py index 5229f035..1923cdfd 100644 --- a/libs/reset_device/reset_lib.py +++ b/libs/reset_device/reset_lib.py @@ -41,15 +41,17 @@ def is_wifi_active(): return wifi_active def reset_to_host_mode(): - os.system('aplay /usr/lib/raspiwifi/reset_device/button_chime.wav') - os.system('rm -f /etc/wpa_supplicant/wpa_supplicant.conf') - os.system('rm -f /home/pi/Projects/RaspiWifi/tmp/*') - os.system('rm /etc/cron.raspiwifi/apclient_bootstrapper') - os.system('cp /usr/lib/raspiwifi/reset_device/static_files/aphost_bootstrapper /etc/cron.raspiwifi/') - os.system('chmod +x /etc/cron.raspiwifi/aphost_bootstrapper') - os.system('mv /etc/dhcpcd.conf /etc/dhcpcd.conf.original') - os.system('cp /usr/lib/raspiwifi/reset_device/static_files/dhcpcd.conf /etc/') - os.system('mv /etc/dnsmasq.conf /etc/dnsmasq.conf.original') - os.system('cp /usr/lib/raspiwifi/reset_device/static_files/dnsmasq.conf /etc/') - os.system('cp /usr/lib/raspiwifi/reset_device/static_files/dhcpcd.conf /etc/') + if not os.path.isfile('/etc/raspiwifi/host_mode'): + os.system('aplay /usr/lib/raspiwifi/reset_device/button_chime.wav') + os.system('rm -f /etc/wpa_supplicant/wpa_supplicant.conf') + os.system('rm -f /home/pi/Projects/RaspiWifi/tmp/*') + os.system('rm /etc/cron.raspiwifi/apclient_bootstrapper') + os.system('cp /usr/lib/raspiwifi/reset_device/static_files/aphost_bootstrapper /etc/cron.raspiwifi/') + os.system('chmod +x /etc/cron.raspiwifi/aphost_bootstrapper') + os.system('mv /etc/dhcpcd.conf /etc/dhcpcd.conf.original') + os.system('cp /usr/lib/raspiwifi/reset_device/static_files/dhcpcd.conf /etc/') + os.system('mv /etc/dnsmasq.conf /etc/dnsmasq.conf.original') + os.system('cp /usr/lib/raspiwifi/reset_device/static_files/dnsmasq.conf /etc/') + os.system('cp /usr/lib/raspiwifi/reset_device/static_files/dhcpcd.conf /etc/') + os.system('touch /etc/raspiwifi/host_mode') os.system('reboot') From 9a1b83e6461f3ae444d181ccfebef2ff8773a66f Mon Sep 17 00:00:00 2001 From: Emannuel Silva Date: Sat, 17 Nov 2018 20:37:41 -0200 Subject: [PATCH 2/2] change initial setup so that /etc/raspiwifi/host_mode is inserted --- setup_lib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup_lib.py b/setup_lib.py index 7bece774..fe0b96a7 100644 --- a/setup_lib.py +++ b/setup_lib.py @@ -28,6 +28,7 @@ def copy_configs(): os.system('echo "# RaspiWiFi Startup" >> /etc/crontab') os.system('echo "@reboot root run-parts /etc/cron.raspiwifi/" >> /etc/crontab') os.system('mv /usr/lib/raspiwifi/reset_device/static_files/raspiwifi.conf /etc/raspiwifi') + os.system('touch /etc/raspiwifi/host_mode') def update_main_config_file(entered_ssid, auto_config_choice, auto_config_delay, ssl_enabled_choice, server_port_choice): if entered_ssid != "":