summarylogtreecommitdiffstats
path: root/openmemory-backend
blob: dc3e70787790a0cfc571d3e1ef8795f601900985 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
set -euo pipefail

APPDIR="/usr/lib/openmemory-backend/openmemory-js"

STATE_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/openmemory-backend"
DATA_DIR="$STATE_DIR/data"

USER_ENV="${XDG_CONFIG_HOME:-$HOME/.config}/openmemory/openmemory.env"
SYSTEM_ENV="/etc/openmemory/openmemory.env"

mkdir -p "$DATA_DIR"

# Load env (user overrides system)
if [[ -f "$USER_ENV" ]]; then
  set -a; source "$USER_ENV"; set +a
elif [[ -f "$SYSTEM_ENV" ]]; then
  set -a; source "$SYSTEM_ENV"; set +a
fi

# Correct entrypoint for openmemory-js server (matches package.json "start")
entry="$APPDIR/dist/server/index.js"
if [[ ! -f "$entry" ]]; then
  echo "openmemory-backend: expected entrypoint not found: $entry" >&2
  echo "Check that the build produced dist/server/index.js" >&2
  exit 1
fi

cd "$STATE_DIR"
exec node "$entry"