#!/usr/bin/env bash # VPS Installer bootstrap — downloads the latest installer and launches it. # # One command (defaults: HTTPS on 0.0.0.0:8088, login "admin", auto-generated # password printed in the console): # curl -sSL https://vps.myidb.ru/files/bootstrap.sh | bash # # Override any of them: # curl -sSL https://vps.myidb.ru/files/bootstrap.sh | bash -s -- \ # --ip 0.0.0.0 --port 8443 --login admin --password S3cur3Pass [--no-tls] set -euo pipefail INSTALL_DIR="/opt/vps-installer" BASE_URL="${INSTALLER_BASE_URL:-https://vps.myidb.ru/files}" ARGS=() # passed through to the installer while [[ $# -gt 0 ]]; do case "$1" in --dir) INSTALL_DIR="$2"; shift 2 ;; --no-tls) ARGS+=("--no-tls"); shift ;; --ip|--port|--login|--password) ARGS+=("$1" "$2"); shift 2 ;; -h|--help) echo "Usage: bootstrap.sh [--ip IP] [--port N] [--login L] [--password P] [--no-tls] [--dir DIR]" echo "No options: HTTPS on 0.0.0.0:8088, login admin, auto-generated password (printed below)." exit 0 ;; *) ARGS+=("$1"); shift ;; esac done ARCH="$(uname -m)" case "$ARCH" in x86_64) BINARY_ARCH="amd64" ;; aarch64|arm64) BINARY_ARCH="arm64" ;; *) echo "ERROR: unsupported architecture: $ARCH" >&2; exit 1 ;; esac DOWNLOAD_URL="${BASE_URL%/}/vps-installer-linux-${BINARY_ARCH}" mkdir -p "$INSTALL_DIR" BINARY_PATH="$INSTALL_DIR/vps-installer" echo "==> Downloading vps-installer ($BINARY_ARCH) ..." if command -v curl >/dev/null 2>&1; then curl -fsSL "$DOWNLOAD_URL" -o "$BINARY_PATH" elif command -v wget >/dev/null 2>&1; then wget -qO "$BINARY_PATH" "$DOWNLOAD_URL" else echo "ERROR: neither curl nor wget is available." >&2; exit 1 fi chmod +x "$BINARY_PATH" # The installer needs root (writes /etc/*, systemd units, firewall). Use sudo only # when a terminal is available for a possible password prompt. RUN=("$BINARY_PATH") if [ "$(id -u)" -ne 0 ]; then if command -v sudo >/dev/null 2>&1 && [ -t 1 ]; then RUN=(sudo "$BINARY_PATH") else echo "NOTE: run as root (or via sudo) — the installer configures system services." >&2 fi fi echo "==> Starting VPS Installer (Ctrl+C to stop)..." if [ ${#ARGS[@]} -gt 0 ]; then exec "${RUN[@]}" "${ARGS[@]}" else exec "${RUN[@]}" fi