Verify elasticsearch working

This commit is contained in:
Alexandre
2023-03-09 09:26:26 +01:00
committed by GitHub
parent 98b5df4492
commit ed67513b51

View File

@@ -13,6 +13,9 @@ if [[ $($LAUNCHER -V) == *"not installed"* ]]; then
exit 0 exit 0
fi fi
if $LAUNCHER fulltextsearch:test &>/dev/null; then
echo "Full Text Search is already working"
############ ############
# BASED ON # # BASED ON #
################################################################################# #################################################################################
@@ -22,22 +25,9 @@ fi
################################################################################# #################################################################################
if bashio::config.true 'Full_Text_Search'; then if bashio::config.true 'Full_Text_Search'; then
# shellcheck disable=SC1073,SC1072,SC1009
if $LAUNCHER fulltextsearch:test &>/dev/null; then
echo "Full Text Search is already working"
break 2
fi
echo "Installing Full Text Search"
# Reset Full Text Search to be able to index again, and also remove the app to be able to install it again
# occ fulltextsearch:reset &>/dev/null || true
# APPS=(fulltextsearch fulltextsearch_elasticsearch files_fulltextsearch)
# for app in "${APPS[@]}"; do
# # If app exists, remove it
# [ -n $($LAUNCHER app:getpath $app) ] && $LAUNCHER app:remove $app &>/dev/null
# done
# Get Full Text Search app for nextcloud # Get Full Text Search app for nextcloud
echo "Installing Full Text Search"
for app in "${APPS[@]}"; do for app in "${APPS[@]}"; do
echo "... installing apps : $app" echo "... installing apps : $app"
$LAUNCHER app:install $app >/dev/null $LAUNCHER app:install $app >/dev/null
@@ -48,15 +38,12 @@ if bashio::config.true 'Full_Text_Search'; then
if bashio::config.has_value 'elasticsearch_server'; then if bashio::config.has_value 'elasticsearch_server'; then
HOST=$(bashio::config 'elasticsearch_server') HOST=$(bashio::config 'elasticsearch_server')
else else
bashio::log.warning 'Please define elasticsearch server url in addon options with the format "ip:port" such as "192.168.178.1:9200". Default value of http://db21ed7f-elasticsearch:9200 will be used' bashio::log.warning 'Please define elasticsearch server url in addon options. Default value of http://db21ed7f-elasticsearch:9200 will be used'
HOST=http://db21ed7f-elasticsearch:9200 HOST=http://db21ed7f-elasticsearch:9200
#HOST=$(bashio::network.ipv4_address)
#HOST="${HOST%/*}:9200"
fi fi
# Final setup # Final setup
echo "... settings apps" echo "... settings apps"
#occ fulltextsearch:configure '{"search_platform":"ElasticSearchPlatform"}'
$LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"$HOST\"}" &>/dev/null $LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"$HOST\"}" &>/dev/null
$LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_index\":\"my_index\"}" &>/dev/null $LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_index\":\"my_index\"}" &>/dev/null
$LAUNCHER fulltextsearch_elasticsearch:configure "{\"analyzer_tokenizer\":\"standard\"}" &>/dev/null $LAUNCHER fulltextsearch_elasticsearch:configure "{\"analyzer_tokenizer\":\"standard\"}" &>/dev/null
@@ -64,10 +51,9 @@ if bashio::config.true 'Full_Text_Search'; then
$LAUNCHER files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}" &>/dev/null || true $LAUNCHER files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}" &>/dev/null || true
# Is server detected # Is server detected
# if [ curl $HOST ] &>/dev/null; then
# Wait further for cache for index to work # Wait further for cache for index to work
echo "Waiting for a few seconds before indexing starts..." echo "Waiting for a few seconds before indexing starts..."
sleep 10s sleep 5s
if $LAUNCHER fulltextsearch:test &>/dev/null; then if $LAUNCHER fulltextsearch:test &>/dev/null; then
bashio::log.info "Full Text Search was successfully installed using elasticsearch server $HOST!" bashio::log.info "Full Text Search was successfully installed using elasticsearch server $HOST!"
@@ -78,3 +64,4 @@ if bashio::config.true 'Full_Text_Search'; then
else else
echo "Full_Text_Search option not set" echo "Full_Text_Search option not set"
fi fi
fi