luci-mod-system: reload crond upon saving crontab

Fixes: #5184
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 8d4ac60f7a)
This commit is contained in:
Jo-Philipp Wich 2021-07-15 11:58:38 +02:00
parent 1d6053ecd9
commit de8bc46aec
2 changed files with 5 additions and 4 deletions

View file

@ -16,6 +16,8 @@ return view.extend({
return fs.write('/etc/crontabs/root', value).then(function(rc) {
document.querySelector('textarea').value = value;
ui.addNotification(null, E('p', _('Contents have been saved.')), 'info');
return fs.exec('/etc/init.d/cron', [ 'reload' ]);
}).catch(function(e) {
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
});
@ -24,9 +26,7 @@ return view.extend({
render: function(crontab) {
return E([
E('h2', _('Scheduled Tasks')),
E('p', { 'class': 'cbi-section-descr' },
_('This is the system crontab in which scheduled tasks can be defined.') +
_('<br/>Note: you need to manually restart the cron service if the crontab file was empty before editing.')),
E('p', { 'class': 'cbi-section-descr' }, _('This is the system crontab in which scheduled tasks can be defined.')),
E('p', {}, E('textarea', { 'style': 'width:100%', 'rows': 10, 'disabled': isReadonlyView }, [ crontab != null ? crontab : '' ]))
]);
},

View file

@ -72,7 +72,8 @@
},
"write": {
"file": {
"/etc/crontabs/root": [ "write" ]
"/etc/crontabs/root": [ "write" ],
"/etc/init.d/cron reload": [ "exec" ]
},
"ubus": {
"file": [ "write" ]