Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jasbur committed Jan 21, 2019
1 parent ad69867 commit 03ed7ba
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
4 changes: 2 additions & 2 deletions initial_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
print()
wpa_enabled_choice = input("Would you like WPA encryption enabled on the hotspot \nwhile in Configuration Mode? [y/N]:")
print()
wpa_entered_key = input("What password would you like to for WPA hotspot \naccess (if enabled above) [default: NO PASSWORD]:")
wpa_entered_key = input("What password would you like to for WPA hotspot \naccess (if enabled above, \nMust be at least 8 characters) [default: NO PASSWORD]:")
print()
auto_config_choice = input("Would you like to enable \nauto-reconfiguration mode [y/N]?: ")
print()
Expand All @@ -35,7 +35,7 @@

if(install_ans.lower() == 'y'):
setup_lib.install_prereqs()
setup_lib.copy_configs()
setup_lib.copy_configs(wpa_enabled_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()
Expand Down
9 changes: 0 additions & 9 deletions libs/reset_device/static_files/hostapd.conf

This file was deleted.

4 changes: 4 additions & 0 deletions libs/reset_device/static_files/hostapd.conf.nowpa
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface=wlan0
driver=nl80211
ssid=temp-ssid
channel=1
9 changes: 9 additions & 0 deletions libs/reset_device/static_files/hostapd.conf.wpa
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
interface=wlan0
driver=nl80211
ssid=temp-ssid
channel=1
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=0
2 changes: 2 additions & 0 deletions libs/reset_device/static_files/raspiwifi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ auto_config=0
auto_config_delay=300
ssl_enabled=0
server_port=80
wpa_enabled=0
wpa_key=0
16 changes: 9 additions & 7 deletions setup_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ def install_prereqs():
os.system('pip3 install flask pyopenssl')
os.system('clear')

def copy_configs():
def copy_configs(wpa_enabled_choice):
os.system('mkdir /usr/lib/raspiwifi')
os.system('mkdir /etc/raspiwifi')
os.system('cp -a libs/* /usr/lib/raspiwifi/')
os.system('mv /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf.original')
os.system('rm -f ./tmp/*')
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/hostapd.conf /etc/hostapd/')

if wpa_enabled_choice.lower() == "y":
os.system('cp /usr/lib/raspiwifi/reset_device/static_files/hostapd.conf.wpa /etc/hostapd/hostapd.conf')
else:
os.system('cp /usr/lib/raspiwifi/reset_device/static_files/hostapd.conf.nowpa /etc/hostapd/hostapd.conf')

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('mkdir /etc/cron.raspiwifi')
Expand All @@ -34,11 +39,8 @@ def update_main_config_file(entered_ssid, auto_config_choice, auto_config_delay,
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=' + wpa_entered_key + '/\' /etc/hostapd/hostapd.conf')
os.system('sed -i \'s/wpa_enabled=0/wpa_enabled=1/\' /etc/raspiwifi/raspiwifi.conf')
os.system('sed -i \'s/wpa_key=0/wpa_key=' + wpa_entered_key + '/\' /etc/raspiwifi/raspiwifi.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 03ed7ba

Please sign in to comment.