1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-12 10:31:51 +00:00

Add shutdown app

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-04-23 19:03:36 +02:00
parent 1d8ad58d4e
commit 1272f8a397
4 changed files with 78 additions and 0 deletions

View file

@ -0,0 +1,14 @@
#
# Copyright (C) 2020 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
#
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI Shutdown device app
PKG_LICENSE:=GPLv3
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View file

@ -0,0 +1,41 @@
'use strict';
'require fs';
'require uci';
'require ui';
return L.view.extend({
render: function(changes) {
var body = E([
E('h2', _('Shutdown')),
E('p', {}, _('Shutdown the operating system of your device'))
]);
for (var config in (changes || {})) {
body.appendChild(E('p', { 'class': 'alert-message warning' },
_('Warning: There are unsaved changes that will get lost on shutdown!')));
break;
}
body.appendChild(E('hr'));
body.appendChild(E('button', {
'class': 'cbi-button cbi-button-action important',
'click': ui.createHandlerFn(this, 'handleShutdown')
}, _('Perform shutdown')));
return body;
},
handleShutdown: function(ev) {
return fs.exec('/sbin/poweroff').then(function(res) {
if (res.code != 0) {
L.ui.addNotification(null, E('p', _('The poweroff command failed with code %d').format(res.code)));
L.raise('Error', 'Poweroff failed');
}
})
.catch(function(e) { L.ui.addNotification(null, E('p', e.message)) });
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});

View file

@ -0,0 +1,10 @@
{
"admin/system/shutdown": {
"title": "Shutdown",
"order": 60,
"action": {
"type": "view",
"path": "system/shutdown"
}
}
}

View file

@ -0,0 +1,13 @@
{
"luci-app-shutdown": {
"description": "Allow shutdown the device",
"read": {
"file": {
"/sbin/poweroff": [ "exec" ]
},
"ubus": {
"file": [ "exec" ]
}
}
}
}