Enhancement: use apt only when needed docker-entrypoint.sh (#7756)

This commit is contained in:
gawa971 2024-09-24 13:46:03 +07:00 committed by GitHub
parent d7ba6d98d3
commit a9b7965dcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
fi
if ! apt-cache show "$pkg" &>/dev/null; then
echo "Package $pkg 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
else
to_install+=("$pkg")
fi
done
# Use apt only when we install packages
if [ ${#to_install[@]} -gt 0 ]; then
apt-get update
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..."