mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
Update readme; remove old files; fix multiple creation of wireless networks; add script to auto-archive important files on wifibox.
This commit is contained in:
parent
8b4d81a7e7
commit
1f4ccb6787
18
src/README
18
src/README
@ -1,17 +1,19 @@
|
|||||||
Installation:
|
Installation:
|
||||||
- place the autowifi directory in /usr/share/lua
|
- place the src directory in /usr/share/lua and name it 'autowifi'
|
||||||
- create a symlink to ext/wfcf in /www/cgi-bin (make sure the file is executable)
|
- create a symlink to ext/wfcf in /www/cgi-bin (make sure the file is executable)
|
||||||
- create a symlink to ext/autowifi.html in /www
|
- create a symlink to admin in /www
|
||||||
- create a symlink to ext/autowifi.css in /www
|
- create a symlink to ext/autowifi_init in /etc/rc.d and name it S18autowifi_init
|
||||||
- create a symlink to ext/autowifi.js in /www
|
- (not necessary) enable init script by calling it with 'enable' argument?
|
||||||
- create a symlink to ext/autowifi_init in /etc/rc.d and name it S19autowifi_init
|
|
||||||
- enable init script by calling it with 'enable' argument?
|
|
||||||
- make sure radio0 in /etc/config/wireless is not disabled
|
- make sure radio0 in /etc/config/wireless is not disabled
|
||||||
|
- the wlan net must also be added to firewall in the lan zone
|
||||||
|
|
||||||
|
== these two items are now handled by the script
|
||||||
- create a wlan network in /etc/config/network as follows <<EOF
|
- create a wlan network in /etc/config/network as follows <<EOF
|
||||||
config interface 'wlan'
|
config interface 'wlan'
|
||||||
option ifname 'radio0'
|
option ifname 'radio0'
|
||||||
option proto 'dhcp'
|
option proto 'dhcp'
|
||||||
EOF
|
EOF
|
||||||
|
NOTE: apparently it should have no ifname (network reload will complain about an unsupported operation)
|
||||||
- HOWEVER in ap mode it should be static with address '192.168.10.1' and netmask '255.255.255.0'
|
- HOWEVER in ap mode it should be static with address '192.168.10.1' and netmask '255.255.255.0'
|
||||||
AND act as dhcp server, add to /etc/config/dhcp <<EOF
|
AND act as dhcp server, add to /etc/config/dhcp <<EOF
|
||||||
config dhcp 'wlan'
|
config dhcp 'wlan'
|
||||||
@ -20,4 +22,6 @@ config dhcp 'wlan'
|
|||||||
option limit '150'
|
option limit '150'
|
||||||
option leasetime '12h'
|
option leasetime '12h'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
== package creation
|
||||||
|
- starting point: http://manoftoday.wordpress.com/2007/10/11/writing-and-compiling-a-simple-program-for-openwrt/
|
||||||
|
@ -1 +1 @@
|
|||||||
/usr/share/lua/autowifi/admin/
|
/usr/share/lua/autowifi/admin
|
34
src/misc/collect-code.sh
Executable file
34
src/misc/collect-code.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
BASE_NAME=d3d-wifibox-backup
|
||||||
|
SRC_PATHS="/etc /root /www/ /usr/share/lua"
|
||||||
|
TEMP_DIR=/tmp
|
||||||
|
TGT_FILE=$BASE_NAME.tar.gz
|
||||||
|
|
||||||
|
if [ -e /www-external ]; then
|
||||||
|
echo "ERROR: switch back /www-regular to /www before running this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $TEMP_DIR
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
echo "ERROR: could not cd to temporary directory ($TEMP_DIR)"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
TGT_DIR=$TEMP_DIR/$BASE_NAME
|
||||||
|
rm -rf $TGT_DIR
|
||||||
|
mkdir -p $TGT_DIR
|
||||||
|
|
||||||
|
for path in $SRC_PATHS; do
|
||||||
|
echo "copying $path -> $TGT_DIR..."
|
||||||
|
cp -a $path $TGT_DIR
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "compressing $TGT_DIR into $BASE_NAME.tar.gz..."
|
||||||
|
tar czf $BASE_NAME.tar.gz $BASE_NAME
|
||||||
|
|
||||||
|
echo "removing staging dir..."
|
||||||
|
rm -rf $TGT_DIR
|
||||||
|
|
||||||
|
echo "done."
|
@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
echo "Content-type: text/plain"
|
|
||||||
echo ""
|
|
||||||
read QUERY_STRING
|
|
||||||
eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i}}')
|
|
||||||
|
|
||||||
#escaped
|
|
||||||
#echo $txtOutput
|
|
||||||
|
|
||||||
#unescaped
|
|
||||||
txtOutput=`uhttpd -d $txtOutput`
|
|
||||||
echo $txtOutput
|
|
@ -1,9 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
echo "Content-type: text/plain"
|
|
||||||
echo ""
|
|
||||||
echo "Sample CGI Output"
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
env
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
@ -1,63 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Doodle3D</title>
|
|
||||||
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function(){
|
|
||||||
$.get("cgi-bin/wifi-scan", function(data) {
|
|
||||||
data = data.split("\n");
|
|
||||||
console.log(data.length);
|
|
||||||
var options = $("#boxNetwork");
|
|
||||||
options.empty();
|
|
||||||
$.each(data, function(index,value) {
|
|
||||||
console.log(value);
|
|
||||||
if (value!="") options.append($("<option />").val(value).text(value));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style type="text/css">
|
|
||||||
body {
|
|
||||||
width: 80%;
|
|
||||||
background-color: #ffe;
|
|
||||||
}
|
|
||||||
|
|
||||||
.catgroup {
|
|
||||||
border: 1px solid black;
|
|
||||||
padding: 0.5em;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
background-color: white;
|
|
||||||
-moz-border-radius: 5px;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cattitle {
|
|
||||||
display: block;
|
|
||||||
margin-left: 3em;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="catgroup">
|
|
||||||
<span class="cattitle">WiFi mode</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="catgroup">
|
|
||||||
<span class="cattitle">Available networks</span>
|
|
||||||
<select id="boxNetwork">
|
|
||||||
<option value="" disabled selected>Scanning for neworks...</option>
|
|
||||||
</select>
|
|
||||||
<input id="txtPassword" placeholder="password" value="" type="password">
|
|
||||||
<input id="btnConnect" type="button" value="Connect">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="catgroup">
|
|
||||||
<span class="cattitle">Known networks</span>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,19 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# avoiding "Device or resource busy" error as per https://forum.openwrt.org/viewtopic.php?pid=121485#p121485
|
|
||||||
# note that iwinfo takes care of this internally
|
|
||||||
|
|
||||||
echo "Content-type: text/plain"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
DEV="${1:-wlan0}"
|
|
||||||
|
|
||||||
ifconfig $DEV down
|
|
||||||
iw dev $DEV interface add scan.$DEV type station
|
|
||||||
ifconfig scan.$DEV up
|
|
||||||
|
|
||||||
iwlist scan.$DEV scan | grep ESSID | cut -c 27- | tr -d '"'
|
|
||||||
|
|
||||||
ifconfig scan.$DEV down
|
|
||||||
iw dev scan.$DEV del
|
|
||||||
ifconfig $DEV up
|
|
@ -1,33 +0,0 @@
|
|||||||
[[1: { ["encryption"] =
|
|
||||||
{ ["enabled"] = true,
|
|
||||||
["auth_algs"] = { } ,
|
|
||||||
["description"] = mixed WPA/WPA2 PSK (TKIP),
|
|
||||||
["wep"] = false,
|
|
||||||
["auth_suites"] =
|
|
||||||
{ [1] = PSK,} ,
|
|
||||||
["wpa"] = 3,
|
|
||||||
["pair_ciphers"] =
|
|
||||||
{ [1] = TKIP,
|
|
||||||
[2] = CCMP,
|
|
||||||
} ,
|
|
||||||
["group_ciphers"] =
|
|
||||||
{ [1] = TKIP,} ,
|
|
||||||
} ,
|
|
||||||
["quality_max"] = 70,
|
|
||||||
["ssid"] = happiesnappie2,
|
|
||||||
["channel"] = 9,
|
|
||||||
["signal"] = -35,
|
|
||||||
["bssid"] = 00:22:6B:EF:BB:99,
|
|
||||||
["mode"] = Master,
|
|
||||||
["quality"] = 70,
|
|
||||||
} ]]
|
|
||||||
|
|
||||||
config wifi-iface
|
|
||||||
option network 'lan'
|
|
||||||
option ssid 'happiesnappie2'
|
|
||||||
option encryption 'psk2'
|
|
||||||
option device 'radio0'
|
|
||||||
option mode 'sta'
|
|
||||||
option bssid '00:22:6B:EF:BB:99'
|
|
||||||
option key 'pr4ppal4trappa'
|
|
||||||
option disabled '1'
|
|
@ -10,6 +10,8 @@ M.WWW_CAPTIVE_PATH = "/usr/share/lua/autowifi/ext/www"
|
|||||||
M.WWW_CAPTIVE_INDICATOR = "/www/.autowifi-inplace"
|
M.WWW_CAPTIVE_INDICATOR = "/www/.autowifi-inplace"
|
||||||
M.WWW_RENAME_NAME = "/www-regular"
|
M.WWW_RENAME_NAME = "/www-regular"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function reloadBit(dlist, itemname)
|
local function reloadBit(dlist, itemname)
|
||||||
if dlist[itemname] == nil then dlist[itemname] = "" end
|
if dlist[itemname] == nil then dlist[itemname] = "" end
|
||||||
if dlist[itemname] == "" then dlist[itemname] = "r"
|
if dlist[itemname] == "" then dlist[itemname] = "r"
|
||||||
@ -24,6 +26,8 @@ local function commitBit(dlist, itemname)
|
|||||||
end
|
end
|
||||||
local function bothBits(dlist, itemname) dlist[itemname] = "b" end
|
local function bothBits(dlist, itemname) dlist[itemname] = "b" end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function M.init(wifiInstance, reloadSilent)
|
function M.init(wifiInstance, reloadSilent)
|
||||||
wifi = wifiInstance
|
wifi = wifiInstance
|
||||||
silent = reloadSilent or false
|
silent = reloadSilent or false
|
||||||
@ -82,10 +86,10 @@ function reconf.wireless_reload(dirtyList) reloadBit(dirtyList, "wireless") end
|
|||||||
--[[ Add wlan interface declaration to /etc/config/network ]]
|
--[[ Add wlan interface declaration to /etc/config/network ]]
|
||||||
function reconf.wifiiface_add(dirtyList)
|
function reconf.wifiiface_add(dirtyList)
|
||||||
uci:set("network", wifi.NET, "interface")
|
uci:set("network", wifi.NET, "interface")
|
||||||
-- uci:set("network", wifi.NET, "proto", "dhcp")
|
|
||||||
commitBit(dirtyList, "network")
|
commitBit(dirtyList, "network")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[ Add/remove access point network ]]
|
--[[ Add/remove access point network ]]
|
||||||
function reconf.apnet_add_noreload(dirtyList) reconf.apnet_add(dirtyList, true) end
|
function reconf.apnet_add_noreload(dirtyList) reconf.apnet_add(dirtyList, true) end
|
||||||
function reconf.apnet_add(dirtyList, noReload)
|
function reconf.apnet_add(dirtyList, noReload)
|
||||||
@ -116,6 +120,7 @@ function reconf.apnet_rm(dirtyList)
|
|||||||
reloadBit(dirtyList, "network"); commitBit(dirtyList, "wireless")
|
reloadBit(dirtyList, "network"); commitBit(dirtyList, "wireless")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[ Switch between wireless static IP and DHCP ]]
|
--[[ Switch between wireless static IP and DHCP ]]
|
||||||
function reconf.staticaddr_add(dirtyList)
|
function reconf.staticaddr_add(dirtyList)
|
||||||
uci:set("network", wifi.NET, "interface")
|
uci:set("network", wifi.NET, "interface")
|
||||||
@ -137,6 +142,7 @@ function reconf.staticaddr_rm(dirtyList)
|
|||||||
bothBits(dirtyList, "network")
|
bothBits(dirtyList, "network")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[ Add/remove DHCP pool for wireless net ]]
|
--[[ Add/remove DHCP pool for wireless net ]]
|
||||||
function reconf.dhcppool_add(dirtyList)
|
function reconf.dhcppool_add(dirtyList)
|
||||||
uci:set("dhcp", wifi.NET, "dhcp") --create section
|
uci:set("dhcp", wifi.NET, "dhcp") --create section
|
||||||
@ -153,6 +159,7 @@ function reconf.dhcppool_rm(dirtyList)
|
|||||||
commitBit(dirtyList, "dhcp"); reloadBit(dirtyList, "dnsmasq")
|
commitBit(dirtyList, "dhcp"); reloadBit(dirtyList, "dnsmasq")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[ Add/remove webserver 404 redirection and denial of dirlisting ]]
|
--[[ Add/remove webserver 404 redirection and denial of dirlisting ]]
|
||||||
function reconf.wwwredir_add(dirtyList)
|
function reconf.wwwredir_add(dirtyList)
|
||||||
uci:set("uhttpd", "main", "error_page", "/admin/autowifi.html")
|
uci:set("uhttpd", "main", "error_page", "/admin/autowifi.html")
|
||||||
@ -165,6 +172,7 @@ function reconf.wwwredir_rm(dirtyList)
|
|||||||
bothBits(dirtyList, "uhttpd")
|
bothBits(dirtyList, "uhttpd")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[ Add/remove redirecton of all DNS requests to self ]]
|
--[[ Add/remove redirecton of all DNS requests to self ]]
|
||||||
function reconf.dnsredir_add(dirtyList)
|
function reconf.dnsredir_add(dirtyList)
|
||||||
local redirText = "/#/" .. wifi.AP_ADDRESS
|
local redirText = "/#/" .. wifi.AP_ADDRESS
|
||||||
@ -183,21 +191,29 @@ function reconf.dnsredir_rm(dirtyList)
|
|||||||
commitBit(dirtyList, "dhcp"); reloadBit(dirtyList, "dnsmasq")
|
commitBit(dirtyList, "dhcp"); reloadBit(dirtyList, "dnsmasq")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--TODO: handle os.rename() return values (nil+msg on error)
|
--TODO: handle os.rename() return values (nil+msg on error)
|
||||||
function reconf.wwwcaptive_add(dirtyList)
|
function reconf.wwwcaptive_add(dirtyList)
|
||||||
if u.exists(M.WWW_CAPTIVE_INDICATOR) then
|
if u.exists(M.WWW_CAPTIVE_INDICATOR) then
|
||||||
return u:logdebug("WWW captive directory already in place, not redoing", false)
|
return u:logdebug("WWW captive directory already in place, not redoing", false)
|
||||||
end
|
end
|
||||||
os.rename("/www", M.WWW_RENAME_NAME)
|
if os.rename("/www", M.WWW_RENAME_NAME) == true then
|
||||||
u.symlink(M.WWW_CAPTIVE_PATH, "/www")
|
u.symlink(M.WWW_CAPTIVE_PATH, "/www")
|
||||||
return true
|
return true
|
||||||
|
else
|
||||||
|
return u:logerror("Could not rename /www to " .. M.WWW_RENAME_NAME)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
function reconf.wwwcaptive_rm(dirtyList)
|
function reconf.wwwcaptive_rm(dirtyList)
|
||||||
if not u.exists(M.WWW_CAPTIVE_INDICATOR) then return u:logdebug("WWW captive directory not in place, not undoing", false) end
|
if not u.exists(M.WWW_CAPTIVE_INDICATOR) then return u:logdebug("WWW captive directory not in place, not undoing", false) end
|
||||||
os.remove("/www")
|
os.remove("/www")
|
||||||
return os.rename(M.WWW_RENAME_NAME, "/www")
|
if os.rename(M.WWW_RENAME_NAME, "/www") ~= true then
|
||||||
|
return u:logerror("Could not rename " .. M.WWW_RENAME_NAME .. " to /www")
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[ Setup/remove NAT reflection to redirect all IPs ]]
|
--[[ Setup/remove NAT reflection to redirect all IPs ]]
|
||||||
function reconf.natreflect_add(dirtyList)
|
function reconf.natreflect_add(dirtyList)
|
||||||
uci:set("firewall", "portalreflect", "redirect");
|
uci:set("firewall", "portalreflect", "redirect");
|
||||||
|
@ -143,6 +143,14 @@ function M.createConfigFromScanInfo(info, passphrase, disabled)
|
|||||||
if passphrase ~= nil then apconfig.key = passphrase end
|
if passphrase ~= nil then apconfig.key = passphrase end
|
||||||
apconfig.disabled = disabled ~= nil and disabled and 1 or 0
|
apconfig.disabled = disabled ~= nil and disabled and 1 or 0
|
||||||
|
|
||||||
|
uci:foreach("wireless", "wifi-iface", function(s)
|
||||||
|
if s.bssid == info.bssid then
|
||||||
|
util:logdebug("removing old wireless config for net '" .. s.ssid .. "(bssid: " .. s.bssid .. ")'")
|
||||||
|
uci:delete("wireless", s[".name"])
|
||||||
|
-- return false --keep looking, just in case multiple entries with this bssid exist
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
local sname = uci:add("wireless", "wifi-iface");
|
local sname = uci:add("wireless", "wifi-iface");
|
||||||
for k, v in pairs(apconfig) do
|
for k, v in pairs(apconfig) do
|
||||||
uci:set("wireless", sname, k, v)
|
uci:set("wireless", sname, k, v)
|
||||||
|
Loading…
Reference in New Issue
Block a user