diff options
author | Simon Rettberg | 2021-03-19 13:54:22 +0100 |
---|---|---|
committer | Simon Rettberg | 2021-03-19 13:54:22 +0100 |
commit | 4c0862efe57fbdaa51a69c8dc39f6fc4ae45fa20 (patch) | |
tree | cf5d472d2bea7a4ba43339bf892db6dad710e51c /modules-available/rebootcontrol/hooks/cron.inc.php | |
parent | [locations] Add permission for openingtimes (diff) | |
download | slx-admin-4c0862efe57fbdaa51a69c8dc39f6fc4ae45fa20.tar.gz slx-admin-4c0862efe57fbdaa51a69c8dc39f6fc4ae45fa20.tar.xz slx-admin-4c0862efe57fbdaa51a69c8dc39f6fc4ae45fa20.zip |
[locations/rebootcontrol] Inherit openingtimes for WOL/shutdown
The opening times schedule is now inherited to child locations, so it's
easy to toggle WOL or shutdown for individual rooms in a building, where
you only have to set the opening times once for the entire building.
As of now, WOL and shutdown settings are *not* inherited to child
locations, as I'm not sure if you always want to inherit those by
default.
Closes #3710
Diffstat (limited to 'modules-available/rebootcontrol/hooks/cron.inc.php')
-rw-r--r-- | modules-available/rebootcontrol/hooks/cron.inc.php | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/modules-available/rebootcontrol/hooks/cron.inc.php b/modules-available/rebootcontrol/hooks/cron.inc.php index c1136c98..8f5c73a0 100644 --- a/modules-available/rebootcontrol/hooks/cron.inc.php +++ b/modules-available/rebootcontrol/hooks/cron.inc.php @@ -11,32 +11,7 @@ if (in_array((int)date('G'), [6, 7, 9, 12, 15]) && in_array(date('i'), ['00', '0 } // CRON for Scheduler -$now = time(); -$res = Database::simpleQuery("SELECT s.locationid, s.action, s.nextexecution, s.options, l.openingtime - FROM reboot_scheduler s - INNER JOIN location l USING (locationid) - WHERE s.nextexecution <= :now", ['now' => $now]); -while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - $options = json_decode($row['options'], true); - - // Calculate next_execution for the event. - Scheduler::updateSchedule($row['locationid'], $options, $row['openingtime']); - - if ($row['nextexecution'] + 1200 < $now) - continue; - - $machines = Database::queryAll("SELECT machineuuid, clientip, macaddr, locationid FROM machine - WHERE locationid = :locid", ['locid' => $row['locationid']]); - if ($row['action'] === Scheduler::SHUTDOWN) { - RebootControl::execute($machines, RebootControl::SHUTDOWN, 0); - } elseif ($row['action'] === Scheduler::WOL) { - RebootControl::wakeMachines($machines); - } elseif ($row['action'] === Scheduler::REBOOT) { - RebootControl::execute($machines, RebootControl::REBOOT, 0); - } else { - EventLog::warning("Invalid action '{$row['action']}' in schedule for location " . $row['locationid']); - } -} +Scheduler::cron(); /* * Client reachability test -- can be disabled |