summaryrefslogtreecommitdiff
path: root/boot/app/cgi-bin
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-05-27 19:02:15 -0700
committerschneefux <schneefux+commit@schneefux.xyz>2014-05-27 19:02:15 -0700
commit6564ee46c48cccd9d8947fea2fa570389f1646e9 (patch)
tree646aec89cb9a90dfe6df853fc601d3c087d7c069 /boot/app/cgi-bin
parent0e1762970b4c3cc938012d7644b70ec5e8ccf947 (diff)
parent38258b6033869da653e6568195c5c870cbf4ddd5 (diff)
downloadjasper-client-6564ee46c48cccd9d8947fea2fa570389f1646e9.tar.gz
jasper-client-6564ee46c48cccd9d8947fea2fa570389f1646e9.zip
Merge branch 'master' of https://github.com/jasperproject/jasper-client
Diffstat (limited to 'boot/app/cgi-bin')
-rwxr-xr-xboot/app/cgi-bin/index.cgi42
-rwxr-xr-xboot/app/cgi-bin/wifi.py60
2 files changed, 0 insertions, 102 deletions
diff --git a/boot/app/cgi-bin/index.cgi b/boot/app/cgi-bin/index.cgi
deleted file mode 100755
index bcb85b5..0000000
--- a/boot/app/cgi-bin/index.cgi
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env python
-
-from wifi import *
-import os
-import cgi
-import cgitb; cgitb.enable() # for troubleshooting
-
-# some housekeeping
-print "Content-type: text/html"
-print
-
-# get the form input
-form = cgi.FieldStorage()
-network = form.getvalue("network", "")
-password = form.getvalue("password", "")
-
-# if not submitted yet, show them the network selection form
-if not network:
-
- wifi = Wifi()
-
- networks = [x.replace("\n","") for x in wifi.access_points if x.replace("\n","") != "Jasper"]
- select_code_split = ["<option value=\"%s\">%s</option>" % (network, network) for network in networks]
- select_code = "".join(select_code_split)
-
- response = open("index-template.html","r").read().replace("{{ select_code }}", select_code)
- print response
-
-# otherwise, show them the password form
-elif not password:
- response = open("key-template.html","r").read().replace("{{ network }}", cgi.escape(network))
- print response
-
-# in the final case, process the wifi password and network data
-else:
- # show the confirmation page
- response = open("connecting-template.html","r").read()
- print response
-
- # save the configuration
- wifi = Wifi()
- wifi.add_wifi(network, password) \ No newline at end of file
diff --git a/boot/app/cgi-bin/wifi.py b/boot/app/cgi-bin/wifi.py
deleted file mode 100755
index 5cede72..0000000
--- a/boot/app/cgi-bin/wifi.py
+++ /dev/null
@@ -1,60 +0,0 @@
-import yaml
-import os, subprocess
-
-class Wifi:
-
- access_points = []
-
- def __init__(self):
-
- subprocess.call("iwlist wlan0 scan > temp.txt", shell = True)
- output = open("temp.txt")
- lines = output.readlines()
-
- for index, line in enumerate(lines):
-
- if "Address" in line:
-
- address = line[29:-1]
- name = lines[index + 1].split("\"")[1]
- self.access_points.append(name)
-
- self.access_points = list(set(self.access_points))
-
- os.system("rm temp.txt")
-
- def add_wifi(self, SSID, KEY=""):
- networks = yaml.safe_load(open("../networks.yml", "r"))
-
- # add new network to front of list
- network = {"SSID": SSID, "KEY": KEY}
- networks.insert(0, network)
-
- with open('../networks.yml', 'w') as outputFile:
- output = yaml.dump(networks)
- outputFile.write(output)
-
- def set_default_wifi(self, SSID, KEY=""):
-
- text = open("connect.txt", "r").read()
- text = text.replace("{{ SSID }}", SSID)
- text = text.replace("{{ KEY }}", KEY)
-
- outputFile = open("/etc/network/interfaces", "w")
- outputFile.write(text)
- outputFile.flush()
- outputFile.close()
-
- subprocess.call(["sudo", "/etc/init.d/networking", "restart"])
-
- def setup_adhoc(self):
-
- text = open("broadcast.txt", "r").read()
- outputFile = open("/etc/network/interfaces","w")
- outputFile.write(text)
- outputFile.flush()
- outputFile.close()
-
- subprocess.call(["sudo", "/etc/init.d/networking", "restart"])
- subprocess.call(['sudo', '/usr/sbin/dhcpd', '-q', '-cf', '/etc/dhcp/dhcpd.conf', '-pf', '/var/run/dhcpd.pid'])
- subprocess.call(["sudo", "/etc/init.d/networking", "restart"])