#!/usr/bin/env bash
set -euo pipefail

# LocalAI's upstream compose persists these directories as named volumes.
# Ensure existing Umbrel installs have matching host-side bind mount directories
# with ownership suitable for the LocalAI container before startup.
DATA_ROOT="${APP_DATA_ROOT:-${APP_DATA_DIR}/data}"

mkdir -p \
  "${DATA_ROOT}/backends" \
  "${DATA_ROOT}/data" \
  "${DATA_ROOT}/configuration"

chown -R 1000:1000 \
  "${DATA_ROOT}/backends" \
  "${DATA_ROOT}/data" \
  "${DATA_ROOT}/configuration"
