#!/usr/bin/env bash
# Delegate to the canonical installer using this repo tree as source (no git clone).
# Run from anywhere after clone:
#   sudo bash scripts/install.sh
# Or with options:
#   sudo bash scripts/install.sh --install-path /opt/YakPanel-server

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

if [ ! -d "$REPO_ROOT/backend" ] || [ ! -d "$REPO_ROOT/frontend" ]; then
  echo "Expected YakPanel-server layout: $REPO_ROOT must contain backend/ and frontend/"
  exit 1
fi

export YAKPANEL_SOURCE_DIR="$REPO_ROOT"
exec bash "$REPO_ROOT/install.sh" "$@"
