summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-system/htdocs
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2020-06-18 15:25:18 +0200
committerRafał Miłecki <rafal@milecki.pl>2020-09-10 17:35:07 +0200
commit96bb528ccce2623a6f3b791d8263b57e878813bc (patch)
treea4799b22d18f996eb56a5c9c2be495a74830dcda /modules/luci-mod-system/htdocs
parent77af092511f31e07b93d8b29935de4671543db7c (diff)
luci-mod-system: use ubus method for reboot
It's more generic & convenient than hardcoding /sbin/reboot executable path. procd provides "reboot" method since 2016. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'modules/luci-mod-system/htdocs')
-rw-r--r--modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js14
1 files changed, 10 insertions, 4 deletions
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');
}