MycroftOS: Remove old wifi setup files

This commit is contained in:
j1nx 2020-09-17 15:41:13 +02:00
parent ee4be20395
commit c0e74de88e
9 changed files with 0 additions and 390 deletions

View File

@ -1,98 +0,0 @@
from flask import Flask, render_template, request
import subprocess
import os
import time
from threading import Thread
import fileinput
app = Flask(__name__)
app.debug = True
@app.route('/')
def index():
wifi_ap_array = scan_wifi_networks()
return render_template('app.html', wifi_ap_array = wifi_ap_array)
@app.route('/manual_ssid_entry')
def manual_ssid_entry():
return render_template('manual_ssid_entry.html')
@app.route('/save_credentials', methods = ['GET', 'POST'])
def save_credentials():
ssid = request.form['ssid']
wifi_key = request.form['wifi_key']
create_wpa_supplicant(ssid, wifi_key)
# Call reconfigure_device() in a thread otherwise the reconfigure will prevent
# the response from getting to the browser
def sleep_and_reconfigure():
time.sleep(2)
reconfigure_device()
t = Thread(target=sleep_and_reconfigure)
t.start()
return render_template('save_credentials.html', ssid = ssid)
@app.route('/skip_wifi')
def skip_wifi():
# Call reconfigure_device() in a thread otherwise the reconfigure will prevent
# the response from getting to the browser
def sleep_and_reconfigure():
time.sleep(2)
reconfigure_device()
t = Thread(target=sleep_and_reconfigure)
t.start()
return render_template('cancelled_wifi.html')
######## FUNCTIONS ##########
def scan_wifi_networks():
iwlist_raw = subprocess.Popen(['iw', 'dev', 'ap0', 'scan', 'ap-force'], stdout=subprocess.PIPE)
ap_list, err = iwlist_raw.communicate()
ap_array = []
for line in ap_list.decode('utf-8').rsplit('\n'):
if 'SSID' in line:
ap_ssid = line[7:]
if ap_ssid != '':
ap_array.append(ap_ssid)
return ap_array
def create_wpa_supplicant(ssid, wifi_key):
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(' ssid="' + ssid + '"\n')
if wifi_key == '':
temp_conf_file.write(' key_mgmt=NONE\n')
else:
temp_conf_file.write(' psk="' + wifi_key + '"\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 = '172.16.127.1', port = '88')

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

View File

@ -1,192 +0,0 @@
/* General
---------------------------------------------------------*/
*, :after, :before {
box-sizing: border-box;
}
body,
html {
margin:0;
padding:0;
}
body{
background-color: #22A7F0;
margin:0;
color: #2C3E50;
}
div#mainContent{
padding:.3em;
background-color: #22A7F0;
width: 100%;
margin: 0 auto;
text-align: center;
font-size: 2.5rem;
color: #2C3E50;
}
div#mainContent h1 {
margin:0 0 .5em 0;
font-size:2rem;
}
div#mainContent ul{
list-style: none;
margin: 0;
padding: 0;
}
div#mainContent form {
margin-top:-2em;
}
div#wpaStatus{
padding: 4px;
margin: 0 0 10px 0;
width: 250px;
background-color: #928043;
text-align: left;
font-size: .3em;
}
div#wpaStatus a{
color: #fff;
}
label[for=ssid],
label[for=wifi_key]{
font-size:1.9rem;
}
/* Select
---------------------------------------------------------*/
li label {
display:inline-block;
margin: 0.5em 0;
padding: 0.5em 0;
}
li.wifiNetwork {
position: relative;
margin: 0;
}
li.wifiNetwork:after {
content: '▼';
position: absolute;
width: 25px;
color: #22A7F0;
font-weight: bold;
font-size: 1.4rem;
right: 0px;
top: 40%;
border-radius: 3px;
pointer-events: none;
z-index: 2;
}
select.wifiNetworkInputs {
position: relative;
width: 100%;
background: #111;
color: #22A7F0;
border: none;
outline: none;
font-size: 1.5rem;
padding: 1em;
margin: 0;
border-radius: 3px;
cursor: pointer;
height: auto;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.wifiNetworkInputs{
width: 100%;
padding:1em;
font-size: 1.4rem;
color: #2C3E50;
background: #22A7F0;
border:#2C3E50 solid 1px;
}
.wifiConnectButton{
width: 100%;
margin:2em 0;
padding:.5em;
background-color: #5B6984;
font-size: 2rem;
color: #fff;
}
.manualSSIDEntry{
font-size: 1rem;
color: #2C3E50;
}
div#wpaCredentialsForm{
margin: 60px 0 0 0;
}
.wpaEnabledCheckbox{
height: 46px;
width: 46px;
}
div#saveCredentialsOutput{
width: 60%;
margin: 0 0 0 20%;
text-align: center;
font-size: 1.7em;
}
.saveCredentialsSSID{
color: #2C3E50;
font-size: 2em;
}
/* Wifi Icon
---------------------------------------------------------*/
.wifiIcon {
padding: 10px;
}
.wifiIcon, .wifiIcon:before {
display: inline-block;
border: 40px double transparent;
border-top-color: currentColor;
border-radius: 50%;
}
.wifiIcon:before {
content: '';
width: 0; height: 0;
}
/* Desktop
---------------------------------------------------------*/
@media (min-width: 800px) {
div#mainContent h1 {
font-size:4.5rem;
}
div#mainContent {
max-width:768px;
}
li.wifiNetwork:after {
content: '▼';
position: absolute;
width: 50px;
color: #2C3E50;
font-weight: bold;
font-size: 2rem;
right: 0px;
bottom: 50px;
border-radius: 3px;
pointer-events: none;
z-index: 2;
}
}

View File

@ -1,32 +0,0 @@
{% extends 'layout.html' %}
{% block body %}
<div id="mainContent">
<h1>WiFi Setup</h1>
<div class="wifiIcon"></div>
<form action="{{ url_for('save_credentials') }}" method=post>
<ul>
<li><label for="ssid">Select your WiFi network</label></li>
<li class="wifiNetwork">
<select id="ssid" name="ssid", class="wifiNetworkInputs">
{% for ssid in wifi_ap_array %}
<option value='{{ ssid }}'>{{ ssid }}</option>
{% endfor %}
</select>
</li>
<li><a href="{{ url_for('manual_ssid_entry') }}" class="manualSSIDEntry">manual SSID entry -></a></li>
<li><label for="wifi_key">Your Wifi password</label></li>
<li><input type="password" name="wifi_key", class="wifiNetworkInputs"></li>
<input type="submit", class="wifiConnectButton", label="Configure">
<li><a href="{{ url_for('skip_wifi') }}" class="manualSSIDEntry">Skip WiFi Setup -></a></li>
</ul>
</form>
</div>
{% endblock %}

View File

@ -1,8 +0,0 @@
{% extends 'layout.html' %}
{% block body %}
<div id="saveCredentialsOutput">
<p>Wifi connection cancelled</p>
<p>You can close this window now and reconnect again to your normal wifi network.</p>
</div>
{% endblock %}

View File

@ -1,15 +0,0 @@
<!--
<?xml version="1.0" encoding="UTF-8"?>
<WISPAccessGatewayParam xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.wballiance.net/wispr_2_0.xsd">
<Redirect>
<MessageType>100</MessageType>
<ResponseCode>0</ResponseCode>
<VersionHigh>2.0</VersionHigh>
<VersionLow>1.0</VersionLow>
<AccessProcedure>1.0</AccessProcedure>
<AccessLocation>MYCROFT</AccessLocation>
<LocationName>MYCROFT</LocationName>
<LoginURL>http://172.16.127.1:88/</LoginURL>
</Redirect>
</WISPAccessGatewayParam>
-->

View File

@ -1,15 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='stylesheets/app.css') }}">
<title>MYCROFT</title>
</head>
<body>
{% block body %}
{% endblock %}
</body>
</html>

View File

@ -1,20 +0,0 @@
{% extends 'layout.html' %}
{% block body %}
<div id="mainContent">
<h1>WiFi Setup</h1>
<div class="wifiIcon"></div>
<form action="{{ url_for('save_credentials') }}" method=post>
<ul>
<li><label for="ssid">Enter your network SSID:</label></li>
<li><input type="text" name="ssid", class="wifiNetworkInputs"></li>
<li><label for="wifi_key">Your Wifi password</label></li>
<li><input type="password" name="wifi_key", class="wifiNetworkInputs"></li>
<input type="submit", class="wifiConnectButton">
</ul>
</form>
</div>
{% endblock %}

View File

@ -1,10 +0,0 @@
{% extends 'layout.html' %}
{% block body %}
<div id="saveCredentialsOutput">
<p>Wifi connection configured for:</p>
<span class="saveCredentialsSSID">{{ ssid }}</span>
<p>Your device will now reconfigure and connect to your access point.</p>
<p>You can close this window now and reconnect again to your normal wifi network.</p>
</div>
{% endblock %}