mirror of
https://github.com/vvzvlad/vestasync.git
synced 2024-12-27 04:31:01 +03:00
update wbrule
This commit is contained in:
parent
12a1d452af
commit
d236b92f23
@ -11,11 +11,21 @@ defineVirtualDevice("vestasync", {
|
|||||||
value: "Update...",
|
value: "Update...",
|
||||||
title: "Last commit hash"
|
title: "Last commit hash"
|
||||||
},
|
},
|
||||||
autopush: {
|
autopush_inotify: {
|
||||||
type: "switch",
|
type: "switch",
|
||||||
value: true,
|
value: false,
|
||||||
title: "Auto push on files changed"
|
title: "Auto push on files changed"
|
||||||
},
|
},
|
||||||
|
autopush_timer: {
|
||||||
|
type: "switch",
|
||||||
|
value: false,
|
||||||
|
title: "Auto push every day"
|
||||||
|
},
|
||||||
|
push_now: {
|
||||||
|
type: "switch",
|
||||||
|
value: false,
|
||||||
|
title: "Commit and push"
|
||||||
|
},
|
||||||
hostname: {
|
hostname: {
|
||||||
type: "text",
|
type: "text",
|
||||||
value: "",
|
value: "",
|
||||||
@ -64,7 +74,15 @@ function _update_vestasync() {
|
|||||||
captureOutput: true,
|
captureOutput: true,
|
||||||
exitCallback: function (exitCode, capturedOutput) {
|
exitCallback: function (exitCode, capturedOutput) {
|
||||||
var isEnabled = capturedOutput.trim() === "active";
|
var isEnabled = capturedOutput.trim() === "active";
|
||||||
dev.vestasync.autopush = isEnabled;
|
dev.vestasync.autopush_inotify = isEnabled;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
runShellCommand("systemctl is-active pushgit.timer", {
|
||||||
|
captureOutput: true,
|
||||||
|
exitCallback: function (exitCode, capturedOutput) {
|
||||||
|
var isEnabled = capturedOutput.trim() === "active";
|
||||||
|
dev.vestasync.autopush_timer = isEnabled;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -82,14 +100,40 @@ function _update_vestasync() {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defineRule("_vestasync_autopush_timer", {
|
||||||
defineRule("_vestasync_autopush", {
|
whenChanged: "vestasync/autopush_timer",
|
||||||
whenChanged: "vestasync/autopush",
|
|
||||||
then: function (newValue, devName, cellName) {
|
then: function (newValue, devName, cellName) {
|
||||||
if (dev.vestasync.autopush) {
|
if (dev.vestasync.autopush_timer) {
|
||||||
runShellCommand("systemctl daemon-reload ; systemctl enable pushgit_inotify.service ; systemctl start pushgit_inotify.service");
|
runShellCommand("systemctl daemon-reload ; systemctl enable pushgit.timer ; systemctl start pushgit.timer; sleep 10");
|
||||||
|
_update_vestasync();
|
||||||
} else {
|
} else {
|
||||||
runShellCommand("systemctl stop pushgit_inotify.service ; systemctl disable pushgit_inotify.service");
|
runShellCommand("systemctl stop pushgit.timer ; systemctl disable pushgit.timer; sleep 10");
|
||||||
|
_update_vestasync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
defineRule("_vestasync_autopush_inotify", {
|
||||||
|
whenChanged: "vestasync/autopush_inotify",
|
||||||
|
then: function (newValue, devName, cellName) {
|
||||||
|
if (dev.vestasync.autopush_inotify) {
|
||||||
|
runShellCommand("systemctl daemon-reload ; systemctl enable pushgit_inotify.service ; systemctl start pushgit_inotify.service; sleep 10");
|
||||||
|
_update_vestasync();
|
||||||
|
} else {
|
||||||
|
runShellCommand("systemctl stop pushgit_inotify.service ; systemctl disable pushgit_inotify.service; sleep 10");
|
||||||
|
_update_vestasync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
defineRule("_vestasync_push", {
|
||||||
|
whenChanged: "vestasync/push_now",
|
||||||
|
then: function (newValue, devName, cellName) {
|
||||||
|
if (dev.vestasync.push_now) {
|
||||||
|
runShellCommand("systemctl start pushgit.service; sleep 2");
|
||||||
|
dev.vestasync.push_now = false;
|
||||||
|
_update_vestasync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user