From 7f33d670f1b9dcb9dd63c288f67cfbda9eeb70e9 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 24 Oct 2021 00:35:34 +0200 Subject: [PATCH] Update 91-OCR --- papermerge/rootfs/etc/cont-init.d/91-OCR | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/papermerge/rootfs/etc/cont-init.d/91-OCR b/papermerge/rootfs/etc/cont-init.d/91-OCR index 9eb3c3e80..3a08cbe73 100644 --- a/papermerge/rootfs/etc/cont-init.d/91-OCR +++ b/papermerge/rootfs/etc/cont-init.d/91-OCR @@ -2,4 +2,18 @@ # Allow OCR setting OCRLANG="$(bashio::config "ocrlang")" -sed -i "2i\OCRLANG=$OCRLANG" /etc/cont-init.d/98-multilangocr + +if [ -n "$OCRLANG" ]; then + LINE=$(sed -n '/OCR_LANGUAGES/=' /data/config/papermerge.conf.py) + echo "OCRLANG variable is set, processing the language packages" + for i in $(echo "$OCRLANG" | tr "," " "); do + if apt-cache show tesseract-ocr-"${i}" > /dev/null 2>&1; then + echo "installing tesseract-ocr-${i}" + apt-get install -y tesseract-ocr-"${i}" + else + echo "package tesseract-ocr-${i} not found in the repository, skipping" + fi + sed "$LINE a \"${i}\": \"lang\"," products.txt + LINE=$((LINE+1)) + done +fi