mirror of
https://github.com/easy-wi/developer.git
synced 2025-02-20 11:23:28 +08:00
#17: Partial
This commit is contained in:
parent
948058b5fe
commit
4561a599a3
@ -56,37 +56,57 @@ include(EASYWIDIR . '/stuff/class_masterserver.php');
|
||||
include(EASYWIDIR . '/stuff/keyphrasefile.php');
|
||||
|
||||
if (!isset($ip) or $ui->escaped('SERVER_ADDR', 'server') == $ip or in_array($ip, ipstoarray($rSA['cronjob_ips']))) {
|
||||
|
||||
echo "Start Syncs and Updates loading...\r\n";
|
||||
|
||||
$currentHour = date('G');
|
||||
$currentMinute = (int) date('i');
|
||||
|
||||
$query = $sql->prepare("SELECT `lastUpdateRun` FROM `settings` WHERE `resellerid`=0 LIMIT 1");
|
||||
$query->execute();
|
||||
$lastUpdateRun= (int) $query->fetchColumn();
|
||||
|
||||
$query = $sql->prepare("UPDATE `settings` SET `lastUpdateRun`=? WHERE `resellerid`=0 LIMIT 1");
|
||||
$query->execute(array($currentMinute));
|
||||
|
||||
echo "Checking for servers to be updated and or synced at hour ${currentHour} and between minutes ${lastUpdateRun} and ${currentMinute}\r\n";
|
||||
|
||||
$currentMinute++;
|
||||
if ($lastUpdateRun != null and $lastUpdateRun != 0) $lastUpdateRun--;
|
||||
|
||||
if ($lastUpdateRun != null and $lastUpdateRun != 0) {
|
||||
$lastUpdateRun--;
|
||||
}
|
||||
|
||||
$query = $sql->prepare("SELECT `id` FROM `rserverdata` WHERE `updates`!=3 AND (`alreadyStartedAt` IS NULL OR `alreadyStartedAt`!=?) AND `updateMinute`>? AND `updateMinute`<?");
|
||||
$query2 = $sql->prepare("UPDATE `rserverdata` SET `alreadyStartedAt`=? WHERE `id`=? LIMIT 1");
|
||||
$query->execute(array($currentHour, $lastUpdateRun, ($currentMinute + 1)));
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
$rootServer = new masterServer($row['id'],$aeskey);
|
||||
$rootServer->collectData();
|
||||
echo "Starting updates for ".$rootServer->sship."\r\n";
|
||||
$sshcmd = $rootServer->returnCmds();
|
||||
|
||||
echo "Starting updates for {$rootServer->sship}\r\n";
|
||||
|
||||
if ($rootServer->sshcmd !== null) {
|
||||
$update=ssh2_execute('gs', $row['id'], $rootServer->sshcmd);
|
||||
|
||||
if ($update !== false) {
|
||||
|
||||
$rootServer->setUpdating();
|
||||
|
||||
echo "Updater started for ".$rootServer->sship."\r\n";
|
||||
|
||||
} else {
|
||||
echo "Updating failed for: ".$rootServer->sship."\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
$query2->execute(array($currentHour, $row['id']));
|
||||
|
||||
unset($rootServer);
|
||||
}
|
||||
|
||||
$query = $sql->prepare("UPDATE `settings` SET `lastCronUpdates`=UNIX_TIMESTAMP() WHERE `resellerid`=0 LIMIT 1");
|
||||
$query->execute();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user