]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Enhancement: use apt only when needed docker-entrypoint.sh (#7756)
authorgawa971 <44551324+gawa971@users.noreply.github.com>
Tue, 24 Sep 2024 06:46:03 +0000 (13:46 +0700)
committerGitHub <noreply@github.com>
Tue, 24 Sep 2024 06:46:03 +0000 (23:46 -0700)
docker/docker-entrypoint.sh

index 903d578da6721519e3e5623d4397c3f54efcd86e..b8687dc565321d731a39c52945272a0536dc4e09 100755 (executable)
@@ -122,27 +122,38 @@ install_languages() {
        if [ ${#langs[@]} -eq 0 ]; then
                return
        fi
-       apt-get update
 
+       # Build list of packages to install
+       to_install=()
        for lang in "${langs[@]}"; do
                pkg="tesseract-ocr-$lang"
 
                if dpkg --status "$pkg" &>/dev/null; then
                        echo "Package $pkg already installed!"
                        continue
+               else
+                       to_install+=("$pkg")
                fi
+       done
 
-               if ! apt-cache show "$pkg" &>/dev/null; then
-                       echo "Package $pkg not found! :("
-                       continue
-               fi
+       # Use apt only when we install packages
+       if [ ${#to_install[@]} -gt 0 ]; then
+               apt-get update
 
-               echo "Installing package $pkg..."
-               if ! apt-get --assume-yes install "$pkg" &>/dev/null; then
-                       echo "Could not install $pkg"
-                       exit 1
-               fi
-       done
+               for pkg in "${to_install[@]}"; do
+
+                       if ! apt-cache show "$pkg" &>/dev/null; then
+                               echo "Skipped $pkg: Package not found! :("
+                               continue
+                       fi
+
+                       echo "Installing package $pkg..."
+                       if ! apt-get --assume-yes install "$pkg" &>/dev/null; then
+                               echo "Could not install $pkg"
+                               exit 1
+                       fi
+               done
+       fi
 }
 
 echo "Paperless-ngx docker container starting..."