#!/usr/bin/env bash
set -euo pipefail
if command -v eve-topos-bridge >/dev/null 2>&1 && [ "$(hostname)" != "topos" ]; then
  eve-topos-bridge once >/dev/null 2>&1 || true
fi
if [ -n "${PI_BIN:-}" ] && [ -x "${PI_BIN}" ]; then
  exec "$PI_BIN" "$@"
elif command -v pi >/dev/null 2>&1; then
  exec "$(command -v pi)" "$@"
elif [ -x "$HOME/.local/bin/pi" ]; then
  exec "$HOME/.local/bin/pi" "$@"
else
  echo "Error: 'pi' binary not found." >&2
  exit 1
fi
