update wb-rule

This commit is contained in:
vvzvlad 2023-04-17 15:22:39 +07:00
parent 84b591be38
commit c43559caed

View File

@ -60,15 +60,11 @@ function _update_vestasync() {
} }
}); });
runShellCommand("systemctl is-enabled pushgit_inotify.service", { runShellCommand("systemctl is-active pushgit_inotify.service", {
captureOutput: true, captureOutput: true,
exitCallback: function (exitCode, capturedOutput) { exitCallback: function (exitCode, capturedOutput) {
if (exitCode === 0) { var isEnabled = capturedOutput.trim() === "active";
var isEnabled = capturedOutput.trim() === "enabled";
dev.vestasync.autopush = isEnabled; dev.vestasync.autopush = isEnabled;
} else {
log("Error checking autopush status:" + capturedOutput + exitCode);
}
} }
}); });
@ -91,15 +87,15 @@ defineRule("_vestasync_autopush", {
whenChanged: "vestasync/autopush", whenChanged: "vestasync/autopush",
then: function (newValue, devName, cellName) { then: function (newValue, devName, cellName) {
if (dev.vestasync.autopush) { if (dev.vestasync.autopush) {
runShellCommand("systemctl start pushgit_inotify.service"); runShellCommand("systemctl daemon-reload ; systemctl enable pushgit_inotify.service ; systemctl start pushgit_inotify.service");
} else { } else {
runShellCommand("systemctl stop pushgit_inotify.service"); runShellCommand("systemctl stop pushgit_inotify.service ; systemctl disable pushgit_inotify.service");
} }
} }
}); });
_update_vestasync(); _update_vestasync();
setInterval(_update_vestasync, 10000); setInterval(_update_vestasync, 11000);