#!/usr/bin/env bash
# 安裝／更新 nginx conf（需要 sudo）
set -euo pipefail
# shellcheck source=_common.sh
source "$(cd "$(dirname "$0")" && pwd)/_common.sh"

SRC="$DEPLOY_DIR/nginx/haixun-dev.conf"
DST="/etc/nginx/conf.d/haixun.conf"

[[ -f "$SRC" ]] || die "missing $SRC"

log "install $SRC → $DST"
sudo cp "$SRC" "$DST"
sudo nginx -t
sudo systemctl reload nginx
log "nginx reloaded"
log "驗：curl -sI -H 'Host: threads-tool.30cm.net' http://127.0.0.1/api/v1/ping"
