Browse Source

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
main
Jeroen De Meerleer 2 years ago
parent
commit
8405599888
3 changed files with 12 additions and 10 deletions
  1. +2
    -1
      database.sql
  2. +8
    -7
      include/functions.php
  3. +2
    -2
      webcron.php

+ 2
- 1
database.sql 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.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', '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');
-- --------------------------------------------------------


+ 8
- 7
include/functions.php View File

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


+ 2
- 2
webcron.php View File

@ -125,14 +125,14 @@ if(file_exists("cache/reboot.trigger")) {
unlink("cache/reboot.trigger");
$rebootser = serialize($rebootjobs);
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();
foreach($rebootjobs as $job) {
parse_str(str_replace("reboot ", "", $job['url']), $rebootcommands);
$cmd = $rebootcommands['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 . "'";
exec($url);


Loading…
Cancel
Save