#!/usr/bin/env bash
# Thin bootstrap: downloads the canonical installer from a configurable base URL.
#
# Examples:
#   curl -fsSL https://www.yakpanel.com/YakPanel-server/install-curl.sh | sudo bash
#   YAKPANEL_INSTALLER_BASE=https://mirror.example.com/YakPanel-server curl -fsSL ... | sudo -E bash
#
# Environment:
#   YAKPANEL_INSTALLER_BASE  Directory URL containing install.sh (no trailing path to install.sh)
#   YAKPANEL_INSTALL_URL      Full URL to install.sh (overrides BASE if set)

set -euo pipefail

if [ "${EUID:-$(id -u)}" -ne 0 ]; then
  echo "Run as root: curl -fsSL ... | sudo -E bash"
  exit 1
fi

BASE="${YAKPANEL_INSTALLER_BASE:-https://www.yakpanel.com/YakPanel-server}"
URL="${YAKPANEL_INSTALL_URL:-${BASE%/}/install.sh}"

echo "Using installer URL: $URL"
exec bash <(curl -fsSL "$URL")
