#285: Enhance output reboot.php/startupdates.php

This commit is contained in:
Ulrich Block 2014-01-23 08:41:13 +01:00
parent dce727fd9c
commit 0641fac5b6
2 changed files with 61 additions and 29 deletions

View File

@ -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);
}
}

View File

@ -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()");