system.crashed == true && system.reason == "reboot"
Not anymore
This commit is contained in:
parent
b410ab18ce
commit
8b6fa405b1
|
@ -36,6 +36,7 @@ touch('cache/webcron.lock');
|
|||
* Reboot finalize
|
||||
*/
|
||||
if (file_exists("cache/get-services.trigger")) {
|
||||
if (file_exists("cache/reboot-time.trigger") && file_get_contents("cache/reboot-time.trigger") < time()) {
|
||||
$rebootjobs = unserialize(file_get_contents("cache/get-services.trigger"));
|
||||
$services = array();
|
||||
exec("systemctl list-unit-files | cat", $services);
|
||||
|
@ -55,6 +56,8 @@ if (file_exists("cache/get-services.trigger")) {
|
|||
$nexttime->execute(array($nextrun, $result["jobID"]));
|
||||
}
|
||||
unlink("cache/get-services.trigger");
|
||||
unlink("cache/reboot-time.trigger");
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = $db->query('SELECT jobID, url, delay, nextrun FROM jobs WHERE nextrun < ' . time());
|
||||
|
@ -81,11 +84,13 @@ foreach ($results as $result) {
|
|||
exec($result["url"], $body, $statuscode);
|
||||
$body = implode("\n", $body);
|
||||
} else {
|
||||
if (!file_exists('cache/get-services.trigger')) {
|
||||
$rebootjobs[] = $result['jobID'];
|
||||
touch("cache/reboot.trigger");
|
||||
$nosave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($nosave !== true) {
|
||||
$stmt = $db->prepare("INSERT INTO runs(job, statuscode, result, timestamp) VALUES(?, ?, ?, ?)");
|
||||
$stmt->execute(array($result['jobID'], $statuscode, $body, time()));
|
||||
|
@ -105,6 +110,7 @@ if(file_exists("cache/reboot.trigger")) {
|
|||
unlink("cache/reboot.trigger");
|
||||
$rebootser = serialize($rebootjobs);
|
||||
file_put_contents("cache/get-services.trigger", $rebootser);
|
||||
exec("systemctl reboot");
|
||||
file_put_contents("cache/reboot-time.trigger", time() + (5 * 60));
|
||||
exec('sudo shutdown -r +5 "A reboot has been scheduled. Please save your work."');
|
||||
}
|
||||
require_once 'include/finalize.inc.php';
|
||||
|
|
Loading…
Reference in New Issue