diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index 19e0d3bb8ec7..49afae6ba266 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -43,10 +43,20 @@ public function GetContainerById(string $id): Container /** * @return array */ - private function GetDefinition(bool $latest): array + private function GetDefinition(): array { $data = json_decode(file_get_contents(__DIR__ . '/../containers.json'), true); + $containerNames = []; + foreach ($this->configurationManager->GetEnabledCommunityContainers() as $communityContainer) { + if ($communityContainer !== '') { + $path = DataConst::GetCommunityContainersDirectory() . $communityContainer . '/' . $communityContainer . '.json'; + $additionalData = json_decode(file_get_contents($path), true); + $data = array_merge_recursive($data, $additionalData); + $containerNames[] = $additionalData['aio_services_v1'][]['container_name']; + } + } + $containers = []; foreach ($data['aio_services_v1'] as $entry) { if ($entry['container_name'] === 'nextcloud-aio-clamav') { @@ -154,7 +164,13 @@ private function GetDefinition(bool $latest): array $dependsOn = []; if (isset($entry['depends_on'])) { - foreach ($entry['depends_on'] as $value) { + $valueDependsOn = $entry['depends_on']; + if ($entry['container_name'] === 'nextcloud-aio-apache') { + foreach ($containerNames as $containerName) { + $valueDependsOn[] = $containerName; + } + } + foreach ($valueDependsOn as $value) { if ($value === 'nextcloud-aio-clamav') { if (!$this->configurationManager->isClamavEnabled()) { continue; @@ -305,35 +321,6 @@ private function GetDefinition(bool $latest): array public function FetchDefinition(): array { - if (!file_exists(DataConst::GetDataDirectory() . '/containers.json')) { - $containers = $this->GetDefinition(true); - } else { - $containers = $this->GetDefinition(false); - } - - $borgBackupMode = $this->configurationManager->GetBorgBackupMode(); - $fetchLatest = false; - - foreach ($containers as $container) { - - if ($container->GetIdentifier() === 'nextcloud-aio-borgbackup') { - if ($container->GetRunningState() === RunningState::class) { - if ($borgBackupMode !== 'backup' && $borgBackupMode !== 'restore') { - $fetchLatest = true; - } - } else { - $fetchLatest = true; - } - - } elseif ($container->GetIdentifier() === 'nextcloud-aio-watchtower' && $container->GetRunningState() === RunningState::class) { - return $containers; - } - } - - if ($fetchLatest === true) { - $containers = $this->GetDefinition(true); - } - - return $containers; + return $this->GetDefinition(); } }