Merge pull request #6743 from nextcloud/enh/noid/add-safeguard-to-fts

nextcloud-entrypoint: do not wait indefinitely if FTS is not reachable
This commit is contained in:
Simon L. 2025-08-14 10:40:45 +02:00 committed by GitHub
commit d0ba9278f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -828,45 +828,54 @@ fi
# Fulltextsearch # Fulltextsearch
if [ "$FULLTEXTSEARCH_ENABLED" = 'yes' ]; then if [ "$FULLTEXTSEARCH_ENABLED" = 'yes' ]; then
while ! nc -z "$FULLTEXTSEARCH_HOST" "$FULLTEXTSEARCH_PORT"; do count=0
while ! nc -z "$FULLTEXTSEARCH_HOST" "$FULLTEXTSEARCH_PORT" && [ "$count" -lt 90 ]; do
echo "waiting for Fulltextsearch to become available..." echo "waiting for Fulltextsearch to become available..."
count=$((count+5))
sleep 5 sleep 5
done done
if ! [ -d "/var/www/html/custom_apps/fulltextsearch" ]; then if [ "$count" -ge 90 ]; then
php /var/www/html/occ app:install fulltextsearch echo "Fulltextsearch did not start in time. Skipping initialization and disabling fulltextsearch apps."
elif [ "$(php /var/www/html/occ config:app:get fulltextsearch enabled)" != "yes" ]; then php /var/www/html/occ app:disable fulltextsearch
php /var/www/html/occ app:enable fulltextsearch php /var/www/html/occ app:disable fulltextsearch_elasticsearch
elif [ "$SKIP_UPDATE" != 1 ]; then php /var/www/html/occ app:disable files_fulltextsearch
php /var/www/html/occ app:update fulltextsearch else
fi if ! [ -d "/var/www/html/custom_apps/fulltextsearch" ]; then
if ! [ -d "/var/www/html/custom_apps/fulltextsearch_elasticsearch" ]; then php /var/www/html/occ app:install fulltextsearch
php /var/www/html/occ app:install fulltextsearch_elasticsearch elif [ "$(php /var/www/html/occ config:app:get fulltextsearch enabled)" != "yes" ]; then
elif [ "$(php /var/www/html/occ config:app:get fulltextsearch_elasticsearch enabled)" != "yes" ]; then php /var/www/html/occ app:enable fulltextsearch
php /var/www/html/occ app:enable fulltextsearch_elasticsearch elif [ "$SKIP_UPDATE" != 1 ]; then
elif [ "$SKIP_UPDATE" != 1 ]; then php /var/www/html/occ app:update fulltextsearch
php /var/www/html/occ app:update fulltextsearch_elasticsearch fi
fi if ! [ -d "/var/www/html/custom_apps/fulltextsearch_elasticsearch" ]; then
if ! [ -d "/var/www/html/custom_apps/files_fulltextsearch" ]; then php /var/www/html/occ app:install fulltextsearch_elasticsearch
php /var/www/html/occ app:install files_fulltextsearch elif [ "$(php /var/www/html/occ config:app:get fulltextsearch_elasticsearch enabled)" != "yes" ]; then
elif [ "$(php /var/www/html/occ config:app:get files_fulltextsearch enabled)" != "yes" ]; then php /var/www/html/occ app:enable fulltextsearch_elasticsearch
php /var/www/html/occ app:enable files_fulltextsearch elif [ "$SKIP_UPDATE" != 1 ]; then
elif [ "$SKIP_UPDATE" != 1 ]; then php /var/www/html/occ app:update fulltextsearch_elasticsearch
php /var/www/html/occ app:update files_fulltextsearch fi
fi if ! [ -d "/var/www/html/custom_apps/files_fulltextsearch" ]; then
php /var/www/html/occ fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}' php /var/www/html/occ app:install files_fulltextsearch
php /var/www/html/occ fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://$FULLTEXTSEARCH_USER:$FULLTEXTSEARCH_PASSWORD@$FULLTEXTSEARCH_HOST:$FULLTEXTSEARCH_PORT\",\"elastic_index\":\"$FULLTEXTSEARCH_INDEX\"}" elif [ "$(php /var/www/html/occ config:app:get files_fulltextsearch enabled)" != "yes" ]; then
php /var/www/html/occ files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}" php /var/www/html/occ app:enable files_fulltextsearch
elif [ "$SKIP_UPDATE" != 1 ]; then
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_USER:$FULLTEXTSEARCH_PASSWORD@$FULLTEXTSEARCH_HOST:$FULLTEXTSEARCH_PORT\",\"elastic_index\":\"$FULLTEXTSEARCH_INDEX\"}"
php /var/www/html/occ files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}"
# Do the index # Do the index
if ! [ -f "$NEXTCLOUD_DATA_DIR/fts-index.done" ]; then if ! [ -f "$NEXTCLOUD_DATA_DIR/fts-index.done" ]; then
echo "Waiting 10s before activating FTS..." echo "Waiting 10s before activating FTS..."
sleep 10 sleep 10
echo "Activating fulltextsearch..." echo "Activating fulltextsearch..."
if php /var/www/html/occ fulltextsearch:test && php /var/www/html/occ fulltextsearch:index "{\"errors\": \"reset\"}" --no-readline; then if php /var/www/html/occ fulltextsearch:test && php /var/www/html/occ fulltextsearch:index "{\"errors\": \"reset\"}" --no-readline; then
touch "$NEXTCLOUD_DATA_DIR/fts-index.done" touch "$NEXTCLOUD_DATA_DIR/fts-index.done"
else else
echo "Fulltextsearch failed. Could not index." echo "Fulltextsearch failed. Could not index."
echo "Feel free to follow https://github.com/nextcloud/all-in-one/discussions/1709 if you want to skip the indexing in the future." echo "Feel free to follow https://github.com/nextcloud/all-in-one/discussions/1709 if you want to skip the indexing in the future."
fi
fi fi
fi fi
else else