#!/usr/bin/env bash
# AutoServer installer — Sprint 1 stub (machine bind + core download = Sprint 3)
# Usage: curl -fsSL https://autoserver.org/install.sh | bash -s -- --key as_live_xxxx
set -euo pipefail

KEY=""
while [[ $# -gt 0 ]]; do
  case "$1" in
    --key) KEY="${2:-}"; shift 2 ;;
    *) echo "Unknown argument: $1" >&2; exit 1 ;;
  esac
done

if [[ -z "$KEY" ]]; then
  echo "Required: --key <AUTOSERVER_LICENSE_KEY>" >&2
  echo "Create a key at https://autoserver.org (one key = one server)." >&2
  exit 1
fi

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root." >&2
  exit 1
fi

echo "AutoServer installer"
echo "Key received (not printed). Machine bind and core download are not enabled in this stub."
echo "Sprint 3 will complete this installer."
exit 0
