mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-15 21:31:50 +02:00
code update
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user