mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-25 16:56:04 +02:00
elasticsearch script
This commit is contained in:
@@ -1,71 +1,87 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
|
|
||||||
if bashio::config.has_value 'test'; then
|
# shellcheck source=lib.sh
|
||||||
|
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
|
||||||
|
|
||||||
# https://raw.githubusercontent.com/nextcloud/vm/master/apps/fulltextsearch.sh
|
# Get all needed variables from the library
|
||||||
|
ncdb
|
||||||
|
nc_update
|
||||||
|
es_install
|
||||||
|
|
||||||
|
# Check for errors + debug code and abort if something isn't right
|
||||||
|
# 1 = ON
|
||||||
|
# 0 = OFF
|
||||||
|
DEBUG=0
|
||||||
|
debug_mode
|
||||||
|
|
||||||
|
# Must be root
|
||||||
|
root_check
|
||||||
|
|
||||||
|
# https://raw.githubusercontent.com/nextcloud/vm/master/apps/fulltextsearch.sh
|
||||||
# T&M Hansson IT AB © - 2021, https://www.hanssonit.se/
|
# T&M Hansson IT AB © - 2021, https://www.hanssonit.se/
|
||||||
# SwITNet Ltd © - 2021, https://switnet.net/
|
# SwITNet Ltd © - 2021, https://switnet.net/
|
||||||
|
|
||||||
true
|
if [ bashio::config.is_true 'install_elasticsearch' ] && [ ! is_app_installed "fulltextsearch" ]; then
|
||||||
SCRIPT_NAME="Full Text Search"
|
echo "Installing Full Text Search"
|
||||||
SCRIPT_EXPLAINER="Full Text Search provides Elasticsearch for Nextcloud, which makes it possible to search for text inside files."
|
|
||||||
|
|
||||||
# Install OCR if requested
|
true
|
||||||
# Reset Full Text Search to be able to index again, and also remove the app to be able to install it again
|
SCRIPT_NAME="Full Text Search"
|
||||||
|
SCRIPT_EXPLAINER="Full Text Search provides Elasticsearch for Nextcloud, which makes it possible to search for text inside files."
|
||||||
|
:
|
||||||
|
# Make sure there is an Nextcloud installation
|
||||||
|
if ! [ "$(nextcloud_occ -V)" ]; then
|
||||||
|
echo "It seems there is no Nextcloud server installed, please check your installation."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install OCR if requested
|
||||||
|
# Reset Full Text Search to be able to index again, and also remove the app to be able to install it again
|
||||||
nextcloud_occ_no_check fulltextsearch:reset
|
nextcloud_occ_no_check fulltextsearch:reset
|
||||||
APPS=(fulltextsearch fulltextsearch_elasticsearch files_fulltextsearch)
|
APPS=(fulltextsearch fulltextsearch_elasticsearch files_fulltextsearch)
|
||||||
for app in "${APPS[@]}"
|
for app in "${APPS[@]}"; do
|
||||||
do
|
if is_app_installed "$app"; then
|
||||||
if is_app_installed "$app"
|
|
||||||
then
|
|
||||||
nextcloud_occ app:remove "$app"
|
nextcloud_occ app:remove "$app"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
# Make sure there is an Nextcloud installation
|
|
||||||
if ! [ "$(nextcloud_occ -V)" ]
|
|
||||||
then
|
|
||||||
msg_box "It seems there is no Nextcloud server installed, please check your installation."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Disable and remove Nextant + Solr
|
|
||||||
if is_app_installed nextant
|
|
||||||
then
|
|
||||||
# Remove Nextant
|
|
||||||
msg_box "We will now remove Nextant + Solr and replace it with Full Text Search"
|
|
||||||
nextcloud_occ app:remove nextant
|
|
||||||
|
|
||||||
# Remove Solr
|
|
||||||
systemctl stop solr.service
|
|
||||||
rm -rf /var/solr
|
|
||||||
rm -rf /opt/solr*
|
|
||||||
rm /etc/init.d/solr
|
|
||||||
deluser --remove-home solr
|
|
||||||
deluser --group solr
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if the app is compatible with the current Nextcloud version
|
|
||||||
if ! install_and_enable_app fulltextsearch
|
|
||||||
then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Get Full Text Search app for nextcloud
|
|
||||||
install_and_enable_app fulltextsearch
|
|
||||||
install_and_enable_app fulltextsearch_elasticsearch
|
|
||||||
install_and_enable_app files_fulltextsearch
|
|
||||||
chown -R abc:abc $NC_APPS_PATH
|
|
||||||
|
|
||||||
# Final setup
|
|
||||||
nextcloud_occ fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}'
|
|
||||||
nextcloud_occ fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://${INDEX_USER}:${ROREST}@localhost:9200\",\"elastic_index\":\"${INDEX_USER}-index\"}"
|
|
||||||
nextcloud_occ files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}"
|
|
||||||
# Wait further for cache for index to work
|
|
||||||
countdown "Waiting for a few seconds before indexing starts..." "10"
|
|
||||||
if nextcloud_occ fulltextsearch:index < /dev/null
|
|
||||||
then
|
|
||||||
msg_box "Full Text Search was successfully installed!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# Disable and remove Nextant + Solr
|
||||||
|
if is_app_installed nextant; then
|
||||||
|
# Remove Nextant
|
||||||
|
echo "We will now remove Nextant + Solr and replace it with Full Text Search"
|
||||||
|
nextcloud_occ app:remove nextant
|
||||||
|
|
||||||
|
# Remove Solr
|
||||||
|
systemctl stop solr.service
|
||||||
|
rm -rf /var/solr
|
||||||
|
rm -rf /opt/solr*
|
||||||
|
rm /etc/init.d/solr
|
||||||
|
deluser --remove-home solr
|
||||||
|
deluser --group solr
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the app is compatible with the current Nextcloud version
|
||||||
|
if ! install_and_enable_app fulltextsearch; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get Full Text Search app for nextcloud
|
||||||
|
echo "... installing apps : fulltextsearch"
|
||||||
|
install_and_enable_app fulltextsearch
|
||||||
|
echo "... installing apps : fulltextsearch_elasticsearch"
|
||||||
|
install_and_enable_app fulltextsearch_elasticsearch
|
||||||
|
echo "... installing apps : files_fulltextsearch"
|
||||||
|
install_and_enable_app files_fulltextsearch
|
||||||
|
echo "... updating permissions"
|
||||||
|
chown -R abc:abc $NC_APPS_PATH
|
||||||
|
|
||||||
|
# Final setup
|
||||||
|
echo "... creating base_config"
|
||||||
|
nextcloud_occ fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}'
|
||||||
|
nextcloud_occ fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://${INDEX_USER}:${ROREST}@localhost:9200\",\"elastic_index\":\"${INDEX_USER}-index\"}"
|
||||||
|
nextcloud_occ files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}"
|
||||||
|
# Wait further for cache for index to work
|
||||||
|
countdown "Waiting for a few seconds before indexing starts..." "10"
|
||||||
|
if nextcloud_occ fulltextsearch:index </dev/null; then
|
||||||
|
bashio::log.info "Full Text Search was successfully installed!"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
# Install OCR if requested
|
# Install OCR if requested
|
||||||
if bashio::config.has_value 'OCR'; then
|
if bashio::config.has_value 'OCR'; then
|
||||||
if $(bashio::config 'OCR') = true; then
|
if $(bashio::config 'OCR') = true; then
|
||||||
bashio::log.info 'Installing OCR'
|
echo "Installing OCR"
|
||||||
apk add --no-cache tesseract-ocr || apk add --no-cache tesseract-ocr@community
|
apk add --no-cache tesseract-ocr || apk add --no-cache tesseract-ocr@community
|
||||||
# Install additional language if requested
|
# Install additional language if requested
|
||||||
if bashio::config.has_value 'OCRLANG'; then
|
if bashio::config.has_value 'OCRLANG'; then
|
||||||
LANG=$(bashio::config 'OCRLANG')
|
LANG=$(bashio::config 'OCRLANG')
|
||||||
bashio::log.info "Installing OCR language : $LANG"
|
apk add --no-cache tesseract-ocr-data-$LANG || apk add --no-cache tesseract-ocr-data-$LANG@community
|
||||||
apk add --no-cache tesseract-ocr-data-$LANG || apk add --no-cache tesseract-ocr-data-$LANG@community
|
bashio::log.info "OCR Language installed : $LANG"
|
||||||
fi
|
fi
|
||||||
elif $(bashio::config 'OCR') = false; then
|
elif $(bashio::config 'OCR') = false; then
|
||||||
bashio::log.info 'Removing OCR'
|
bashio::log.info 'Removing OCR'
|
||||||
apk del tesseract-ocr.* || true
|
apk del tesseract-ocr.* || true
|
||||||
|
|||||||
Reference in New Issue
Block a user