Skip to content

Commit

Permalink
Initial commit to add a WPA encryption option to the hotspot while in…
Browse files Browse the repository at this point in the history
… Configuration Mode
  • Loading branch information
jasbur committed Dec 30, 2018
1 parent 5c4c306 commit 07deb09
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 5 additions & 1 deletion initial_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ")
Expand All @@ -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()
Expand Down
7 changes: 6 additions & 1 deletion libs/reset_device/static_files/hostapd.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
interface=wlan0
driver=nl80211
ssid=temp-ssid
channel=1
channel=1
#auth_algs=1
#wpa=2
#wpa_key_mgmt=WPA-PSK
#rsn_pairwise=CCMP
#wpa_passphrase=somepassword
8 changes: 7 additions & 1 deletion setup_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "":
Expand Down

0 comments on commit 07deb09

Please sign in to comment.