From 79b5f46f5bfdf7998e55897b6988ff94b6eb815d Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Fri, 26 Apr 2019 17:01:12 +0200 Subject: [PATCH] Added a reboottime template --- database.sql | 4 ++-- js/site.js | 11 ++++++++--- templates/addjob.html.twig | 1 + templates/editjob.html.twig | 1 + webcron.php | 4 +++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/database.sql b/database.sql index 92467e9..5b4fd20 100644 --- a/database.sql +++ b/database.sql @@ -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'); -- -------------------------------------------------------- diff --git a/js/site.js b/js/site.js index ee82587..1ede0c0 100644 --- a/js/site.js +++ b/js/site.js @@ -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
reboot cmd={{command}}&services={{command}}
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"); }); \ No newline at end of file diff --git a/templates/addjob.html.twig b/templates/addjob.html.twig index 5155944..bee1f2a 100644 --- a/templates/addjob.html.twig +++ b/templates/addjob.html.twig @@ -23,6 +23,7 @@
+

diff --git a/templates/editjob.html.twig b/templates/editjob.html.twig index ec2e94d..a877cdb 100644 --- a/templates/editjob.html.twig +++ b/templates/editjob.html.twig @@ -18,6 +18,7 @@
+

diff --git a/webcron.php b/webcron.php index 0329204..fcfd8d6 100644 --- a/webcron.php +++ b/webcron.php @@ -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 = '';