Updated reboot to include a waiting time as well as a delay.

Synopsis:
Waiting time: The time you have before computer says no
Reboot time: The time the computer needs to perform a reboot. This very variable but somewhat consequent. You'll need to set this a bit longer than expected
This commit is contained in:
Jeroen De Meerleer 2019-04-25 18:34:10 +02:00
parent 33f016316b
commit 00dd5c77aa
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
3 changed files with 12 additions and 10 deletions

View File

@ -40,7 +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.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.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()), ('dbclean.lastrun', 'Database Cleanup', 'hidden', 'Last run', 'Last run of database cleanup', UNIX_TIMESTAMP()),
('jobs.reboottime', '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,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');
('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'); ('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

@ -43,13 +43,14 @@ function load_config_categorized() {
$configCategorized = array(); $configCategorized = array();
$count = 0; $count = 0;
foreach($allConfigResult as $key=>$value) { foreach($allConfigResult as $key=>$value) {
$configCategorized[$value['category']][$count]['conf'] = $value['conf']; if ($value['type'] != "hidden") {
$configCategorized[$value['category']][$count]['value'] = $value['value']; $configCategorized[$value['category']][$count]['conf'] = $value['conf'];
$configCategorized[$value['category']][$count]['label'] = $value['label']; $configCategorized[$value['category']][$count]['value'] = $value['value'];
$configCategorized[$value['category']][$count]['description'] = $value['description']; $configCategorized[$value['category']][$count]['label'] = $value['label'];
$configCategorized[$value['category']][$count]['type'] = parse_config_type($value['type']); $configCategorized[$value['category']][$count]['description'] = $value['description'];
$configCategorized[$value['category']][$count]['type'] = parse_config_type($value['type']);
if ($configCategorized[$value['category']][$count]['type']['type'] != 'hidden') $count++; }
$count++;
} }
// into a easy twig array // into a easy twig array

View File

@ -125,14 +125,14 @@ if(file_exists("cache/reboot.trigger")) {
unlink("cache/reboot.trigger"); unlink("cache/reboot.trigger");
$rebootser = serialize($rebootjobs); $rebootser = serialize($rebootjobs);
file_put_contents("cache/get-services.trigger", $rebootser); file_put_contents("cache/get-services.trigger", $rebootser);
file_put_contents("cache/reboot-time.trigger", time() + (get_configvalue('jobs.reboottime') * 60)); file_put_contents("cache/reboot-time.trigger", time() + ((get_configvalue('jobs.reboottime') + get_configvalue('jobs.rebootwait')) * 60));
$rebooted_hosts = array(); $rebooted_hosts = array();
foreach($rebootjobs as $job) { foreach($rebootjobs as $job) {
parse_str(str_replace("reboot ", "", $job['url']), $rebootcommands); parse_str(str_replace("reboot ", "", $job['url']), $rebootcommands);
$cmd = $rebootcommands['cmd']; $cmd = $rebootcommands['cmd'];
if ($cmd == '') { if ($cmd == '') {
$cmd = 'sudo shutdown -r +' . get_configvalue('jobs.reboottime') . ' "A reboot has been scheduled. Please save your work."'; $cmd = 'sudo shutdown -r +' . get_configvalue('jobs.rebootwait') . ' "A reboot has been scheduled. Please save your work."';
} }
$url = "ssh " . $job['host'] . " '" . $cmd . "'"; $url = "ssh " . $job['host'] . " '" . $cmd . "'";
exec($url); exec($url);