diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d61aead1..fa37945a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -144,3 +144,12 @@ updates: labels: - 3. to review - dependencies +- package-ecosystem: "docker" + directory: "/Containers/fulltextsearch" + schedule: + interval: "daily" + time: "12:00" + open-pull-requests-limit: 10 + labels: + - 3. to review + - dependencies diff --git a/Containers/fulltextsearch/Dockerfile b/Containers/fulltextsearch/Dockerfile new file mode 100644 index 00000000..e8ced1db --- /dev/null +++ b/Containers/fulltextsearch/Dockerfile @@ -0,0 +1,4 @@ +# Probably from here https://github.com/elastic/elasticsearch/blob/main/distribution/docker/src/docker/Dockerfile +FROM elasticsearch:7.17.5 + +RUN elasticsearch /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch ingest-attachment \ No newline at end of file diff --git a/Containers/nextcloud/Dockerfile b/Containers/nextcloud/Dockerfile index ce108589..1b368fc6 100644 --- a/Containers/nextcloud/Dockerfile +++ b/Containers/nextcloud/Dockerfile @@ -237,7 +237,8 @@ RUN set -ex; \ chmod +r /upgrade.exclude && \ chmod +x /cron.sh && \ chmod +x /notify.sh && \ - chmod +x /activate-collabora.sh + chmod +x /activate-collabora.sh && \ + chmod +x /activate-fulltextsearch.sh RUN set -ex; \ mkdir /mnt/ncdata; \ diff --git a/Containers/nextcloud/activate-fulltextsearch.sh b/Containers/nextcloud/activate-fulltextsearch.sh new file mode 100644 index 00000000..2d547ba3 --- /dev/null +++ b/Containers/nextcloud/activate-fulltextsearch.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ "$FULLTEXTSEARCH_ENABLED" != yes ]; then + # Basically sleep for forever if fulltextsearch is not enabled + sleep 365d +fi +echo "Activating fulltextsearch..." +php /var/www/html/occ fulltextsearch:live -q +sleep 365d diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index c1d4aacd..16c271dc 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -423,5 +423,47 @@ if version_greater "24.0.0.0" "$installed_version"; then fi fi +# Fulltextsearch +if [ "$FULLTEXTSEARCH_ENABLED" = 'yes' ]; then + while ! nc -z "$FULLTEXTSEARCH_HOST" 9200; do + echo "waiting for Fulltextsearch to become available..." + sleep 5 + done + if ! [ -d "/var/www/html/custom_apps/fulltextsearch" ]; then + php /var/www/html/occ app:install fulltextsearch + elif [ "$(php /var/www/html/occ config:app:get fulltextsearch enabled)" = "no" ]; then + php /var/www/html/occ app:enable fulltextsearch + else + php /var/www/html/occ app:update fulltextsearch + fi + if ! [ -d "/var/www/html/custom_apps/fulltextsearch_elasticsearch" ]; then + php /var/www/html/occ app:install fulltextsearch_elasticsearch + elif [ "$(php /var/www/html/occ config:app:get fulltextsearch_elasticsearch enabled)" = "no" ]; then + php /var/www/html/occ app:enable fulltextsearch_elasticsearch + else + php /var/www/html/occ app:update fulltextsearch_elasticsearch + fi + if ! [ -d "/var/www/html/custom_apps/files_fulltextsearch" ]; then + php /var/www/html/occ app:install files_fulltextsearch + elif [ "$(php /var/www/html/occ config:app:get files_fulltextsearch enabled)" = "no" ]; then + php /var/www/html/occ app:enable files_fulltextsearch + else + php /var/www/html/occ app:update files_fulltextsearch + fi + php /var/www/html/occ fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}' + php /var/www/html/occ fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://$FULLTEXTSEARCH_HOST:9200\"}" + php /var/www/html/occ files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}" +else + if [ -d "/var/www/html/custom_apps/fulltextsearch" ]; then + php /var/www/html/occ app:remove fulltextsearch + fi + if [ -d "/var/www/html/custom_apps/fulltextsearch_elasticsearch" ]; then + php /var/www/html/occ app:remove fulltextsearch_elasticsearch + fi + if [ -d "/var/www/html/custom_apps/files_fulltextsearch" ]; then + php /var/www/html/occ app:remove files_fulltextsearch + fi +fi + # Remove the update skip file always rm -f /mnt/ncdata/skip.update diff --git a/Containers/nextcloud/supervisord.conf b/Containers/nextcloud/supervisord.conf index f411e59b..76f47a70 100644 --- a/Containers/nextcloud/supervisord.conf +++ b/Containers/nextcloud/supervisord.conf @@ -35,3 +35,10 @@ stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 command=/activate-collabora.sh + +[program:activate-fulltextsearch] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=/activate-fulltextsearch.sh diff --git a/php/containers.json b/php/containers.json index 447afe85..d06299dd 100644 --- a/php/containers.json +++ b/php/containers.json @@ -3,6 +3,7 @@ { "identifier": "nextcloud-aio-apache", "dependsOn": [ + "nextcloud-aio-fulltextsearch", "nextcloud-aio-onlyoffice", "nextcloud-aio-collabora", "nextcloud-aio-clamav", @@ -144,7 +145,9 @@ "TALK_PORT=%TALK_PORT%", "IMAGINARY_ENABLED=%IMAGINARY_ENABLED%", "IMAGINARY_HOST=nextcloud-aio-imaginary", - "PHP_UPLOAD_LIMIT=%NEXTCLOUD_UPLOAD_LIMIT%" + "PHP_UPLOAD_LIMIT=%NEXTCLOUD_UPLOAD_LIMIT%", + "FULLTEXTSEARCH_ENABLED=%FULLTEXTSEARCH_ENABLED%", + "FULLTEXTSEARCH_HOST=nextcloud-aio-fulltextsearch" ], "maxShutdownTime": 10, "restartPolicy": "unless-stopped" @@ -388,6 +391,31 @@ "secrets": [], "maxShutdownTime": 10, "restartPolicy": "unless-stopped" + }, + { + "identifier": "nextcloud-aio-fulltextsearch", + "dependsOn": [], + "displayName": "Fulltextsearch", + "containerName": "nextcloud/aio-fulltextsearch", + "ports": [], + "internalPorts": [ + "9200" + ], + "environmentVariables": [ + "TZ=%TIMEZONE%", + "discovery.type=single-node", + "ES_JAVA_OPTS=-Xms1024M -Xmx1024M" + ], + "volumes": [ + { + "name": "nextcloud_aio_elasticsearch", + "location": "/usr/share/elasticsearch/data", + "writeable": true + } + ], + "secrets": [], + "maxShutdownTime": 10, + "restartPolicy": "unless-stopped" } ] } diff --git a/php/public/disable-fulltextsearch.js b/php/public/disable-fulltextsearch.js new file mode 100644 index 00000000..de614bf5 --- /dev/null +++ b/php/public/disable-fulltextsearch.js @@ -0,0 +1,5 @@ +document.addEventListener("DOMContentLoaded", function(event) { + // Fulltextsearch + var fulltextsearch = document.getElementById("fulltextsearch"); + fulltextsearch.disabled = true; +}); \ No newline at end of file diff --git a/php/public/index.php b/php/public/index.php index 79888808..6136f2d5 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -103,6 +103,7 @@ $app->get('/containers', function ($request, $response, $args) use ($container) 'automatic_updates' => $configurationManager->areAutomaticUpdatesEnabled(), 'is_backup_section_enabled' => $configurationManager->isBackupSectionEnabled(), 'is_imaginary_enabled' => $configurationManager->isImaginaryEnabled(), + 'is_fulltextsearch_enabled' => $configurationManager->isFulltextsearchEnabled(), ]); })->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 1b03f8c0..02734ba0 100644 --- a/php/public/options-form-submit.js +++ b/php/public/options-form-submit.js @@ -27,4 +27,8 @@ document.addEventListener("DOMContentLoaded", function(event) { // Imaginary var imaginary = document.getElementById("imaginary"); imaginary.addEventListener('change', makeOptionsFormSubmitVisible); + + // Fulltextsearch + var fulltextsearch = document.getElementById("fulltextsearch"); + fulltextsearch.addEventListener('change', makeOptionsFormSubmitVisible); }); diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index e3ff90a1..15e84b1e 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -69,6 +69,10 @@ class ContainerDefinitionFetcher if (!$this->configurationManager->isImaginaryEnabled()) { continue; } + } elseif ($entry['identifier'] === 'nextcloud-aio-fulltextsearch') { + if (!$this->configurationManager->isFulltextsearchEnabled()) { + continue; + } } $ports = new ContainerPorts(); @@ -154,6 +158,10 @@ class ContainerDefinitionFetcher if (!$this->configurationManager->isImaginaryEnabled()) { continue; } + } elseif ($value === 'nextcloud-aio-fulltextsearch') { + if (!$this->configurationManager->isFulltextsearchEnabled()) { + continue; + } } $dependsOn[] = $value; } diff --git a/php/src/Controller/ConfigurationController.php b/php/src/Controller/ConfigurationController.php index 02174d26..ad2697d7 100644 --- a/php/src/Controller/ConfigurationController.php +++ b/php/src/Controller/ConfigurationController.php @@ -95,6 +95,11 @@ class ConfigurationController } else { $this->configurationManager->SetImaginaryEnabledState(0); } + if (isset($request->getParsedBody()['fulltextsearch'])) { + $this->configurationManager->SetFulltextsearchEnabledState(1); + } else { + $this->configurationManager->SetFulltextsearchEnabledState(0); + } } if (isset($request->getParsedBody()['delete_collabora_dictionaries'])) { diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index e87cc039..1dec7615 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -154,6 +154,21 @@ class ConfigurationManager $this->WriteConfig($config); } + public function isFulltextsearchEnabled() : bool { + $config = $this->GetConfig(); + if (isset($config['isFulltextsearchEnabled']) && $config['isFulltextsearchEnabled'] === 1) { + return true; + } else { + return false; + } + } + + public function SetFulltextsearchEnabledState(int $value) : void { + $config = $this->GetConfig(); + $config['isFulltextsearchEnabled'] = $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 8be3b675..cb76aac9 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -304,6 +304,12 @@ class DockerActionManager } else { $replacements[1] = ''; } + } elseif ($out[1] === 'FULLTEXTSEARCH_ENABLED') { + if ($this->configurationManager->isFulltextsearchEnabled()) { + $replacements[1] = 'yes'; + } else { + $replacements[1] = ''; + } } elseif ($out[1] === 'NEXTCLOUD_UPLOAD_LIMIT') { $replacements[1] = $this->configurationManager->GetNextcloudUploadLimit(); } elseif ($out[1] === 'NEXTCLOUD_MAX_TIME') { diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 5bd71b06..be4d3a7d 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -452,6 +452,11 @@ {% else %}
{% endif %} + {% if is_fulltextsearch_enabled == true %} +
+ {% else %} +
+ {% endif %} {% if is_imaginary_enabled == true %}
{% else %} @@ -469,7 +474,7 @@ {% endif %} - Minimal system requirements: When any optional addon is enabled, at least 2GB RAM, a dual-core CPU and 40GB system storage are required. When enabling ClamAV, at least 3GB RAM are required. Recommended are at least 4GB of RAM.

+ Minimal system requirements: When any optional addon is enabled, at least 2GB RAM, a dual-core CPU and 40GB system storage are required. When enabling ClamAV or Fulltextsearch, at least 3GB RAM are required. When enabling everything, at least 4GB RAM are required. Recommended are at least 1GB more RAM than the minimal requirement.

{% if isAnyRunning == true or is_x64_platform == false %} @@ -478,6 +483,7 @@ + {% endif %} {% if is_collabora_enabled == true and isAnyRunning == false and was_start_button_clicked == true %} diff --git a/readme.md b/readme.md index f7d9c293..6e4bfdd7 100644 --- a/readme.md +++ b/readme.md @@ -9,6 +9,7 @@ Included are: - Backup solution (based on [BorgBackup](https://github.com/borgbackup/borg#what-is-borgbackup)) - Imaginary - ClamAV +- Fulltextsearch ## How to use this? The following instructions are especially meant for Linux. For macOS see [this](#how-to-run-aio-on-macos), for Windows see [this](#how-to-run-aio-on-windows). diff --git a/tests/QA/050-optional-addons.md b/tests/QA/050-optional-addons.md index c5cfd3ac..9719839f 100644 --- a/tests/QA/050-optional-addons.md +++ b/tests/QA/050-optional-addons.md @@ -8,6 +8,7 @@ - [ ] Collabora by trying to open a .docx or .odt file in Nextcloud - [ ] Nextcloud Talk by opening the Talk app in Nextcloud, creating a new chat and trying to join a call in this chat. Also verifying in the settings that the HPB and turn server work. - [ ] Imaginary by having a look if when uploading a new picture in Nextcloud, it adds some log entries to the container + - [ ] Fulltextsearch by trying to search for a heading inside a file in Nextcloud - [ ] When Collabora is enabled, it should show below the Optional Addons section a section where you can change the dictionaries for collabora. `de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru` should be a valid setting. E.g. `de.De` not. If already set, it should show a button that allows to remove the setting again. You can now continue with [060-environmental-variables.md](./060-environmental-variables.md) \ No newline at end of file