#!/usr/bin/env bash set -euo pipefail DATA_DIR="${DATA_DIR:-/data}" APP_DIR="${APP_DIR:-/app}" MODEL_DIR="$DATA_DIR/models" DB_DIR="$DATA_DIR/dbs" IMAGE_DIR="$DATA_DIR/encrypted_images" BUNDLED_MODEL_DIR="$APP_DIR/data/models" if ! command -v tesseract >/dev/null 2>&1; then echo "tesseract binary is missing; installing tesseract-ocr and English language data." >&2 apt-get update apt-get install -y --no-install-recommends tesseract-ocr tesseract-ocr-eng rm -rf /var/lib/apt/lists/* fi mkdir -p "$DATA_DIR" "$MODEL_DIR" "$DB_DIR" "$IMAGE_DIR" if [ -d "$BUNDLED_MODEL_DIR" ] && [ -z "$(find "$MODEL_DIR" -mindepth 1 -maxdepth 1 -print -quit)" ]; then cp -a "$BUNDLED_MODEL_DIR"/. "$MODEL_DIR"/ fi if [ -d "$APP_DIR/encrypted_images" ] && [ ! -L "$APP_DIR/encrypted_images" ]; then find "$APP_DIR/encrypted_images" -mindepth 1 -maxdepth 1 -exec cp -a {} "$IMAGE_DIR"/ \; rm -rf "$APP_DIR/encrypted_images" elif [ -e "$APP_DIR/encrypted_images" ] && [ ! -L "$APP_DIR/encrypted_images" ]; then rm -f "$APP_DIR/encrypted_images" fi ln -sfn "$IMAGE_DIR" "$APP_DIR/encrypted_images" exec streamlit run Homepage.py \ --server.port=8501 \ --server.address=0.0.0.0 \ --server.enableCORS=false \ --server.enableXsrfProtection=false