#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PG_BIN="/usr/lib/postgresql/17/bin"
if [ -d "/Library/PostgreSQL/18/bin" ]; then
  PG_BIN="/Library/PostgreSQL/18/bin"
elif [ -d "/Library/PostgreSQL/17/bin" ]; then
  PG_BIN="/Library/PostgreSQL/17/bin"
fi
PG_DATA="$ROOT_DIR/.local/postgres"

"$PG_BIN/pg_ctl" -D "$PG_DATA" stop
