deskpaw-memory/bin/run-memory

25 lines
661 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
memory_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
device_config="${DESKPAW_DEVICE_CONFIG:-/home/kickpi/.config/deskpaw/device.env}"
if [[ -f "$device_config" ]]; then
set -a
source "$device_config"
set +a
fi
config_dir="${DESKPAW_CONFIG_DIR:-$(dirname "$device_config")}"
memory_config="$config_dir/memory.env"
if [[ -f "$memory_config" ]]; then
set -a
source "$memory_config"
set +a
fi
node_bin="${DESKPAW_NODE_BIN:-$(command -v node || true)}"
if [[ -z "$node_bin" || ! -x "$node_bin" ]]; then
echo "DeskPaw memory cannot find Node.js" >&2
exit 1
fi
cd "$memory_root"
exec "$node_bin" src/server.js