#!/bin/bash # Volt Network Benchmark - Dependency Setup # Run on both client and server VMs set -e echo "=== Volt Network Benchmark Setup ===" echo "" # Detect package manager if command -v apt-get &> /dev/null; then PKG_MGR="apt" INSTALL_CMD="sudo apt-get install -y" UPDATE_CMD="sudo apt-get update" elif command -v dnf &> /dev/null; then PKG_MGR="dnf" INSTALL_CMD="sudo dnf install -y" UPDATE_CMD="sudo dnf check-update || true" elif command -v yum &> /dev/null; then PKG_MGR="yum" INSTALL_CMD="sudo yum install -y" UPDATE_CMD="sudo yum check-update || true" else echo "ERROR: Unsupported package manager" exit 1 fi echo "[1/5] Updating package cache..." $UPDATE_CMD echo "" echo "[2/5] Installing iperf3..." $INSTALL_CMD iperf3 echo "" echo "[3/5] Installing netperf..." if [ "$PKG_MGR" = "apt" ]; then $INSTALL_CMD netperf || { echo "netperf not in repos, building from source..." $INSTALL_CMD build-essential autoconf automake cd /tmp git clone https://github.com/HewlettPackard/netperf.git cd netperf ./autogen.sh ./configure make sudo make install cd - } else $INSTALL_CMD netperf || { echo "netperf not in repos, building from source..." $INSTALL_CMD gcc make autoconf automake cd /tmp git clone https://github.com/HewlettPackard/netperf.git cd netperf ./autogen.sh ./configure make sudo make install cd - } fi echo "" echo "[4/5] Installing sockperf..." if [ "$PKG_MGR" = "apt" ]; then $INSTALL_CMD sockperf 2>/dev/null || { echo "sockperf not in repos, building from source..." $INSTALL_CMD build-essential autoconf automake libtool cd /tmp git clone https://github.com/Mellanox/sockperf.git cd sockperf ./autogen.sh ./configure make sudo make install cd - } else $INSTALL_CMD sockperf 2>/dev/null || { echo "sockperf not in repos, building from source..." $INSTALL_CMD gcc-c++ make autoconf automake libtool cd /tmp git clone https://github.com/Mellanox/sockperf.git cd sockperf ./autogen.sh ./configure make sudo make install cd - } fi echo "" echo "[5/5] Installing additional utilities..." $INSTALL_CMD jq bc ethtool 2>/dev/null || true echo "" echo "=== Verifying Installation ===" echo "" check_tool() { if command -v "$1" &> /dev/null; then echo "✓ $1: $(command -v $1)" else echo "✗ $1: NOT FOUND" return 1 fi } FAILED=0 check_tool iperf3 || FAILED=1 check_tool netperf || FAILED=1 check_tool netserver || FAILED=1 check_tool sockperf || FAILED=1 check_tool jq || echo " (jq optional, JSON parsing may fail)" check_tool bc || echo " (bc optional, calculations may fail)" echo "" if [ $FAILED -eq 0 ]; then echo "=== Setup Complete ===" echo "" echo "To start servers (run on server VM):" echo " iperf3 -s -D" echo " sockperf sr --daemonize" echo " netserver" else echo "=== Setup Incomplete ===" echo "Some tools failed to install. Check errors above." exit 1 fi