mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-19 22:16:49 +00:00
aio-interface: allow to manage the community containers via the AIO interface (#6443)
Signed-off-by: Simon L. <szaimen@e.mail.de> Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com>
This commit is contained in:
parent
17ec503bf3
commit
673b1db07e
15 changed files with 220 additions and 205 deletions
12
php/src/Container/CommunityContainer.php
Normal file
12
php/src/Container/CommunityContainer.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace AIO\Container;
|
||||
|
||||
readonly class CommunityContainer {
|
||||
public function __construct(
|
||||
string $id,
|
||||
string $name,
|
||||
string $documentation,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ readonly class ConfigurationController {
|
|||
) {
|
||||
}
|
||||
|
||||
public function SetConfig(Request $request, Response $response, array $args) : Response {
|
||||
public function SetConfig(Request $request, Response $response, array $args): Response {
|
||||
try {
|
||||
if (isset($request->getParsedBody()['domain'])) {
|
||||
$domain = $request->getParsedBody()['domain'] ?? '';
|
||||
|
|
@ -125,6 +125,10 @@ readonly class ConfigurationController {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($request->getParsedBody()['community-form'])) {
|
||||
$this->configurationManager->SetEnabledCommunityContainers($request->getParsedBody()['enabled-community'] ?? []);
|
||||
}
|
||||
|
||||
if (isset($request->getParsedBody()['delete_collabora_dictionaries'])) {
|
||||
$this->configurationManager->DeleteCollaboraDictionaries();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace AIO\Data;
|
||||
|
||||
use AIO\Auth\PasswordGenerator;
|
||||
use AIO\Container\CommunityContainer;
|
||||
use AIO\Controller\DockerController;
|
||||
|
||||
class ConfigurationManager
|
||||
|
|
@ -75,7 +76,7 @@ class ConfigurationManager
|
|||
if (!file_exists(DataConst::GetBackupArchivesList())) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
$content = file_get_contents(DataConst::GetBackupArchivesList());
|
||||
if ($content === '') {
|
||||
return '';
|
||||
|
|
@ -95,7 +96,7 @@ class ConfigurationManager
|
|||
if ($lastBackupTime === "") {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
return $lastBackupTime;
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +104,7 @@ class ConfigurationManager
|
|||
if (!file_exists(DataConst::GetBackupArchivesList())) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
$content = file_get_contents(DataConst::GetBackupArchivesList());
|
||||
if ($content === '') {
|
||||
return [];
|
||||
|
|
@ -114,7 +115,7 @@ class ConfigurationManager
|
|||
foreach($backupLines as $lines) {
|
||||
if ($lines !== "") {
|
||||
$backupTimesTemp = explode(',', $lines);
|
||||
$backupTimes[] = $backupTimesTemp[1];
|
||||
$backupTimes[] = $backupTimesTemp[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +141,7 @@ class ConfigurationManager
|
|||
}
|
||||
}
|
||||
|
||||
public function isClamavEnabled() : bool {
|
||||
public function isClamavEnabled() : bool {
|
||||
$config = $this->GetConfig();
|
||||
if (isset($config['isClamavEnabled']) && $config['isClamavEnabled'] === 1) {
|
||||
return true;
|
||||
|
|
@ -375,7 +376,7 @@ class ConfigurationManager
|
|||
$testUrl = $protocol . $domain . ':443';
|
||||
curl_setopt($ch, CURLOPT_URL, $testUrl);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
$response = (string)curl_exec($ch);
|
||||
# Get rid of trailing \n
|
||||
|
|
@ -474,7 +475,7 @@ class ConfigurationManager
|
|||
} elseif ($location !== '' && $repo !== '') {
|
||||
throw new InvalidSettingConfigurationException("Location and remote repo url are mutually exclusive!");
|
||||
}
|
||||
|
||||
|
||||
if ($location !== '') {
|
||||
$isValidPath = false;
|
||||
if (str_starts_with($location, '/') && !str_ends_with($location, '/')) {
|
||||
|
|
@ -629,7 +630,7 @@ class ConfigurationManager
|
|||
if (!file_exists(DataConst::GetBackupPublicKey())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
return trim(file_get_contents(DataConst::GetBackupPublicKey()));
|
||||
}
|
||||
|
||||
|
|
@ -771,7 +772,7 @@ class ConfigurationManager
|
|||
if (!preg_match("#^[0-1][0-9]:[0-5][0-9]$#", $time) && !preg_match("#^2[0-3]:[0-5][0-9]$#", $time)) {
|
||||
throw new InvalidSettingConfigurationException("You did not enter a correct time! One correct example is '04:00'!");
|
||||
}
|
||||
|
||||
|
||||
if ($enableAutomaticUpdates === false) {
|
||||
$time .= PHP_EOL . 'automaticUpdatesAreNotEnabled';
|
||||
} else {
|
||||
|
|
@ -1008,16 +1009,59 @@ class ConfigurationManager
|
|||
}
|
||||
|
||||
private function GetCommunityContainers() : string {
|
||||
$envVariableName = 'AIO_COMMUNITY_CONTAINERS';
|
||||
$configName = 'aio_community_containers';
|
||||
$defaultValue = '';
|
||||
return $this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue);
|
||||
$config = $this->GetConfig();
|
||||
if(!isset($config['aio_community_containers'])) {
|
||||
$config['aio_community_containers'] = '';
|
||||
}
|
||||
|
||||
return $config['aio_community_containers'];
|
||||
}
|
||||
|
||||
public function GetEnabledCommunityContainers() : array {
|
||||
|
||||
/** @return list<CommunityContainer> */
|
||||
public function listAvailableCommunityContainers() : array {
|
||||
$cc = [];
|
||||
$dir = scandir(DataConst::GetCommunityContainersDirectory());
|
||||
if ($dir === false) {
|
||||
return $cc;
|
||||
}
|
||||
foreach ($dir as $id) {
|
||||
$filePath = DataConst::GetCommunityContainersDirectory() . '/' . $id . '/' . $id . '.json';
|
||||
$fileContents = apcu_fetch($filePath);
|
||||
if (!is_string($fileContents)) {
|
||||
$fileContents = file_get_contents($filePath);
|
||||
if (is_string($fileContents)) {
|
||||
apcu_add($filePath, $fileContents);
|
||||
}
|
||||
}
|
||||
$json = is_string($fileContents) ? json_decode($fileContents) : false;
|
||||
if(is_array($json) && is_array($json['aio_services_v1'])) {
|
||||
foreach ($json['aio_services_v1'] as $service) {
|
||||
$documentation = is_string($service['documentation']) ? $service['documentation'] : '';
|
||||
if (is_string($service['display_name'])) {
|
||||
$cc[] = new CommunityContainer(
|
||||
$id,
|
||||
$service['display_name'],
|
||||
$documentation);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $cc;
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
public function GetEnabledCommunityContainers(): array {
|
||||
return explode(' ', $this->GetCommunityContainers());
|
||||
}
|
||||
|
||||
public function SetEnabledCommunityContainers(array $enabledCommunityContainers) : void {
|
||||
$config = $this->GetConfig();
|
||||
$config['aio_community_containers'] = implode(' ', $enabledCommunityContainers);
|
||||
$this->WriteConfig($config);
|
||||
}
|
||||
|
||||
private function GetEnabledDriDevice() : string {
|
||||
$envVariableName = 'NEXTCLOUD_ENABLE_DRI_DEVICE';
|
||||
$configName = 'nextcloud_enable_dri_device';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue