mirror of
https://github.com/easy-wi/developer.git
synced 2025-02-20 11:23:28 +08:00
#285: Enhance output reboot.php/startupdates.php
This commit is contained in:
parent
dce727fd9c
commit
0641fac5b6
@ -501,19 +501,31 @@ if (!isset($ip) or $ui->escaped('SERVER_ADDR', 'server') == $ip or in_array($ip,
|
||||
}
|
||||
|
||||
echo "Executing Updates if neccessary\r\n";
|
||||
$query2 = $sql->prepare("SELECT `id` FROM `rserverdata` WHERE `resellerid`=? AND `updates`!=3 AND (`updateMinute`=0 OR `updateMinute` IS NULL)");
|
||||
$query2 = $sql->prepare("SELECT `id`,`updates` FROM `rserverdata` WHERE `resellerid`=? AND (`updateMinute`=0 OR `updateMinute` IS NULL)");
|
||||
$query2->execute(array($resellerid));
|
||||
foreach ($query2->fetchAll(PDO::FETCH_ASSOC) as $row2) {
|
||||
|
||||
$rootServer = new masterServer($row2['id'], $aeskey);
|
||||
|
||||
if ($row2['updates'] == 3) {
|
||||
|
||||
echo "Updates deactivated for: " . $rootServer->sship . "\r\n";
|
||||
|
||||
} else {
|
||||
|
||||
$rootServer->collectData();
|
||||
|
||||
$sshcmd = (4 == $stunde) ? $rootServer->returnCmds('update', 'all') : $rootServer->returnCmds();
|
||||
|
||||
if ($rootServer->sshcmd !== null) {
|
||||
|
||||
echo "Starting updates for ".$rootServer->sship."\r\n";
|
||||
|
||||
if (ssh2_execute('gs', $row2['id'], $rootServer->sshcmd) !== false) {
|
||||
|
||||
$rootServer->setUpdating();
|
||||
|
||||
echo "Updater started for " . $rootServer->sship . "\r\n";
|
||||
|
||||
} else {
|
||||
echo "Updating failed for: " . $rootServer->sship . "\r\n";
|
||||
}
|
||||
@ -521,8 +533,14 @@ if (!isset($ip) or $ui->escaped('SERVER_ADDR', 'server') == $ip or in_array($ip,
|
||||
if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) {
|
||||
print_r($rootServer->sshcmd);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
echo "No updates to be executed for " . $rootServer->sship . "\r\n";
|
||||
}
|
||||
|
||||
$rootServer = null;;
|
||||
}
|
||||
unset($rootServer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,18 +77,25 @@ if (!isset($ip) or $ui->escaped('SERVER_ADDR', 'server') == $ip or in_array($ip,
|
||||
$lastUpdateRun--;
|
||||
}
|
||||
|
||||
$query = $sql->prepare("SELECT `id` FROM `rserverdata` WHERE `updates`!=3 AND (`alreadyStartedAt` IS NULL OR `alreadyStartedAt`!=?) AND `updateMinute`>? AND `updateMinute`<?");
|
||||
$query = $sql->prepare("SELECT `id`,`updates` FROM `rserverdata` WHERE (`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);
|
||||
|
||||
if ($row['updates'] == 3) {
|
||||
|
||||
echo "Updates deactivated for: " . $rootServer->sship . "\r\n";
|
||||
|
||||
} else {
|
||||
|
||||
$rootServer->collectData();
|
||||
$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) {
|
||||
@ -98,13 +105,20 @@ if (!isset($ip) or $ui->escaped('SERVER_ADDR', 'server') == $ip or in_array($ip,
|
||||
echo "Updater started for " . $rootServer->sship . "\r\n";
|
||||
|
||||
} else {
|
||||
|
||||
echo "Updating failed for: " . $rootServer->sship . "\r\n";
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
echo "No updates to be executed for " . $rootServer->sship . "\r\n";
|
||||
}
|
||||
|
||||
$query2->execute(array($currentHour, $row['id']));
|
||||
|
||||
unset($rootServer);
|
||||
$rootServer = null;
|
||||
}
|
||||
}
|
||||
|
||||
$query = $sql->prepare("UPDATE `settings` SET `lastCronUpdates`=UNIX_TIMESTAMP()");
|
||||
|
Loading…
x
Reference in New Issue
Block a user