mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-28 11:24:04 +02:00
code update
This commit is contained in:
@@ -16,7 +16,7 @@ RUN \
|
|||||||
##################
|
##################
|
||||||
&& echo "**** Install Bashio ****" \
|
&& echo "**** Install Bashio ****" \
|
||||||
&& apk add --no-cache \
|
&& apk add --no-cache \
|
||||||
curl jq \
|
curl jq wget \
|
||||||
&& curl -J -L -o /tmp/bashio.tar.gz \
|
&& curl -J -L -o /tmp/bashio.tar.gz \
|
||||||
"https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \
|
"https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \
|
||||||
&& mkdir /tmp/bashio \
|
&& mkdir /tmp/bashio \
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"upstream": "22.2.0",
|
"upstream": "22.2.0",
|
||||||
"slug": "nextcloud_ocr",
|
"slug": "nextcloud_ocr",
|
||||||
"ingress": false,
|
"ingress": false,
|
||||||
|
"hassio_api": true,
|
||||||
"ingress_port": 0,
|
"ingress_port": 0,
|
||||||
"arch": ["aarch64", "amd64", "armv7"],
|
"arch": ["aarch64", "amd64", "armv7"],
|
||||||
"description": "Nextcloud for Home Assistant",
|
"description": "Nextcloud for Home Assistant",
|
||||||
|
|||||||
@@ -1,96 +1,93 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/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 #
|
# BASED ON #
|
||||||
############
|
#################################################################################
|
||||||
# https://raw.githubusercontent.com/nextcloud/vm/master/apps/fulltextsearch.sh
|
# 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/ #
|
||||||
|
#################################################################################
|
||||||
|
|
||||||
# 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
|
# Correct the script #
|
||||||
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
|
#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
|
# Get all needed variables from the library
|
||||||
ncdb
|
#ncdb
|
||||||
nc_update
|
#nc_update
|
||||||
es_install
|
#es_install
|
||||||
|
|
||||||
# Check for errors + debug code and abort if something isn't right
|
# Check for errors + debug code and abort if something isn't right
|
||||||
# 1 = ON
|
# 1 = ON
|
||||||
# 0 = OFF
|
# 0 = OFF
|
||||||
DEBUG=0
|
#DEBUG=0
|
||||||
debug_mode
|
#debug_mode
|
||||||
|
|
||||||
# Must be root
|
# 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"
|
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
|
# 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)
|
APPS=(fulltextsearch fulltextsearch_elasticsearch files_fulltextsearch)
|
||||||
for app in "${APPS[@]}"; do
|
for app in "${APPS[@]}"; do
|
||||||
if is_app_installed "$app"; then
|
# If app exists, remove it
|
||||||
nextcloud_occ app:remove "$app"
|
[ ! -z $(occ app:getpath $app) ] && occ app:remove $app
|
||||||
fi
|
|
||||||
done
|
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
|
# Get Full Text Search app for nextcloud
|
||||||
echo "... installing apps : fulltextsearch"
|
for app in "${APPS[@]}"; do
|
||||||
install_and_enable_app fulltextsearch
|
echo "... installing apps : $app"
|
||||||
echo "... installing apps : fulltextsearch_elasticsearch"
|
occ app:install $app >/dev/null
|
||||||
install_and_enable_app fulltextsearch_elasticsearch
|
occ app:enable $app >/dev/null
|
||||||
echo "... installing apps : files_fulltextsearch"
|
done
|
||||||
install_and_enable_app files_fulltextsearch
|
chown -R abc:abc $NEXTCLOUD_PATH/apps
|
||||||
echo "... updating permissions"
|
|
||||||
chown -R abc:abc $NC_APPS_PATH
|
|
||||||
|
|
||||||
# Final setup
|
# Final setup
|
||||||
echo "... creating base_config"
|
echo "... settings apps"
|
||||||
nextcloud_occ fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}'
|
#occ fulltextsearch:configure '{"search_platform":"ElasticSearchPlatform"}'
|
||||||
nextcloud_occ fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://${INDEX_USER}:${ROREST}@localhost:9200\",\"elastic_index\":\"${INDEX_USER}-index\"}"
|
HOST=$(bashio::network.ipv4_address)
|
||||||
nextcloud_occ files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}"
|
HOST=${host_ip%/*}
|
||||||
# Wait further for cache for index to work
|
occ fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://$HOST:9200\"}"
|
||||||
countdown "Waiting for a few seconds before indexing starts..." "10"
|
occ fulltextsearch_elasticsearch:configure "{\"elastic_index\":\"my_index\"}"
|
||||||
if nextcloud_occ fulltextsearch:index </dev/null; then
|
occ fulltextsearch_elasticsearch:configure "{\"analyzer_tokenizer\":\"standard\"}"
|
||||||
bashio::log.info "Full Text Search was successfully installed!"
|
|
||||||
|
# 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
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,18 +1,40 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/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
|
# Install OCR if requested
|
||||||
if bashio::config.has_value 'OCR'; then
|
if bashio::config.has_value 'OCR'; then
|
||||||
|
# Install package
|
||||||
if $(bashio::config 'OCR') = true; then
|
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"
|
echo "Installing OCR"
|
||||||
apk add --quiet --no-cache tesseract-ocr || apk add --quiet --no-cache tesseract-ocr@community
|
apk add --quiet --no-cache tesseract-ocr || apk add --quiet --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')
|
||||||
apk add --quiet --no-cache tesseract-ocr-data-$LANG || apk add --quiet --no-cache tesseract-ocr-data-$LANG@community \
|
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"
|
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
|
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
|
# Delete package
|
||||||
|
apk del tesseract-ocr.* &>/dev/null || true
|
||||||
|
# Remove app
|
||||||
|
occ app:disable files_fulltextsearch_tesseract &>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,28 +1,33 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
|
|
||||||
####################
|
# Make sure there is an Nextcloud installation
|
||||||
# Initialization #
|
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
|
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"
|
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
|
if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then
|
||||||
LAUNCHER=`find / -name "occ" -print -quit`
|
LAUNCHER=$(find / -name "occ" -print -quit)
|
||||||
fi || bashio::log.info "occ not found"
|
fi || bashio::log.info "occ not found"
|
||||||
|
|
||||||
bashio::log.info "Currently set trusted domains :"
|
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"
|
$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 #
|
# Remove previous trusted domains #
|
||||||
###################################
|
###################################
|
||||||
bashio::log.info "... removing previously added trusted domain (except for first one created)"
|
bashio::log.info "... removing previously added trusted domain (except for first one created)"
|
||||||
i=2
|
i=2
|
||||||
until [ $i -gt 5 ]
|
until [ $i -gt 5 ]; do
|
||||||
do
|
$LAUNCHER config:system:delete trusted_domains $i && \
|
||||||
$LAUNCHER config:system:delete trusted_domains $i && \
|
((i = i + 1)) || exit
|
||||||
((i=i+1)) || exit
|
|
||||||
done
|
done
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
@@ -30,15 +35,13 @@ $LAUNCHER config:system:get trusted_domains || bashio::log.info "No trusted doma
|
|||||||
###########################
|
###########################
|
||||||
TRUSTEDDOMAINS=$(bashio::config 'trusted_domains')
|
TRUSTEDDOMAINS=$(bashio::config 'trusted_domains')
|
||||||
bashio::log.info "... alignement with trusted domains list : ${TRUSTEDDOMAINS}"
|
bashio::log.info "... alignement with trusted domains list : ${TRUSTEDDOMAINS}"
|
||||||
for domain in ${TRUSTEDDOMAINS//,/ } # Comma separated values
|
for domain in ${TRUSTEDDOMAINS//,/ }; do # Comma separated values
|
||||||
do
|
|
||||||
bashio::log.info "... adding ${domain}"
|
bashio::log.info "... adding ${domain}"
|
||||||
$LAUNCHER config:system:set trusted_domains $i --value=${domain}
|
$LAUNCHER config:system:set trusted_domains $i --value=${domain}
|
||||||
i=$((i+1))
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
bashio::log.info "Remaining configurated trusted domains :"
|
bashio::log.info "Remaining configurated trusted domains :"
|
||||||
bashio::log.info "$($LAUNCHER config:system:get trusted_domains)" || exit
|
bashio::log.info "$($LAUNCHER config:system:get trusted_domains)" || exit
|
||||||
|
|
||||||
fi
|
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