luci-mod-network: interfaces.js: issue iface restart via file/exec rpc call
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
6aa4b83f24
commit
c72c78bed9
3 changed files with 5 additions and 21 deletions
|
@ -62,6 +62,7 @@
|
||||||
"/etc/sysupgrade.conf": [ "write" ],
|
"/etc/sysupgrade.conf": [ "write" ],
|
||||||
"/sbin/block": [ "exec" ],
|
"/sbin/block": [ "exec" ],
|
||||||
"/sbin/firstboot": [ "exec" ],
|
"/sbin/firstboot": [ "exec" ],
|
||||||
|
"/sbin/ifup": [ "exec" ],
|
||||||
"/sbin/reboot": [ "exec" ],
|
"/sbin/reboot": [ "exec" ],
|
||||||
"/sbin/sysupgrade": [ "exec" ],
|
"/sbin/sysupgrade": [ "exec" ],
|
||||||
"/sbin/wifi": [ "exec" ],
|
"/sbin/wifi": [ "exec" ],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
'require fs';
|
||||||
'require uci';
|
'require uci';
|
||||||
'require form';
|
'require form';
|
||||||
'require network';
|
'require network';
|
||||||
|
@ -934,11 +935,9 @@ return L.view.extend({
|
||||||
|
|
||||||
if (dsc.getAttribute('reconnect') == '') {
|
if (dsc.getAttribute('reconnect') == '') {
|
||||||
dsc.setAttribute('reconnect', '1');
|
dsc.setAttribute('reconnect', '1');
|
||||||
tasks.push(L.Request.post(
|
tasks.push(fs.exec('/sbin/ifup', [section_ids[i]]).catch(function(e) {
|
||||||
L.url('admin/network/iface_reconnect', section_ids[i]),
|
L.ui.addNotification(null, E('p', e.message));
|
||||||
'token=' + L.env.token,
|
}));
|
||||||
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
|
|
||||||
).catch(function() {}));
|
|
||||||
}
|
}
|
||||||
else if (dsc.getAttribute('disconnect') == '' || dsc.getAttribute('disconnect') == 'force') {
|
else if (dsc.getAttribute('disconnect') == '' || dsc.getAttribute('disconnect') == 'force') {
|
||||||
var force = dsc.getAttribute('disconnect');
|
var force = dsc.getAttribute('disconnect');
|
||||||
|
|
|
@ -36,9 +36,6 @@ function index()
|
||||||
end
|
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 = entry({"admin", "network", "iface_down"}, post("iface_down"), nil)
|
||||||
page.leaf = true
|
page.leaf = true
|
||||||
|
|
||||||
|
@ -86,19 +83,6 @@ function index()
|
||||||
-- end
|
-- end
|
||||||
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 function addr2dev(addr, src)
|
||||||
local ip = require "luci.ip"
|
local ip = require "luci.ip"
|
||||||
local route = ip.route(addr, src)
|
local route = ip.route(addr, src)
|
||||||
|
|
Loading…
Reference in a new issue