mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Transitions the Docker image to use s6 and s6-overlay for process supervision instead of supervisord (#8886)
This commit is contained in:
65
docker/rootfs/etc/s6-overlay/s6-rc.d/init-tesseract-langs/run
Executable file
65
docker/rootfs/etc/s6-overlay/s6-rc.d/init-tesseract-langs/run
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/command/with-contenv /usr/bin/bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
declare -r log_prefix="[init-tesseract-langs]"
|
||||
|
||||
install_languages() {
|
||||
echo "Installing languages..."
|
||||
|
||||
read -ra langs <<<"$1"
|
||||
|
||||
# Check that it is not empty
|
||||
if [ ${#langs[@]} -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# 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 "${log_prefix} Package $pkg already installed!"
|
||||
continue
|
||||
else
|
||||
to_install+=("$pkg")
|
||||
fi
|
||||
done
|
||||
|
||||
# Use apt only when we install packages
|
||||
if [ ${#to_install[@]} -gt 0 ]; then
|
||||
|
||||
# Warn the user if they're not root, but try anyway
|
||||
if [[ -n "${USER_IS_NON_ROOT}" ]]; then
|
||||
echo "${log_prefix} ERROR: Unable to install language ${pkg} as non-root, startup may fail"
|
||||
fi
|
||||
|
||||
apt-get --quiet update &>/dev/null
|
||||
|
||||
for pkg in "${to_install[@]}"; do
|
||||
if ! apt-cache --quiet show "$pkg" &>/dev/null; then
|
||||
echo "${log_prefix} Skipped $pkg: Package not found! :("
|
||||
continue
|
||||
fi
|
||||
echo "${log_prefix} Installing package $pkg..."
|
||||
if ! apt-get --quiet --assume-yes install "$pkg" &>/dev/null; then
|
||||
echo "${log_prefix} Could not install $pkg"
|
||||
exit 1
|
||||
else
|
||||
echo "${log_prefix} Installed $pkg"
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
echo "${log_prefix} Checking if additional teseract languages needed"
|
||||
|
||||
# Install additional languages if specified
|
||||
if [[ -n "$PAPERLESS_OCR_LANGUAGES" ]]; then
|
||||
|
||||
install_languages "$PAPERLESS_OCR_LANGUAGES"
|
||||
echo "${log_prefix} Additional packages installed"
|
||||
else
|
||||
echo "${log_prefix} No additional installs requested"
|
||||
fi
|
Reference in New Issue
Block a user