From 05e90d6110dabd2f86958238c26472bd0c87b06d Mon Sep 17 00:00:00 2001 From: szaimen Date: Wed, 17 Aug 2022 15:09:22 +0200 Subject: [PATCH] add imaginary Signed-off-by: szaimen --- .github/dependabot.yml | 9 +++++++ Containers/imaginary/Dockerfile | 2 ++ Containers/nextcloud/entrypoint.sh | 11 +++++++++ php/containers.json | 24 +++++++++++++++++-- php/public/disable-imaginary.js | 5 ++++ php/public/index.php | 1 + php/public/options-form-submit.js | 4 ++++ php/src/ContainerDefinitionFetcher.php | 8 +++++++ .../Controller/ConfigurationController.php | 5 ++++ php/src/Data/ConfigurationManager.php | 15 ++++++++++++ php/src/Docker/DockerActionManager.php | 6 +++++ php/templates/containers.twig | 6 +++++ readme.md | 1 + 13 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 Containers/imaginary/Dockerfile create mode 100644 php/public/disable-imaginary.js diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e9c51c11c0d..d61aead1db0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -135,3 +135,12 @@ updates: labels: - 3. to review - dependencies +- package-ecosystem: "docker" + directory: "/Containers/imaginary" + schedule: + interval: "daily" + time: "12:00" + open-pull-requests-limit: 10 + labels: + - 3. to review + - dependencies diff --git a/Containers/imaginary/Dockerfile b/Containers/imaginary/Dockerfile new file mode 100644 index 00000000000..baed1b8150b --- /dev/null +++ b/Containers/imaginary/Dockerfile @@ -0,0 +1,2 @@ +# From https://github.com/h2non/imaginary/blob/master/Dockerfile +FROM nextcloud/imaginary:20220819 diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index c1c4b7e4efe..993cb7a74b2 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -407,5 +407,16 @@ else fi fi +# Imaginary +if version_greater "24.0.0.0" "$installed_version"; then + if [ "$IMAGINARY_ENABLED" = 'yes' ]; then + php /var/www/html/occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\Imaginary" + php /var/www/html/occ config:system:set preview_imaginary_url --value="http://$IMAGINARY_HOST:9000" + else + php /var/www/html/occ config:system:delete enabledPreviewProviders 0 + php /var/www/html/occ config:system:delete preview_imaginary_url + fi +fi + # Remove the update skip file always rm -f /mnt/ncdata/skip.update diff --git a/php/containers.json b/php/containers.json index 105eb618cc5..2570348ca64 100644 --- a/php/containers.json +++ b/php/containers.json @@ -80,7 +80,8 @@ "identifier": "nextcloud-aio-nextcloud", "dependsOn": [ "nextcloud-aio-database", - "nextcloud-aio-redis" + "nextcloud-aio-redis", + "nextcloud-aio-imaginary" ], "displayName": "Nextcloud", "containerName": "nextcloud/aio-nextcloud", @@ -140,7 +141,9 @@ "ONLYOFFICE_HOST=nextcloud-aio-onlyoffice", "UPDATE_NEXTCLOUD_APPS=%UPDATE_NEXTCLOUD_APPS%", "TZ=%TIMEZONE%", - "TALK_PORT=%TALK_PORT%" + "TALK_PORT=%TALK_PORT%", + "IMAGINARY_ENABLED=%IMAGINARY_ENABLED%", + "IMAGINARY_HOST=nextcloud-aio-imaginary" ], "maxShutdownTime": 10, "restartPolicy": "unless-stopped" @@ -367,6 +370,23 @@ ], "maxShutdownTime": 10, "restartPolicy": "unless-stopped" + }, + { + "identifier": "nextcloud-aio-imaginary", + "dependsOn": [], + "displayName": "Imaginary", + "containerName": "nextcloud/aio-imaginary", + "ports": [], + "internalPorts": [ + "9000" + ], + "environmentVariables": [ + "TZ=%TIMEZONE%" + ], + "volumes": [], + "secrets": [], + "maxShutdownTime": 10, + "restartPolicy": "unless-stopped" } ] } diff --git a/php/public/disable-imaginary.js b/php/public/disable-imaginary.js new file mode 100644 index 00000000000..0f7787c9fa8 --- /dev/null +++ b/php/public/disable-imaginary.js @@ -0,0 +1,5 @@ +document.addEventListener("DOMContentLoaded", function(event) { + // Imaginary + var imaginary = document.getElementById("imaginary"); + imaginary.disabled = true; +}); \ No newline at end of file diff --git a/php/public/index.php b/php/public/index.php index cc29d0a1cd0..79888808037 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -102,6 +102,7 @@ 'collabora_dictionaries' => $configurationManager->GetCollaboraDictionaries(), 'automatic_updates' => $configurationManager->areAutomaticUpdatesEnabled(), 'is_backup_section_enabled' => $configurationManager->isBackupSectionEnabled(), + 'is_imaginary_enabled' => $configurationManager->isImaginaryEnabled(), ]); })->setName('profile'); $app->get('/login', function ($request, $response, $args) use ($container) { diff --git a/php/public/options-form-submit.js b/php/public/options-form-submit.js index fc63fb29c4c..1b03f8c0a01 100644 --- a/php/public/options-form-submit.js +++ b/php/public/options-form-submit.js @@ -23,4 +23,8 @@ document.addEventListener("DOMContentLoaded", function(event) { // Talk var talk = document.getElementById("talk"); talk.addEventListener('change', makeOptionsFormSubmitVisible); + + // Imaginary + var imaginary = document.getElementById("imaginary"); + imaginary.addEventListener('change', makeOptionsFormSubmitVisible); }); diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index db6dae22f26..e3ff90a187f 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -65,6 +65,10 @@ private function GetDefinition(bool $latest): array if (!$this->configurationManager->isTalkEnabled()) { continue; } + } elseif ($entry['identifier'] === 'nextcloud-aio-imaginary') { + if (!$this->configurationManager->isImaginaryEnabled()) { + continue; + } } $ports = new ContainerPorts(); @@ -146,6 +150,10 @@ private function GetDefinition(bool $latest): array if (!$this->configurationManager->isTalkEnabled()) { continue; } + } elseif ($value === 'nextcloud-aio-imaginary') { + if (!$this->configurationManager->isImaginaryEnabled()) { + continue; + } } $dependsOn[] = $value; } diff --git a/php/src/Controller/ConfigurationController.php b/php/src/Controller/ConfigurationController.php index 109626e996d..02174d26b68 100644 --- a/php/src/Controller/ConfigurationController.php +++ b/php/src/Controller/ConfigurationController.php @@ -90,6 +90,11 @@ public function SetConfig(Request $request, Response $response, $args) : Respons } else { $this->configurationManager->SetTalkEnabledState(0); } + if (isset($request->getParsedBody()['imaginary'])) { + $this->configurationManager->SetImaginaryEnabledState(1); + } else { + $this->configurationManager->SetImaginaryEnabledState(0); + } } if (isset($request->getParsedBody()['delete_collabora_dictionaries'])) { diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 67ab009d45c..00ea9989612 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -139,6 +139,21 @@ public function SetClamavEnabledState(int $value) : void { $this->WriteConfig($config); } + public function isImaginaryEnabled() : bool { + $config = $this->GetConfig(); + if (isset($config['isImaginaryEnabled']) && $config['isImaginaryEnabled'] === 1) { + return true; + } else { + return false; + } + } + + public function SetImaginaryEnabledState(int $value) : void { + $config = $this->GetConfig(); + $config['isImaginaryEnabled'] = $value; + $this->WriteConfig($config); + } + public function isOnlyofficeEnabled() : bool { $config = $this->GetConfig(); if (isset($config['isOnlyofficeEnabled']) && $config['isOnlyofficeEnabled'] === 1) { diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 8fb85fe3773..35b8b15063a 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -298,6 +298,12 @@ public function CreateContainer(Container $container) : void { } else { $replacements[1] = $this->configurationManager->GetCollaboraDictionaries(); } + } elseif ($out[1] === 'IMAGINARY_ENABLED') { + if ($this->configurationManager->isImaginaryEnabled()) { + $replacements[1] = 'yes'; + } else { + $replacements[1] = ''; + } } else { $replacements[1] = $this->configurationManager->GetSecret($out[1]); } diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 6025041055e..5bd71b06d72 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -452,6 +452,11 @@ {% else %}
{% endif %} + {% if is_imaginary_enabled == true %} +
+ {% else %} +
+ {% endif %} {% if is_talk_enabled == true %}

{% else %} @@ -472,6 +477,7 @@ {% if isAnyRunning == true %} + {% endif %} {% if is_collabora_enabled == true and isAnyRunning == false and was_start_button_clicked == true %} diff --git a/readme.md b/readme.md index 980d153eed4..c30c0cd31cf 100644 --- a/readme.md +++ b/readme.md @@ -7,6 +7,7 @@ Included are: - High performance backend for Nextcloud Files - High performance backend for Nextcloud Talk - Backup solution (based on [BorgBackup](https://github.com/borgbackup/borg#what-is-borgbackup)) +- Imaginary - ClamAV ## How to use this?