From 834b95629832fc3735756727b6c7cb1826d0e9d8 Mon Sep 17 00:00:00 2001 From: Christian Hofmaier Date: Tue, 16 Mar 2021 20:03:58 +0100 Subject: [rebootcontrol] Handle scheduler overlaps - Overlaps < 5 min are ignored, < 15 triggers reboot - Database: Make 1 line out of 2 --- modules-available/rebootcontrol/hooks/cron.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules-available/rebootcontrol/hooks') diff --git a/modules-available/rebootcontrol/hooks/cron.inc.php b/modules-available/rebootcontrol/hooks/cron.inc.php index 3651c779..9c6cbaaf 100644 --- a/modules-available/rebootcontrol/hooks/cron.inc.php +++ b/modules-available/rebootcontrol/hooks/cron.inc.php @@ -14,10 +14,11 @@ if (in_array((int)date('G'), [6, 7, 9, 12, 15]) && in_array(date('i'), ['00', '0 $now = time(); $res = Database::simpleQuery("SELECT * FROM reboot_scheduler WHERE nextexecution < :now", ['now' => $now]); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $options = json_decode($row['options'], true); // Calculate next_execution for the event. $location = Database::queryFirst("SELECT openingtime FROM `location` WHERE locationid = :lid", array('lid' => $row['locationid'])); - Scheduler::updateSchedule($row['locationid'], $row['action'], $row['options'], $location['openingtime']); + Scheduler::updateSchedule($row['locationid'], $options, $location['openingtime']); if ($row['nextexecution'] + 1200 < $now) continue; @@ -27,10 +28,9 @@ while ($row = $res->fetch(PDO::FETCH_ASSOC)) { settype($machine['locationid'], 'int'); $machines[] = $machine; } - // Options not yet used. - $options = json_decode($row['options']); if ($row['action'] === 'sd') RebootControl::execute($machines, RebootControl::SHUTDOWN, 0); else if ($row['action'] === 'wol') RebootControl::wakeMachines($machines); + else if ($row['action'] === 'rb') RebootControl::execute($machines, RebootControl::REBOOT, 0); } /* -- cgit v1.2.3-55-g7522