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

declare -r log_prefix="[init-index]"

echo "${log_prefix} Checking search index..."
cd "${PAPERLESS_SRC_DIR}"
if [[ -n "${USER_IS_NON_ROOT}" ]]; then
	python3 manage.py document_index reindex --if-needed --no-progress-bar
else
	s6-setuidgid paperless python3 manage.py document_index reindex --if-needed --no-progress-bar
fi
