Merge branch 'task/config-reboot-cmd'

This commit is contained in:
Jeroen De Meerleer 2019-04-26 17:01:23 +02:00
commit 619d0705ba
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
5 changed files with 15 additions and 6 deletions

View File

@ -40,8 +40,8 @@ INSERT INTO `config` (`conf`, `category`, `type`, `label`, `description`, `value
('dbclean.expireruns', 'Database Cleanup', 'number(0)', 'Retention', 'How many days does the database keep the runs', '30'),
('dbclean.enabled', 'Database Cleanup', 'text', 'Enabled', 'Database cleanup enabled? (true: yes; false: no)', 'false'),
('dbclean.lastrun', 'Database Cleanup', 'hidden', 'Last run', 'Last run of database cleanup', UNIX_TIMESTAMP()),
('jobs.reboottime', 'Jobs', 'number(0,30)', 'Reboot delay', 'Time to wait until a reboot should be finished', '5');
('jobs.rebootwait', 'Jobs', 'number(0,30)', 'Reboot delay', 'The amount of delay in minutes between scheduling a reboot and the actual reboot', '5');
('jobs.reboottime', 'Jobs', 'number(0)', 'Reboot time', 'The amount of time in seconds for the systems to perform a reboot', '300'),
('jobs.rebootwait', 'Jobs', 'number(0)', 'Reboot wait', 'The amount of time in seconds between scheduling a reboot and the actual reboot', '300'),
('master.crashtimeout', 'Master script', 'number()', 'Master script crash timeout', 'The amount of time in seconds after we can assume the master script is crashed', '3600');
-- --------------------------------------------------------

View File

@ -46,11 +46,16 @@ $(document).ready(function() {
$('#resultmodal').modal('show');
});
});
$("body").on("focusout", "input[name=url]", function() {
if($("input[name=url]").val().startsWith("reboot") !== -1) {
$("body").on("input", "input[name=url]", function() {
if($("input[name=url]").val().startsWith("reboot")) {
$("#url-description").html("This job triggers a reboot. Please use <pre>reboot cmd={{command}}&services={{command}}</pre> to modify the reboot and get services commands. You can use {}+ in the reboot command to use the Reboot wait configuration value");
$("label[for=expected]").html("Capture services after reboot? (1: yes; 0: no)");
$("input[name=expected]").attr("placeholder", "1");
} else {
$("#url-description").html("");
$("label[for=expected]").html("Expected exit code");
$("input[name=expected]").attr("placeholder", "200");
}
});
$("input[name=url]").focusout();
$("input[name=url]").trigger("input");
});

View File

@ -23,6 +23,7 @@
<div class="form-group">
<label for="url">url</label>
<input type="text" name="url" class="form-control" id="url" placeholder="http://example.com/ or 'sudo yum update -y'">
<p class="url-description"></p>
</div>
<div class="form-group">

View File

@ -18,6 +18,7 @@
<div class="form-group">
<label for="url">url</label>
<input type="text" name="url" class="form-control" id="url" placeholder="http://example.com/ or 'sudo yum update -y'" value="{{ url }}">
<p class="url-description"></p>
</div>
<div class="form-group">

View File

@ -132,8 +132,10 @@ if(file_exists("cache/reboot.trigger")) {
$cmd = $rebootcommands['cmd'];
if ($cmd == '') {
$cmd = 'sudo shutdown -r +' . get_configvalue('jobs.rebootwait') . ' "A reboot has been scheduled. Please save your work."';
$cmd = 'sudo shutdown -r -t{}+ "A reboot has been scheduled. Please save your work."';
}
$cmd = str_replace("{}+", get_configvalue('jobs.rebootwait'), $cmd);
$url = "ssh " . $job['host'] . " '" . $cmd . "'";
exec($url);
$cmd = '';