mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 10:21:02 +01:00
code update
This commit is contained in:
@@ -16,7 +16,7 @@ RUN \
|
||||
##################
|
||||
&& echo "**** Install Bashio ****" \
|
||||
&& apk add --no-cache \
|
||||
curl jq \
|
||||
curl jq wget \
|
||||
&& curl -J -L -o /tmp/bashio.tar.gz \
|
||||
"https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \
|
||||
&& mkdir /tmp/bashio \
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"upstream": "22.2.0",
|
||||
"slug": "nextcloud_ocr",
|
||||
"ingress": false,
|
||||
"hassio_api": true,
|
||||
"ingress_port": 0,
|
||||
"arch": ["aarch64", "amd64", "armv7"],
|
||||
"description": "Nextcloud for Home Assistant",
|
||||
|
||||
@@ -1,96 +1,93 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
# Make sure there is an Nextcloud installation
|
||||
if ! [ "$(occ -V)" ]; then
|
||||
bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
############
|
||||
# BASED ON #
|
||||
############
|
||||
# https://raw.githubusercontent.com/nextcloud/vm/master/apps/fulltextsearch.sh
|
||||
# T&M Hansson IT AB © - 2021, https://www.hanssonit.se/
|
||||
# SwITNet Ltd © - 2021, https://switnet.net/
|
||||
#################################################################################
|
||||
# https://raw.githubusercontent.com/nextcloud/vm/master/apps/fulltextsearch.sh #
|
||||
# T&M Hansson IT AB © - 2021, https://www.hanssonit.se/ #
|
||||
# SwITNet Ltd © - 2021, https://switnet.net/ #
|
||||
#################################################################################
|
||||
|
||||
# Download the script
|
||||
source /sbin/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
|
||||
#######################
|
||||
# Download the script #
|
||||
#######################
|
||||
#SCRIPT="/sbin/fetch_lib"
|
||||
#wget -q -O $SCRIPT https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh
|
||||
#source $SCRIPT
|
||||
|
||||
# Correct the script
|
||||
sed -i "s|SCRIPTS=/var/scripts|SCRIPTS=/sbin|g" /sbin/fetch_lib.sh
|
||||
sed -i "s|NCPATH=/var/www/nextcloud|/data/config/www/nextcloud|g" /sbin/fetch_lib.sh
|
||||
sed -i "s|BACKUP=/mnt/NCBACKUP|BACKUP=/data/NCBACKUP|g" /sbin/fetch_lib.sh
|
||||
######################
|
||||
# Correct the script #
|
||||
######################
|
||||
#sed -i "s|SCRIPTS=/var/scripts|SCRIPTS=/sbin|g" $SCRIPT
|
||||
#sed -i "s|NCPATH=/var/www/nextcloud|NCPATH=/data/config/www/nextcloud|g" $SCRIPT
|
||||
#sed -i "s|BACKUP=/mnt/NCBACKUP|BACKUP=/data/NCBACKUP|g" $SCRIPT
|
||||
|
||||
# Test RAM size (2GB min) + CPUs (min 2)
|
||||
#ram_check 3 FullTextSearch
|
||||
#cpu_check 2 FullTextSearch
|
||||
|
||||
# Get all needed variables from the library
|
||||
ncdb
|
||||
nc_update
|
||||
es_install
|
||||
#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
|
||||
#DEBUG=0
|
||||
#debug_mode
|
||||
|
||||
# Must be root
|
||||
root_check
|
||||
#root_check
|
||||
|
||||
# Nextcloud 18 is required.
|
||||
#lowest_compatible_nc 18
|
||||
|
||||
if [ bashio::config.is_true 'install_elasticsearch' ] && [ ! is_app_installed "fulltextsearch" ]; then
|
||||
if bashio::config.true 'Full_Text_Search' && [ occ fulltextsearch:index ] &>/dev/null; then
|
||||
echo "Full Text Search is already working"
|
||||
else
|
||||
echo "Installing Full Text Search"
|
||||
|
||||
true
|
||||
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
|
||||
occ fulltextsearch:reset &>/dev/null || true
|
||||
APPS=(fulltextsearch fulltextsearch_elasticsearch files_fulltextsearch)
|
||||
for app in "${APPS[@]}"; do
|
||||
if is_app_installed "$app"; then
|
||||
nextcloud_occ app:remove "$app"
|
||||
fi
|
||||
# If app exists, remove it
|
||||
[ ! -z $(occ app:getpath $app) ] && occ app:remove $app
|
||||
done
|
||||
|
||||
# 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
|
||||
for app in "${APPS[@]}"; do
|
||||
echo "... installing apps : $app"
|
||||
occ app:install $app >/dev/null
|
||||
occ app:enable $app >/dev/null
|
||||
done
|
||||
chown -R abc:abc $NEXTCLOUD_PATH/apps
|
||||
|
||||
# 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!"
|
||||
echo "... settings apps"
|
||||
#occ fulltextsearch:configure '{"search_platform":"ElasticSearchPlatform"}'
|
||||
HOST=$(bashio::network.ipv4_address)
|
||||
HOST=${host_ip%/*}
|
||||
occ fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://$HOST:9200\"}"
|
||||
occ fulltextsearch_elasticsearch:configure "{\"elastic_index\":\"my_index\"}"
|
||||
occ fulltextsearch_elasticsearch:configure "{\"analyzer_tokenizer\":\"standard\"}"
|
||||
|
||||
# Is server detected
|
||||
if [ curl $HOST:9100 ] &>/dev/null; then
|
||||
# Wait further for cache for index to work
|
||||
countdown "Waiting for a few seconds before indexing starts..." "10"
|
||||
if occ fulltextsearch:index </dev/null; then
|
||||
bashio::log.info "Full Text Search was successfully installed!"
|
||||
fi
|
||||
|
||||
else
|
||||
bashio::log.warning "Elasticsearch can't connect. Please manually define its server in the options"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
@@ -1,18 +1,40 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
# Make sure there is an Nextcloud installation
|
||||
if ! [ "$(nextcloud_occ -V)" ]; then
|
||||
bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Install OCR if requested
|
||||
if bashio::config.has_value 'OCR'; then
|
||||
# Install package
|
||||
if $(bashio::config 'OCR') = true; then
|
||||
|
||||
# Get Full Text Search app for nextcloud
|
||||
echo "... installing apps : fulltextsearch"
|
||||
occ app:install files_fulltextsearch_tesseract &>/dev/null || true
|
||||
occ app:enable files_fulltextsearch_tesseract &>/dev/null || true
|
||||
|
||||
echo "Installing OCR"
|
||||
apk add --quiet --no-cache tesseract-ocr || apk add --quiet --no-cache tesseract-ocr@community
|
||||
# Install additional language if requested
|
||||
if bashio::config.has_value 'OCRLANG'; then
|
||||
LANG=$(bashio::config 'OCRLANG')
|
||||
apk add --quiet --no-cache tesseract-ocr-data-$LANG || apk add --quiet --no-cache tesseract-ocr-data-$LANG@community \
|
||||
&& bashio::log.info "OCR Language installed : $LANG" || bashio::log.fatal "Couldn't install OCR lang $LANG. Please check its format is conform"
|
||||
apk add --quiet --no-cache tesseract-ocr-data-$LANG || apk add --quiet --no-cache tesseract-ocr-data-$LANG@community && \
|
||||
bashio::log.info "OCR Language installed : $LANG" || bashio::log.fatal "Couldn't install OCR lang $LANG. Please check its format is conform"
|
||||
|
||||
# Downloading trainer data
|
||||
cd /usr/share/tessdata
|
||||
sudo rm -r $LANG.traineddata &>/dev/null || true
|
||||
wget https://github.com/tesseract-ocr/tessdata/raw/main/$LANG.traineddata &>/dev/null
|
||||
|
||||
fi
|
||||
elif $(bashio::config 'OCR') = false; then
|
||||
bashio::log.info 'Removing OCR'
|
||||
apk del tesseract-ocr.* || true
|
||||
# Delete package
|
||||
apk del tesseract-ocr.* &>/dev/null || true
|
||||
# Remove app
|
||||
occ app:disable files_fulltextsearch_tesseract &>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
####################
|
||||
# Initialization #
|
||||
####################
|
||||
# Make sure there is an Nextcloud installation
|
||||
if ! [ "$(nextcloud_occ -V)" ]; then
|
||||
bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
####################
|
||||
# Initialization #
|
||||
####################
|
||||
|
||||
if bashio::config.has_value 'trusted_domains'; then
|
||||
LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found"
|
||||
if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then
|
||||
LAUNCHER=`find / -name "occ" -print -quit`
|
||||
fi || bashio::log.info "occ not found"
|
||||
LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found"
|
||||
if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then
|
||||
LAUNCHER=$(find / -name "occ" -print -quit)
|
||||
fi || bashio::log.info "occ not found"
|
||||
|
||||
bashio::log.info "Currently set trusted domains :"
|
||||
$LAUNCHER config:system:get trusted_domains || bashio::log.info "No trusted domain set yet. The first one will be set when doing initial configuration"
|
||||
bashio::log.info "Currently set trusted domains :"
|
||||
$LAUNCHER config:system:get trusted_domains || bashio::log.info "No trusted domain set yet. The first one will be set when doing initial configuration"
|
||||
|
||||
bashio::log.info "Trusted domains set in the configuration. Refreshing domains." && \
|
||||
bashio::log.info "Trusted domains set in the configuration. Refreshing domains." && \
|
||||
###################################
|
||||
# Remove previous trusted domains #
|
||||
###################################
|
||||
bashio::log.info "... removing previously added trusted domain (except for first one created)"
|
||||
i=2
|
||||
until [ $i -gt 5 ]
|
||||
do
|
||||
$LAUNCHER config:system:delete trusted_domains $i && \
|
||||
((i=i+1)) || exit
|
||||
until [ $i -gt 5 ]; do
|
||||
$LAUNCHER config:system:delete trusted_domains $i && \
|
||||
((i = i + 1)) || exit
|
||||
done
|
||||
|
||||
###########################
|
||||
@@ -30,15 +35,13 @@ $LAUNCHER config:system:get trusted_domains || bashio::log.info "No trusted doma
|
||||
###########################
|
||||
TRUSTEDDOMAINS=$(bashio::config 'trusted_domains')
|
||||
bashio::log.info "... alignement with trusted domains list : ${TRUSTEDDOMAINS}"
|
||||
for domain in ${TRUSTEDDOMAINS//,/ } # Comma separated values
|
||||
do
|
||||
for domain in ${TRUSTEDDOMAINS//,/ }; do # Comma separated values
|
||||
bashio::log.info "... adding ${domain}"
|
||||
$LAUNCHER config:system:set trusted_domains $i --value=${domain}
|
||||
i=$((i+1))
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
bashio::log.info "Remaining configurated trusted domains :"
|
||||
bashio::log.info "$($LAUNCHER config:system:get trusted_domains)" || exit
|
||||
bashio::log.info "Remaining configurated trusted domains :"
|
||||
bashio::log.info "$($LAUNCHER config:system:get trusted_domains)" || exit
|
||||
|
||||
fi
|
||||
|
||||
|
||||
8
zzz_templates/00-bettercomments.sh
Normal file
8
zzz_templates/00-bettercomments.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!bin/bash
|
||||
|
||||
# Color comments
|
||||
#! Red
|
||||
#? Question
|
||||
#// Done
|
||||
#todo To do
|
||||
#* Green
|
||||
Reference in New Issue
Block a user