diff --git a/initial_setup.py b/initial_setup.py index 015fcbe5..5b6c2a1d 100644 --- a/initial_setup.py +++ b/initial_setup.py @@ -17,6 +17,10 @@ print() entered_ssid = input("Would you like to specify an SSID you'd like to use \nfor Host/Configuration mode? [default: RaspiWiFi Setup]: ") print() +wpa_enabled_choice = input("Would you like WPA encryption enabled on the hotspot while in Configuration Mode? [y/N]:") +print() +wpa_entered_key = input("What password would you like to for WPA hotspot access (if enabled above) [default: NO PASSWORD]:") +print() auto_config_choice = input("Would you like to enable \nauto-reconfiguration mode [y/N]?: ") print() auto_config_delay = input("How long of a delay would you like without an active connection \nbefore auto-reconfiguration triggers (seconds)? [default: 300]: ") @@ -32,7 +36,7 @@ if(install_ans.lower() == 'y'): setup_lib.install_prereqs() setup_lib.copy_configs() - setup_lib.update_main_config_file(entered_ssid, auto_config_choice, auto_config_delay, ssl_enabled_choice, server_port_choice) + setup_lib.update_main_config_file(entered_ssid, auto_config_choice, auto_config_delay, ssl_enabled_choice, server_port_choice, wpa_enabled_choice, wpa_entered_key) else: print() print() diff --git a/libs/reset_device/static_files/hostapd.conf b/libs/reset_device/static_files/hostapd.conf index 2613e796..550dd077 100644 --- a/libs/reset_device/static_files/hostapd.conf +++ b/libs/reset_device/static_files/hostapd.conf @@ -1,4 +1,9 @@ interface=wlan0 driver=nl80211 ssid=temp-ssid -channel=1 \ No newline at end of file +channel=1 +#auth_algs=1 +#wpa=2 +#wpa_key_mgmt=WPA-PSK +#rsn_pairwise=CCMP +#wpa_passphrase=somepassword \ No newline at end of file diff --git a/setup_lib.py b/setup_lib.py index fe0b96a7..90cbc774 100644 --- a/setup_lib.py +++ b/setup_lib.py @@ -30,9 +30,15 @@ def copy_configs(): 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): +def update_main_config_file(entered_ssid, auto_config_choice, auto_config_delay, ssl_enabled_choice, server_port_choice, wpa_enabled_choice, wpa_entered_key): if entered_ssid != "": os.system('sed -i \'s/RaspiWiFi Setup/' + entered_ssid + '/\' /etc/raspiwifi/raspiwifi.conf') + if wpa_enabled_choice.lower() == "y": + os.system('sed -i \'s/#auth_algs=1/auth_algs=1/\' /etc/hostapd/hostapd.conf') + os.system('sed -i \'s/#wpa=2/wpa=2/\' /etc/hostapd/hostapd.conf') + os.system('sed -i \'s/#wpa_key_mgmt=WPA-PSK/wpa_key_mgmt=WPA-PSK/\' /etc/hostapd/hostapd.conf') + os.system('sed -i \'s/#rsn_pairwise=CCMP/rsn_pairwise=CCMP/\' /etc/hostapd/hostapd.conf') + os.system('sed -i \'s/#wpa_passphrase=somepassword/wpa_passphrase=somepassword' + wpa_entered_key + '/\' /etc/hostapd/hostapd.conf') if auto_config_choice.lower() == "y": os.system('sed -i \'s/auto_config=0/auto_config=1/\' /etc/raspiwifi/raspiwifi.conf') if auto_config_delay != "":