summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-10-31 17:37:55 +0100
committerJo-Philipp Wich <jo@mein.io>2019-11-01 12:03:33 +0100
commitc72c78bed979f2d85a3c71fe8c7ab26aefe8bae2 (patch)
treeb5d37f0ba65b56105b23d5ee9b72d4d67ad1ad3a
parent6aa4b83f2460ff6fe989b39675ce0b001c05ddae (diff)
luci-mod-network: interfaces.js: issue iface restart via file/exec rpc call
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json1
-rw-r--r--modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js9
-rw-r--r--modules/luci-mod-network/luasrc/controller/admin/network.lua16
3 files changed, 5 insertions, 21 deletions
diff --git a/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json b/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json
index cd37f4d49f..098af140da 100644
--- a/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json
+++ b/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json
@@ -62,6 +62,7 @@
"/etc/sysupgrade.conf": [ "write" ],
"/sbin/block": [ "exec" ],
"/sbin/firstboot": [ "exec" ],
+ "/sbin/ifup": [ "exec" ],
"/sbin/reboot": [ "exec" ],
"/sbin/sysupgrade": [ "exec" ],
"/sbin/wifi": [ "exec" ],
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js
index bfff2575bd..60d61adfec 100644
--- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js
+++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js
@@ -1,4 +1,5 @@
'use strict';
+'require fs';
'require uci';
'require form';
'require network';
@@ -934,11 +935,9 @@ return L.view.extend({
if (dsc.getAttribute('reconnect') == '') {
dsc.setAttribute('reconnect', '1');
- tasks.push(L.Request.post(
- L.url('admin/network/iface_reconnect', section_ids[i]),
- 'token=' + L.env.token,
- { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
- ).catch(function() {}));
+ tasks.push(fs.exec('/sbin/ifup', [section_ids[i]]).catch(function(e) {
+ L.ui.addNotification(null, E('p', e.message));
+ }));
}
else if (dsc.getAttribute('disconnect') == '' || dsc.getAttribute('disconnect') == 'force') {
var force = dsc.getAttribute('disconnect');
diff --git a/modules/luci-mod-network/luasrc/controller/admin/network.lua b/modules/luci-mod-network/luasrc/controller/admin/network.lua
index 49ed78a0ea..a2ff215480 100644
--- a/modules/luci-mod-network/luasrc/controller/admin/network.lua
+++ b/modules/luci-mod-network/luasrc/controller/admin/network.lua
@@ -36,9 +36,6 @@ function index()
end
- page = entry({"admin", "network", "iface_reconnect"}, post("iface_reconnect"), nil)
- page.leaf = true
-
page = entry({"admin", "network", "iface_down"}, post("iface_down"), nil)
page.leaf = true
@@ -86,19 +83,6 @@ function index()
-- end
end
-function iface_reconnect(iface)
- local netmd = require "luci.model.network".init()
- local net = netmd:get_network(iface)
- if net then
- luci.sys.call("env -i /sbin/ifup %s >/dev/null 2>/dev/null"
- % luci.util.shellquote(iface))
- luci.http.status(200, "Reconnected")
- return
- end
-
- luci.http.status(404, "No such interface")
-end
-
local function addr2dev(addr, src)
local ip = require "luci.ip"
local route = ip.route(addr, src)