diff options
author | Simon Rettberg | 2021-01-15 11:35:23 +0100 |
---|---|---|
committer | Simon Rettberg | 2021-01-15 11:35:23 +0100 |
commit | 610c174db8504b1b84a2e683874894122de162cc (patch) | |
tree | 67f8ec1208cc4c031c594e146009574c057a73d9 | |
parent | [locationinfo] his: Change error_log to GUI error (diff) | |
download | slx-admin-610c174db8504b1b84a2e683874894122de162cc.tar.gz slx-admin-610c174db8504b1b84a2e683874894122de162cc.tar.xz slx-admin-610c174db8504b1b84a2e683874894122de162cc.zip |
[roomplanner] WOL pvsmgr if tutor machine boots or a user logs in
Closes #3586
-rw-r--r-- | modules-available/roomplanner/hooks/client-update.inc.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/modules-available/roomplanner/hooks/client-update.inc.php b/modules-available/roomplanner/hooks/client-update.inc.php new file mode 100644 index 00000000..a8ffd555 --- /dev/null +++ b/modules-available/roomplanner/hooks/client-update.inc.php @@ -0,0 +1,19 @@ +<?php + +// Either poweron or user logged in +if ($type === '~poweron' || ($type === '~runstate' && $used === 1 && $old['state'] !== 'OCCUPIED')) { + // Get all the clients that are managers for rooms this client is a tutor for. + // Start in the machine table aliased tut, map $ip to client uuid, then look this + // up in the location_roomplan table as tutoruuid, get the according managerip, + // look this one up again in machine table aliased mgr to finally get the according + // mac address of that manager. We need that for WOL. + $managers = Database::queryAll('SELECT mgr.machineuuid, mgr.clientip, mgr.macaddr + FROM machine tut + INNER JOIN location_roomplan lr ON (tut.machineuuid = lr.tutoruuid) + INNER JOIN machine mgr ON (lr.managerip = mgr.clientip) + WHERE tut.clientip = :tutorip', ['tutorip' => $ip]); + if (!empty($managers) && Module::isAvailable('rebootcontrol')) { + // Create WOL job + RebootControl::wakeMachines($managers); + } +}
\ No newline at end of file |