diff --git a/web/reboot.php b/web/reboot.php index e23a23c7..b1c51e6e 100644 --- a/web/reboot.php +++ b/web/reboot.php @@ -501,28 +501,46 @@ 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); - $rootServer->collectData(); - $sshcmd=(4==$stunde) ? $rootServer->returnCmds('update','all') : $rootServer->returnCmds(); - if ($rootServer->sshcmd !== null) { - echo "Starting updates for ".$rootServer->sship."\r\n"; + $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) { + + + 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"; + } + + if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) { + print_r($rootServer->sshcmd); + } - 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"; + + echo "No updates to be executed for " . $rootServer->sship . "\r\n"; } - if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) { - print_r($rootServer->sshcmd); - } + $rootServer = null;; } - unset($rootServer); } } diff --git a/web/startupdates.php b/web/startupdates.php index b0d440c9..e2ead26d 100644 --- a/web/startupdates.php +++ b/web/startupdates.php @@ -77,34 +77,48 @@ 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`prepare("SELECT `id`,`updates` FROM `rserverdata` WHERE (`alreadyStartedAt` IS NULL OR `alreadyStartedAt`!=?) AND `updateMinute`>? AND `updateMinute`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(); - $sshcmd = $rootServer->returnCmds(); + $rootServer = new masterServer($row['id'], $aeskey); - echo "Starting updates for {$rootServer->sship}\r\n"; + if ($row['updates'] == 3) { - if ($rootServer->sshcmd !== null) { - $update=ssh2_execute('gs', $row['id'], $rootServer->sshcmd); + echo "Updates deactivated for: " . $rootServer->sship . "\r\n"; - if ($update !== false) { + } else { - $rootServer->setUpdating(); + $rootServer->collectData(); + $sshcmd = $rootServer->returnCmds(); - echo "Updater started 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"; + + } } else { - echo "Updating failed for: ".$rootServer->sship."\r\n"; + + echo "No updates to be executed for " . $rootServer->sship . "\r\n"; } + + $query2->execute(array($currentHour, $row['id'])); + + $rootServer = null; } - - $query2->execute(array($currentHour, $row['id'])); - - unset($rootServer); } $query = $sql->prepare("UPDATE `settings` SET `lastCronUpdates`=UNIX_TIMESTAMP()");