Skip to content

Commit

Permalink
add live index service (nextcloud#2565)
Browse files Browse the repository at this point in the history
  • Loading branch information
enoch85 authored Sep 21, 2023
1 parent da5faca commit 586c140
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
22 changes: 22 additions & 0 deletions apps/fulltextsearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,25 @@ nextcloud_occ fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_
nextcloud_occ fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"https://elastic:$ELASTIC_USER_PASSWORD@localhost:9200\",\"elastic_index\":\"${NEXTCLOUD_INDEX}\"}"
nextcloud_occ files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}"

# Add SystemD service for live indexing
cat << SYSTEMCTL_FTS > "/etc/systemd/system/$FULLTEXTSEARCH_SERVICE"
[Unit]
Description=Elasticsearch Worker for Nextcloud FullTextSearch
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=$NCPATH
ExecStart=/usr/bin/php $NCPATH/occ fulltextsearch:live -q
ExecStop=/usr/bin/php $NCPATH/occ fulltextsearch:stop
Nice=19
Restart=always
[Install]
WantedBy=multi-user.target
SYSTEMCTL_FTS

# Wait further for cache for index to work
countdown "Waiting for a few seconds before indexing starts..." "10"
if nextcloud_occ fulltextsearch:test
Expand All @@ -179,6 +198,9 @@ then
if nextcloud_occ fulltextsearch:index < /dev/null
then
msg_box "Full Text Search was successfully installed!"
# Enable the live service
systemctl enable "$FULLTEXTSEARCH_SERVICE"
systemctl start "$FULLTEXTSEARCH_SERVICE"
fi
else
msg_box "There seems to be an issue with the Full Text Search test. Please report this to $ISSUES."
Expand Down
5 changes: 3 additions & 2 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,14 @@ ENVASIVE=/etc/apache2/mods-available/mod-evasive.load
APACHE2=/etc/apache2/apache2.conf
# Full text Search
fulltextsearch_install() {
FULLTEXTSEARCH_DIR="$SCRIPTS"/fulltextsearch
NEXTCLOUD_INDEX=$(gen_passwd "$SHUF" '[:lower:]')
ELASTIC_USER_PASSWORD=$(gen_passwd "$SHUF" '[:lower:]')
FULLTEXTSEARCH_IMAGE_NAME=fulltextsearch_es01
FULLTEXTSEARCH_SERVICE=nextcloud-fulltext-elasticsearch-worker.service
# Legacy, changed 2023-09-21
DOCKER_IMAGE_NAME=es01
FULLTEXTSEARCH_DIR="$SCRIPTS"/fulltextsearch
# Legacy
# Legacy, not used at all
RORDIR=/opt/es/
OPNSDIR=/opt/opensearch
nc_fts="ark74/nc_fts"
Expand Down

0 comments on commit 586c140

Please sign in to comment.