#!/bin/sh
# Copyright (c) 2026 Athan Clark. SPDX-License-Identifier: GPL-3.0-only
# Imports log files into OpenChronology timelines: och-import-logs --help, and
# /usr/share/doc/openchronology-server/log-import.md. OCH_API_URL and OCH_API_KEY come from
# the environment or, when it has none and the file is readable, /etc/openchronology/syslog.env.
APP=/usr/lib/openchronology
CONFIG=/etc/openchronology/syslog.env
if [ -z "${OCH_API_KEY:-}" ] && [ -r "$CONFIG" ]; then
  exec env OCH_CONFIG="$CONFIG" "$APP/node/bin/node" "$APP/server/import-logs.mjs" "$@"
fi
exec "$APP/node/bin/node" "$APP/server/import-logs.mjs" "$@"
