#!/usr/bin/env bash
# This script sets up the necessary directories and permissions for model-cache and tsdata that were added after the initial release of the app.

set -euo pipefail

APP_DATA_DIR="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)/data"
MODEL_CACHE_DIR="${APP_DATA_DIR}/model-cache"
TYPESENSE_DIR="${APP_DATA_DIR}/tsdata"

[ ! -d "${MODEL_CACHE_DIR}" ] && mkdir -p "${MODEL_CACHE_DIR}" && chown 1000:1000 "${MODEL_CACHE_DIR}"
[ ! -d "${TYPESENSE_DIR}" ] && mkdir -p "${TYPESENSE_DIR}" && chown 1000:1000 "${TYPESENSE_DIR}"