#!/bin/bash
CLIENT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
URL_FILE="$CLIENT_DIR/server_url.txt"
if [ ! -f "$URL_FILE" ]; then
  osascript -e 'display alert "未找到 server_url.txt。"'
  exit 1
fi
URL="$(tr -d '\r\n' < "$URL_FILE")"
if curl -fsS --max-time 5 "$URL/health" >/dev/null 2>&1; then
  osascript -e 'display alert "连接成功。" as informational'
else
  osascript -e 'display alert "连接失败，请检查服务、地址和防火墙。"'
  exit 1
fi
