summaryrefslogtreecommitdiffhomepage
path: root/applications
diff options
context:
space:
mode:
Diffstat (limited to 'applications')
-rw-r--r--applications/luci-app-adblock/luasrc/controller/adblock.lua10
-rw-r--r--applications/luci-app-adblock/luasrc/model/cbi/adblock/blacklist_tab.lua1
-rw-r--r--applications/luci-app-adblock/luasrc/model/cbi/adblock/configuration_tab.lua1
-rw-r--r--applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua4
-rw-r--r--applications/luci-app-adblock/luasrc/model/cbi/adblock/whitelist_tab.lua1
-rw-r--r--applications/luci-app-attendedsysupgrade/Makefile11
-rw-r--r--applications/luci-app-attendedsysupgrade/luasrc/controller/attendedsysupgrade.lua5
-rw-r--r--applications/luci-app-attendedsysupgrade/luasrc/view/attendedsysupgrade.htm266
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua12
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_delete.lua1
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua5
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_order.lua50
-rw-r--r--applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm2
13 files changed, 318 insertions, 51 deletions
diff --git a/applications/luci-app-adblock/luasrc/controller/adblock.lua b/applications/luci-app-adblock/luasrc/controller/adblock.lua
index 03b9fc20eb..efa99b5b89 100644
--- a/applications/luci-app-adblock/luasrc/controller/adblock.lua
+++ b/applications/luci-app-adblock/luasrc/controller/adblock.lua
@@ -5,7 +5,7 @@ module("luci.controller.adblock", package.seeall)
local fs = require("nixio.fs")
local util = require("luci.util")
-local template = require("luci.template")
+local templ = require("luci.template")
local i18n = require("luci.i18n")
function index()
@@ -19,17 +19,13 @@ function index()
entry({"admin", "services", "adblock", "advanced", "blacklist"}, cbi("adblock/blacklist_tab"), _("Edit Blacklist"), 110).leaf = true
entry({"admin", "services", "adblock", "advanced", "whitelist"}, cbi("adblock/whitelist_tab"), _("Edit Whitelist"), 120).leaf = true
entry({"admin", "services", "adblock", "advanced", "configuration"}, cbi("adblock/configuration_tab"), _("Edit Configuration"), 130).leaf = true
- entry({"admin", "services", "adblock", "advanced", "query"}, call("query"), _("Query domains"), 140).leaf = true
+ entry({"admin", "services", "adblock", "advanced", "query"}, template("adblock/query"), _("Query domains"), 140).leaf = true
entry({"admin", "services", "adblock", "advanced", "result"}, call("queryData"), nil, 150).leaf = true
end
function logread()
local logfile = util.trim(util.exec("logread -e 'adblock'"))
- template.render("adblock/logread", {title = i18n.translate("Adblock Logfile"), content = logfile})
-end
-
-function query()
- template.render("adblock/query", {title = i18n.translate("Adblock Domain Query")})
+ templ.render("adblock/logread", {title = i18n.translate("Adblock Logfile"), content = logfile})
end
function queryData(domain)
diff --git a/applications/luci-app-adblock/luasrc/model/cbi/adblock/blacklist_tab.lua b/applications/luci-app-adblock/luasrc/model/cbi/adblock/blacklist_tab.lua
index 59cd1e80fa..ef70100e4f 100644
--- a/applications/luci-app-adblock/luasrc/model/cbi/adblock/blacklist_tab.lua
+++ b/applications/luci-app-adblock/luasrc/model/cbi/adblock/blacklist_tab.lua
@@ -25,6 +25,7 @@ end
m = SimpleForm("input", nil)
m:append(Template("adblock/config_css"))
+m.submit = translate("Save")
m.reset = false
s = m:section(SimpleSection, nil,
diff --git a/applications/luci-app-adblock/luasrc/model/cbi/adblock/configuration_tab.lua b/applications/luci-app-adblock/luasrc/model/cbi/adblock/configuration_tab.lua
index 1607f1440a..1d89485e79 100644
--- a/applications/luci-app-adblock/luasrc/model/cbi/adblock/configuration_tab.lua
+++ b/applications/luci-app-adblock/luasrc/model/cbi/adblock/configuration_tab.lua
@@ -14,6 +14,7 @@ end
m = SimpleForm("input", nil)
m:append(Template("adblock/config_css"))
+m.submit = translate("Save")
m.reset = false
s = m:section(SimpleSection, nil,
diff --git a/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua b/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua
index 68f9c8897e..aa57014879 100644
--- a/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua
+++ b/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua
@@ -21,6 +21,8 @@ if parse ~= nil then
dnspath = "/var/lib/unbound"
elseif backend == "named" then
dnspath = "/var/lib/bind"
+ elseif backend == "kresd" then
+ dnspath = "/tmp/kresd"
end
end
end
@@ -180,7 +182,7 @@ e2 = e:option(Flag, "adb_forcesrt", translate("Force Overall Sort"),
e2.default = e2.disabled
e2.rmempty = false
-e3 = e:option(Flag, "adb_manmode", translate("Manual mode"),
+e3 = e:option(Flag, "adb_manmode", translate("Manual / Backup mode"),
translate("Do not automatically update blocklists during startup, use blocklist backups instead."))
e3.default = e3.disabled
e3.rmempty = false
diff --git a/applications/luci-app-adblock/luasrc/model/cbi/adblock/whitelist_tab.lua b/applications/luci-app-adblock/luasrc/model/cbi/adblock/whitelist_tab.lua
index 10a593859f..a3659eb469 100644
--- a/applications/luci-app-adblock/luasrc/model/cbi/adblock/whitelist_tab.lua
+++ b/applications/luci-app-adblock/luasrc/model/cbi/adblock/whitelist_tab.lua
@@ -24,6 +24,7 @@ end
m = SimpleForm("input", nil)
m:append(Template("adblock/config_css"))
+m.submit = translate("Save")
m.reset = false
s = m:section(SimpleSection, nil,
diff --git a/applications/luci-app-attendedsysupgrade/Makefile b/applications/luci-app-attendedsysupgrade/Makefile
new file mode 100644
index 0000000000..32992e19df
--- /dev/null
+++ b/applications/luci-app-attendedsysupgrade/Makefile
@@ -0,0 +1,11 @@
+# See /LICENSE for more information.
+# This is free software, licensed under the GNU General Public License v2.
+
+include $(TOPDIR)/rules.mk
+
+LUCI_TITLE:=LuCI support for attended sysupgrades
+LUCI_DEPENDS:=+luci-base +rpcd-mod-attendedsysupgrade
+
+include ../../luci.mk
+
+# call BuildPackage - OpenWrt buildroot signature
diff --git a/applications/luci-app-attendedsysupgrade/luasrc/controller/attendedsysupgrade.lua b/applications/luci-app-attendedsysupgrade/luasrc/controller/attendedsysupgrade.lua
new file mode 100644
index 0000000000..1bd050af66
--- /dev/null
+++ b/applications/luci-app-attendedsysupgrade/luasrc/controller/attendedsysupgrade.lua
@@ -0,0 +1,5 @@
+module("luci.controller.attendedsysupgrade", package.seeall)
+
+function index()
+ entry({"admin", "system", "attended_sysupgrade"}, template("attendedsysupgrade"), _("Attended Sysupgrade"), 1)
+end
diff --git a/applications/luci-app-attendedsysupgrade/luasrc/view/attendedsysupgrade.htm b/applications/luci-app-attendedsysupgrade/luasrc/view/attendedsysupgrade.htm
new file mode 100644
index 0000000000..8bcec3b493
--- /dev/null
+++ b/applications/luci-app-attendedsysupgrade/luasrc/view/attendedsysupgrade.htm
@@ -0,0 +1,266 @@
+<%+header%>
+<h2 name="content"><%:Attended Sysupgrade%></h2>
+<div class="container">
+ <div style="display: none" id="update_info" class="alert-message info">
+ </div>
+ <div style="display: none" id="update_error" class="alert-message danger">
+ </div>
+</div>
+<input class="cbi-button" value="search for updates" onclick="update_request()" type="button" id="update_button">
+
+<script type="text/javascript">
+
+latest_release = "";
+data = {};
+ubus_counter = 1
+origin = document.location.href.replace(location.pathname, "")
+ubus_url = origin + "/ubus/"
+
+// requests to the update server
+function server_request(request_dict, path, callback) {
+ url = data.update_server + "/" + path
+ request_dict.distro = data.release.distribution;
+ request_dict.target = data.release.target.split("\/")[0];
+ request_dict.subtarget = data.release.target.split("\/")[1];
+ request_dict.packages = data.packagelist;
+ var xmlhttp = new XMLHttpRequest();
+ xmlhttp.open("POST", url, true);
+ xmlhttp.setRequestHeader("Content-type", "application/json");
+ xmlhttp.send(JSON.stringify(request_dict));
+ xmlhttp.onerror = function(e) {
+ update_error("update server down")
+ }
+ xmlhttp.addEventListener('load', function(event) {
+ callback(xmlhttp)
+ });
+}
+
+// requests ubus via rpcd
+function ubus_request(command, argument, params, callback) {
+ // perform login if ubus_rpc_session is empty
+ var request_data = '{ "jsonrpc": "2.0", "id": ' + ubus_counter + ', "method": "call", "params": [ "'+ data["ubus_rpc_session"] +'", "' + command + '", "' + argument + '", ' + params + ' ] }'
+ ubus_counter++
+ var xmlhttp = new XMLHttpRequest();
+ xmlhttp.open("POST", ubus_url, true);
+ xmlhttp.setRequestHeader("Content-type", "application/json");
+ xmlhttp.onerror = function(e) {
+ setTimeout(back_online, 5000)
+ }
+ xmlhttp.addEventListener('load', function(event) {
+ if(command === "uci") {
+ ubus_request_callback_uci(xmlhttp, callback)
+ } else {
+ ubus_request_callback(xmlhttp, callback)
+ }
+ });
+ xmlhttp.send(request_data);
+}
+
+// handle ubus_requests, set variables or perform functions
+function ubus_request_callback(response_object, callback) {
+ if(response_object.status === 200) {
+ console.log(callback)
+ if(typeof callback === "string") {
+ response_json = JSON.parse(response_object.responseText).result[1]
+ data[callback] = response_json[callback]
+ } else {
+ callback(response_object)
+ }
+ } else {
+ console.log(respons_object.responseText)
+ }
+}
+
+function ubus_request_callback_uci(response_object, callback) {
+ if(response_object.status === 200) {
+ console.log(callback)
+ response_json = JSON.parse(response_object.responseText).result[1].value
+ data[callback] = response_json
+ } else {
+ console.log(respons_object.responseText)
+ }
+}
+
+// initial setup, get system information
+function setup() {
+ data["ubus_rpc_session"] = "<%=luci.dispatcher.context.authsession%>"
+ ubus_request("packagelist", "list", '{ }', "packagelist")
+ ubus_request("system", "board", '{ }', "release")
+ ubus_request("system", "board", '{ }', "board_name")
+ ubus_request("uci", "get", '{"config": "attendedsysupgrade", "section": "@settings[0]", "option": "update_server"}', "update_server")
+}
+
+// shows notification if update is available
+function update_info(info_output) {
+ document.getElementById("update_info").style.display = "block";
+ document.getElementById("update_info").innerHTML = info_output;
+}
+
+function update_error(error_output) {
+ document.getElementById("update_error").style.display = "block";
+ document.getElementById("update_error").innerHTML = error_output;
+ document.getElementById("update_info").style.display = "None";
+}
+
+// asks server for news updates, actually only based on relesae not packages
+function update_request() {
+ console.log("update_request")
+ request_dict = {}
+ request_dict.version = data.release.version;
+ server_request(request_dict, "update-request", update_request_callback)
+}
+
+function update_request_callback(response_object) {
+ if (response_object.status === 500) {
+ // python crashed
+ update_error("internal server error, please try again later")
+ console.log("update server issue")
+ } else if (response_object.status === 502) {
+ // python part offline
+ update_error("internal server error, please try again later")
+ console.log("update server issue")
+ } else if (response_object.status === 503) {
+ // handle overload
+ update_error("server overloaded, retry in 5 minutes")
+ console.log("server overloaded")
+ setTimeout(update_request, 300000)
+ } else if (response_object.status === 201) {
+ update_info("imagebuilder not ready, please wait")
+ console.log("setting up imagebuilder")
+ setTimeout(update_request, 5000)
+ } else if (response_object.status === 204) {
+ // no updates
+ update_info("no updates available")
+ } else if (response_object.status === 400) {
+ // bad request
+ console.log(response_object.responseText)
+ response_object_content = JSON.parse(response_object.responseText)
+ update_error(response_object_content)
+ } else if (response_object.status === 200) {
+ // new release/updates
+ response_object_content = JSON.parse(response_object.responseText)
+ update_request_200(response_object_content)
+ }
+}
+
+function back_online() {
+ ubus_request("session", "login", '{ }', back_online_callback)
+}
+
+function back_online_callback(response_object) {
+ if (response_object.status != 200) {
+ setTimeout(back_online, 5000)
+ } else {
+ update_info("upgrade successfull!")
+ document.getElementById("update_button").value = "reload page";
+ document.getElementById("update_button").onclick = function() { location.reload(); }
+ }
+
+}
+
+function update_request_200(response_content) {
+ info_output = ""
+ if(response_content.version != undefined) {
+ info_output += "new update available. from " + data.release.version + " to " + response_content.version
+ latest_version = response_content.version;
+ }
+ if(response_content.packages != undefined) {
+ info_output += "package updates available"
+ }
+ update_info(info_output)
+ document.getElementById("update_button").value = "request image";
+ document.getElementById("update_button").onclick = image_request;
+}
+
+// request the image, need merge with update_request
+function image_request() {
+ console.log("image_request")
+ request_dict = {}
+ request_dict.version = latest_version;
+ request_dict.board = data.board_name
+ server_request(request_dict, "/image-request", image_request_handler)
+}
+
+function image_request_handler(response) {
+ if (response.status === 400) {
+ response_content = JSON.parse(response.responseText)
+ update_error(response_content.error)
+ } else if (response.status === 500) {
+ image_request_500()
+ } else if (response.status === 503) {
+ update_error("please wait. server overloaded")
+ // handle overload
+ setTimeout(image_request, 30000)
+ } else if (response.status === 201) {
+ response_content = JSON.parse(response.responseText)
+ if(response_content.queue != undefined) {
+ // in queue
+ update_info("please wait. you are in queue position " + response_content.queue)
+ console.log("queued")
+ } else {
+ update_info("imagebuilder not ready, please wait")
+ console.log("setting up imagebuilder")
+ }
+ setTimeout(image_request, 5000)
+ } else if (response.status === 206) {
+ // building
+ console.log("building")
+ update_info("building image")
+ setTimeout(image_request, 5000)
+ } else if (response.status === 200) {
+ // ready to download
+ response_content = JSON.parse(response.responseText)
+ update_info("image created")
+ document.getElementById("update_button").value = "download and flash"
+ document.getElementById("update_button").onclick = function() {download_image(response_content.url); }
+ }
+}
+
+
+// uploads received blob data to the server using cgi-io
+function upload_image(blob) {
+ var upload_request = new XMLHttpRequest();
+ var form_data = new FormData();
+
+ form_data.append("sessionid", data.ubus_rpc_session)
+ form_data.append("filename", "/tmp/sysupgrade.bin")
+ form_data.append("filemode", 755) // insecure?
+ form_data.append("filedata", blob)
+
+ upload_request.addEventListener('load', function(event) {
+ // this checksum should be parsed
+ document.getElementById("update_info").innerHTML = "flashing... please wait" // show fancy indicator http://www.ajaxload.info/
+ ubus_request("attendedsysupgrade", "sysupgrade", '{ }', 'done');
+ });
+
+ upload_request.addEventListener('error', function(event) {
+ document.getElementById("update_info").innerHTML = "uploading failed, please retry"
+ });
+
+ upload_request.open('POST', origin + '/cgi-bin/cgi-upload');
+ upload_request.send(form_data);
+}
+
+// download image from server once the url was received by image_request
+function download_image(url) {
+ console.log("download_image")
+ document.getElementById("update_button").value = "flashing..."
+ document.getElementById("update_button").disabled = true;
+ var download_request = new XMLHttpRequest();
+ download_request.open("GET", url);
+ download_request.responseType = "arraybuffer";
+
+ download_request.onload = function () {
+ if (this.status === 200) {
+ var blob = new Blob([download_request.response], {type: "application/octet-stream"});
+ upload_image(blob)
+ }
+ };
+ document.getElementById("update_info").innerHTML = "downloading image"
+ download_request.send();
+}
+
+document.onload = setup()
+</script>
+
+<%+footer%>
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua
index 979307e001..3f3f2348a7 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua
@@ -18,7 +18,7 @@ m.hidden = {
device = http.formvalue("device"),
ssid = http.formvalue("ssid"),
wep = http.formvalue("wep"),
- wpa_suites = http.formvalue("wpa_suites"),
+ wpa_suites = http.formvalue("wpa_suites"),
wpa_version = http.formvalue("wpa_version")
}
@@ -45,11 +45,11 @@ end
function wssid.write(self, section, value)
newsection = uci:section("wireless", "wifi-iface", nil, {
- mode = "sta",
- network = trmiface,
- device = m.hidden.device,
- ssid = wssid:formvalue(section),
- disabled = "1"
+ mode = "sta",
+ network = trmiface,
+ device = m.hidden.device,
+ ssid = wssid:formvalue(section),
+ disabled = "1"
})
if (tonumber(m.hidden.wep) or 0) == 1 then
uci:set("wireless", newsection, "encryption", "wep-open")
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_delete.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_delete.lua
index 97ec1ca3ca..0c3cc1865b 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_delete.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_delete.lua
@@ -10,5 +10,4 @@ if cfg ~= nil then
uci:save("wireless")
uci:commit("wireless")
end
-
http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua
index 0bae98460f..b0a77e4865 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua
@@ -21,7 +21,6 @@ local s = uci:get_all("wireless", m.hidden.cfg)
if s ~= nil then
wssid = m:field(Value, "ssid", translate("SSID"))
wssid.default = s.ssid
-
if s.encryption and s.key then
wkey = m:field(Value, "key", translatef("Passphrase (%s)", s.encryption))
wkey.password = true
@@ -33,7 +32,7 @@ if s ~= nil then
end
end
else
- http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
+ m.on_cancel()
end
function wssid.write(self, section, value)
@@ -43,7 +42,7 @@ function wssid.write(self, section, value)
end
uci:save("wireless")
uci:commit("wireless")
- http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
+ m.on_cancel()
end
return m
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_order.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_order.lua
index d53e1f55e5..5b6141e52d 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_order.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_order.lua
@@ -12,40 +12,26 @@ if cfg ~= nil then
local section = ""
local idx = ""
local idx_change = ""
- if dir == "up" then
- uci:foreach("wireless", "wifi-iface", function(s)
- iface = s.network
- if iface == trmiface then
- section = s['.name']
- if cfg == section then
- idx = s['.index']
- else
- idx_change = s['.index']
- end
- if idx ~= "" and idx_change ~= "" and idx_change < idx then
- uci:reorder("wireless", cfg, idx_change)
- idx = ""
- end
+ local changed = ""
+ uci:foreach("wireless", "wifi-iface", function(s)
+ iface = s.network
+ if iface == trmiface then
+ section = s['.name']
+ if cfg == section then
+ idx = s['.index']
+ else
+ idx_change = s['.index']
end
- end)
- elseif dir == "down" then
- uci:foreach("wireless", "wifi-iface", function(s)
- iface = s.network
- if iface == trmiface then
- section = s['.name']
- if cfg == section then
- idx = s['.index']
- else
- idx_change = s['.index']
- end
- if idx ~= "" and idx_change ~= "" and idx_change > idx then
- uci:reorder("wireless", cfg, idx_change)
- idx = ""
- end
+ if (dir == "up" and idx ~= "" and idx_change ~= "" and idx_change < idx) or
+ (dir == "down" and idx ~= "" and idx_change ~= "" and idx_change > idx) then
+ changed = uci:reorder("wireless", cfg, idx_change)
+ idx = ""
end
- end)
+ end
+ end)
+ if changed ~= "" then
+ uci:save("wireless")
+ uci:commit("wireless")
end
- uci:save("wireless")
- uci:commit("wireless")
end
http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm
index f1f26801ce..41c9f5267d 100644
--- a/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm
+++ b/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm
@@ -53,7 +53,7 @@ This is free software, licensed under the Apache License, Version 2.0
<input type="button" class="cbi-button cbi-button-remove" onclick="location.href='<%=url('admin/services/travelmate/wifidelete')%>?cfg=<%=section%>'" title="<%:Delete this Uplink%>" value="<%:Delete%>"/>
</td>
</tr>
-<%
+<%
end
end)
%>