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

TEST_HOST="${TEST_HOST:-player@93.170.12.154}"
TARGET_DOMAIN="${TARGET_DOMAIN:-test.shineup.me}"
REMOTE_UI_DIR="${REMOTE_UI_DIR:-/home/player/SHiNE/shine-ui}"

echo "==> Подготовка Caddy для $TARGET_DOMAIN"
TEST_HOST="$TEST_HOST" \
TARGET_DOMAIN="$TARGET_DOMAIN" \
REMOTE_UI_DIR="$REMOTE_UI_DIR" \
bash "$(dirname "$0")/scripts/install_test_caddyfile.sh"

echo "==> Деплой UI на $TARGET_DOMAIN"
REMOTE_HOST="$TEST_HOST" \
REMOTE_UI_DIR="$REMOTE_UI_DIR" \
EXPECTED_CADDY_UI_ROOT="$REMOTE_UI_DIR" \
EXPECTED_CADDY_SITE="$TARGET_DOMAIN" \
TARGET_URL="https://$TARGET_DOMAIN" \
bash "$(dirname "$0")/deploy_shine-PWA.sh"
