#!/usr/bin/with-contenv bash
# shellcheck shell=bash

# make folders
mkdir -p \
    /config/machine-learning/models \
    "${IMMICH_MEDIA_LOCATION}/library"

# permissions
find /app/immich -path "*/node_modules" -prune -o -exec chown abc:abc {} +
chown -R abc:abc \
    /config
chown abc:abc \
    "${IMMICH_MEDIA_LOCATION}" \
    "${IMMICH_MEDIA_LOCATION}"/*
if [[ "${APPLY_PERMISSIONS}" == "true" ]]; then
    lsiown -R abc:abc "${IMMICH_MEDIA_LOCATION}"
fi
