luci-mod-system: reload crond upon saving crontab
authorJo-Philipp Wich <jo@mein.io>
Thu, 15 Jul 2021 09:58:38 +0000 (11:58 +0200)
committerJo-Philipp Wich <jo@mein.io>
Thu, 15 Jul 2021 09:58:38 +0000 (11:58 +0200)
Fixes: #5184
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-system/htdocs/luci-static/resources/view/system/crontab.js
modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json

index 939d41b0ecc0893b5f81a8ebb215b95a361fdace..079921a520e4de59556d682d04a46b6a0dabfabf 100644 (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 : '' ]))
                ]);
        },
index 38ff98dee6efe5abef770d36bc3234b1ee619911..c5f801a264ffa2ba0efa60648ca7c8597d974cff 100644 (file)
@@ -72,7 +72,8 @@
                },
                "write": {
                        "file": {
-                               "/etc/crontabs/root": [ "write" ]
+                               "/etc/crontabs/root": [ "write" ],
+                               "/etc/init.d/cron reload": [ "exec" ]
                        },
                        "ubus": {
                                "file": [ "write" ]