#!/usr/bin/env bash # scripts/setup-cm5.sh — CM5 Provisioning # Installs necessary dependencies on the CM5 via SSH and syncs the repository. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" cd "$ROOT" CM5_HOST="${1:-}" CM5_USER="${2:-pi}" if [[ -z "$CM5_HOST" ]]; then echo "Usage: ./scripts/setup-cm5.sh [USERNAME]" echo "Example: ./scripts/setup-cm5.sh 192.168.1.50 pi" exit 1 fi echo "==================================================" echo "1. Installing system dependencies on $CM5_HOST..." echo "==================================================" ssh -t "$CM5_USER@$CM5_HOST" << 'EOF' set -e sudo apt-get update sudo apt-get install -y curl lsof iproute2 gawk build-essential pkg-config libssl-dev cmake rsync if ! command -v cargo &> /dev/null; then echo "Installing Rust toolchain..." curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y else echo "Rust is already installed." fi EOF echo "" echo "==================================================" echo "2. Syncing codebase to CM5..." echo "==================================================" rsync -avz --exclude 'target' --exclude '.git' --exclude 'data' --exclude 'paper/_output' ./ "$CM5_USER@$CM5_HOST:~/quic_ecs_dt/" echo "" echo "==================================================" echo "✅ CM5 is configured and code is synced!" echo "==================================================" echo "To start the server benchmarking script, SSH into the CM5:" echo " ssh $CM5_USER@$CM5_HOST" echo " cd ~/quic_ecs_dt" echo " source ~/.cargo/env" echo " RUN_SIMULATOR=0 ./scripts/bench-loss.sh"