From 96bb528ccce2623a6f3b791d8263b57e878813bc Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Thu, 18 Jun 2020 15:25:18 +0200 Subject: luci-mod-system: use ubus method for reboot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's more generic & convenient than hardcoding /sbin/reboot executable path. procd provides "reboot" method since 2016. Signed-off-by: Rafał Miłecki --- .../htdocs/luci-static/resources/view/system/reboot.js | 14 ++++++++++---- .../root/usr/share/rpcd/acl.d/luci-mod-system.json | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js index 3b9f450fcd..92e1dd4920 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js @@ -1,9 +1,15 @@ 'use strict'; 'require view'; -'require fs'; +'require rpc'; 'require ui'; 'require uci'; +var callReboot = rpc.declare({ + object: 'system', + method: 'reboot', + expect: { result: 0 } +}); + return view.extend({ load: function() { return uci.changes(); @@ -31,9 +37,9 @@ return view.extend({ }, handleReboot: function(ev) { - return fs.exec('/sbin/reboot').then(function(res) { - if (res.code != 0) { - L.ui.addNotification(null, E('p', _('The reboot command failed with code %d').format(res.code))); + return callReboot().then(function(res) { + if (res != 0) { + L.ui.addNotification(null, E('p', _('The reboot command failed with code %d').format(res))); L.raise('Error', 'Reboot failed'); } diff --git a/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json b/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json index b29ddb8f4e..38ff98dee6 100644 --- a/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json +++ b/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json @@ -160,7 +160,8 @@ "/sbin/reboot": [ "exec" ] }, "ubus": { - "file": [ "exec" ] + "file": [ "exec" ], + "system": [ "reboot" ] } } } -- cgit v1.2.3