#!/usr/bin/env bash # rocks-ad self-hosted channel installer. # # Usage: # curl -fsSL https://rocksadspanel.rockstreamer.com/downloads/install.sh | bash -s -- # or download it first and inspect it (recommended before piping any # installer to bash): # curl -fsSL https://rocksadspanel.rockstreamer.com/downloads/install.sh -o install.sh # less install.sh # bash install.sh set -euo pipefail LICENSE_KEY="${1:-}" GATEWAY_URL="${GATEWAY_URL:-wss://rockads.rockstreamer.com/agent-ws}" BUNDLE_DIR="${BUNDLE_DIR:-$HOME/rocks-ad-agent}" REPO_URL="https://gitlab.com/rockstreamer/rocks-ad-service/rocks-ad-agent.git" if [ -z "$LICENSE_KEY" ]; then echo "Usage: install.sh " >&2 echo "Get a license key from https://rocksadspanel.rockstreamer.com after logging in." >&2 exit 1 fi if [ "$(uname -s)" != "Linux" ] || [ "$(uname -m)" != "x86_64" ]; then echo "WARNING: this bundle is only verified on Linux x86_64." >&2 echo "Docker Desktop on macOS/Windows does not support the host networking mode this stack relies on for SRT — it will not work correctly there." >&2 read -r -p "Continue anyway? [y/N] " ans [ "${ans:-N}" = "y" ] || exit 1 fi if ! command -v docker >/dev/null 2>&1; then echo "==> Docker not found. Installing Docker Engine via the official convenience script..." echo " (review it yourself first if you'd rather not pipe-to-shell: https://get.docker.com)" curl -fsSL https://get.docker.com | sh echo "==> Docker installed. You may need to log out/in for group membership to take effect," echo " or run the rest of this script with sudo." fi if ! docker compose version >/dev/null 2>&1; then echo "ERROR: 'docker compose' (v2, the plugin, not the standalone docker-compose) is required and wasn't found." >&2 echo "See https://docs.docker.com/compose/install/ for your distro." >&2 exit 1 fi echo "==> Fetching the rocks-ad-agent bundle into $BUNDLE_DIR ..." if [ -d "$BUNDLE_DIR/.git" ]; then git -C "$BUNDLE_DIR" pull --ff-only else git clone --depth 1 "$REPO_URL" "$BUNDLE_DIR" fi cd "$BUNDLE_DIR" cat > .env < If you haven't already, log in to the image registry:" echo " docker login registry.gitlab.com" echo "" read -r -p "Have you run 'docker login registry.gitlab.com' with the credentials from your account contact? [y/N] " loggedin if [ "${loggedin:-N}" != "y" ]; then echo "Run that first, then re-run this script (it's safe to re-run)." >&2 exit 1 fi echo "==> Starting the channel..." docker compose up -d echo "==> Waiting for activation..." for i in $(seq 1 15); do if curl -fsS http://localhost:4108/status 2>/dev/null | grep -q '"connected":true'; then echo "" echo "✓ Connected. This channel is now live and remotely manageable from rocksadspanel." exit 0 fi sleep 2 done echo "" echo "Not connected yet after 30s. Check the logs:" >&2 echo " docker compose -f $BUNDLE_DIR/docker-compose.yml logs license-agent" >&2 exit 1