mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 10:34:06 +02:00
+18

![stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)
![dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)






Anthony Stirling
GitHub
ConnorYoh
Connor Yoh
OUNZAR Aymane
YAOU Reda
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com>
Balázs Szücs
Ludy
tkymmm
Peter Dave Hello
albanobattistella
PingLin8888
FdaSilvaYY
Copilot
OteJlo
Angel
Ricardo Catarino
Luis Antonio Argüelles González
Dawid Urbański
Stephan Paternotte
Leonardo Santos Paulucio
hamza khalem
IT Creativity + Art Team
Reece Browne
James Brunton
Victor Villarreal
68ed54e398
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Balázs Szücs <[email protected]> Signed-off-by: stirlingbot[bot] <stirlingbot[bot]@users.noreply.github.com> Co-authored-by: ConnorYoh <[email protected]> Co-authored-by: Connor Yoh <[email protected]> Co-authored-by: OUNZAR Aymane <[email protected]> Co-authored-by: YAOU Reda <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com> Co-authored-by: Balázs Szücs <[email protected]> Co-authored-by: Ludy <[email protected]> Co-authored-by: tkymmm <[email protected]> Co-authored-by: Peter Dave Hello <[email protected]> Co-authored-by: albanobattistella <[email protected]> Co-authored-by: PingLin8888 <[email protected]> Co-authored-by: FdaSilvaYY <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: OteJlo <[email protected]> Co-authored-by: Angel <[email protected]> Co-authored-by: Ricardo Catarino <[email protected]> Co-authored-by: Luis Antonio Argüelles González <[email protected]> Co-authored-by: Dawid Urbański <[email protected]> Co-authored-by: Stephan Paternotte <[email protected]> Co-authored-by: Leonardo Santos Paulucio <[email protected]> Co-authored-by: hamza khalem <[email protected]> Co-authored-by: IT Creativity + Art Team <[email protected]> Co-authored-by: Reece Browne <[email protected]> Co-authored-by: James Brunton <[email protected]> Co-authored-by: Victor Villarreal <[email protected]>
111 lines
3.4 KiB
Bash
111 lines
3.4 KiB
Bash
#!/bin/bash
|
|
# This script initializes environment variables and paths,
|
|
# prepares Tesseract data directories, and then runs the main init script.
|
|
|
|
set -euo pipefail
|
|
|
|
append_env_path() {
|
|
local target="$1" current="$2" separator=":"
|
|
if [ -d "$target" ] && [[ ":${current}:" != *":${target}:"* ]]; then
|
|
if [ -n "$current" ]; then
|
|
printf '%s' "${target}${separator}${current}"
|
|
else
|
|
printf '%s' "${target}"
|
|
fi
|
|
else
|
|
printf '%s' "$current"
|
|
fi
|
|
}
|
|
|
|
python_site_dir() {
|
|
local venv_dir="$1"
|
|
local python_bin="$venv_dir/bin/python"
|
|
if [ -x "$python_bin" ]; then
|
|
local py_tag
|
|
if py_tag="$("$python_bin" -c 'import sys; print(f"python{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null)" \
|
|
&& [ -n "$py_tag" ] \
|
|
&& [ -d "$venv_dir/lib/$py_tag/site-packages" ]; then
|
|
printf '%s' "$venv_dir/lib/$py_tag/site-packages"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# === LD_LIBRARY_PATH ===
|
|
# Adjust the library path depending on CPU architecture.
|
|
ARCH=$(uname -m)
|
|
case "$ARCH" in
|
|
x86_64)
|
|
[ -d /usr/lib/x86_64-linux-gnu ] && export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
|
;;
|
|
aarch64)
|
|
[ -d /usr/lib/aarch64-linux-gnu ] && export LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
|
;;
|
|
esac
|
|
|
|
# Add LibreOffice program directory to library path if available.
|
|
if [ -d /usr/lib/libreoffice/program ]; then
|
|
export LD_LIBRARY_PATH="/usr/lib/libreoffice/program${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
|
fi
|
|
|
|
# === Python PATH ===
|
|
# Add virtual environments to PATH and PYTHONPATH.
|
|
for dir in /opt/venv/bin /opt/unoserver-venv/bin; do
|
|
PATH="$(append_env_path "$dir" "$PATH")"
|
|
done
|
|
export PATH
|
|
|
|
PYTHON_PATH_ENTRIES=()
|
|
for venv in /opt/venv /opt/unoserver-venv; do
|
|
if [ -d "$venv" ]; then
|
|
site_dir="$(python_site_dir "$venv")"
|
|
[ -n "${site_dir:-}" ] && PYTHON_PATH_ENTRIES+=("$site_dir")
|
|
fi
|
|
done
|
|
if [ ${#PYTHON_PATH_ENTRIES[@]} -gt 0 ]; then
|
|
PYTHONPATH="$(IFS=:; printf '%s' "${PYTHON_PATH_ENTRIES[*]}")${PYTHONPATH:+:$PYTHONPATH}"
|
|
export PYTHONPATH
|
|
fi
|
|
|
|
# # === tessdata ===
|
|
# # Prepare Tesseract OCR data directory.
|
|
REAL_TESSDATA="/usr/share/tesseract-ocr/5/tessdata"
|
|
SEC_TESSDATA="/usr/share/tessdata"
|
|
|
|
log_warn() {
|
|
echo "[init][warn] $*" >&2
|
|
}
|
|
|
|
if [ -d "$REAL_TESSDATA" ] && [ -w "$REAL_TESSDATA" ]; then
|
|
log_warn "Skipping tessdata adjustments; directory writable: $REAL_TESSDATA"
|
|
else
|
|
log_warn "Skipping tessdata adjustments; directory missing or not writable: $REAL_TESSDATA"
|
|
fi
|
|
|
|
if [ -d /usr/share/tesseract-ocr/5/tessdata ]; then
|
|
REAL_TESSDATA="/usr/share/tesseract-ocr/5/tessdata"
|
|
log_warn "Using /usr/share/tesseract-ocr/5/tessdata as TESSDATA_PREFIX"
|
|
elif [ -d /usr/share/tessdata ]; then
|
|
REAL_TESSDATA="/usr/share/tessdata"
|
|
log_warn "Using /usr/share/tessdata as TESSDATA_PREFIX"
|
|
elif [ -d /tessdata ]; then
|
|
REAL_TESSDATA="/tessdata"
|
|
log_warn "Using /tessdata as TESSDATA_PREFIX"
|
|
else
|
|
REAL_TESSDATA=""
|
|
log_warn "No tessdata directory found"
|
|
fi
|
|
|
|
if [ -n "$REAL_TESSDATA" ]; then
|
|
export TESSDATA_PREFIX="$REAL_TESSDATA"
|
|
fi
|
|
|
|
# === Temp dir ===
|
|
# Ensure the temporary directory exists and has proper permissions.
|
|
mkdir -p /tmp/stirling-pdf
|
|
chown -R stirlingpdfuser:stirlingpdfgroup /tmp/stirling-pdf || true
|
|
chmod -R 755 /tmp/stirling-pdf || true
|
|
|
|
# === Start application ===
|
|
# Run the main init script that handles the full startup logic.
|
|
exec /scripts/init-without-ocr.sh
|