#!/bin/bash
# setup-client.sh — client / peer node setup.
#
# Clients run local training + (star) the Flower client or (mesh) the gossip
# peer. Data is either generated on-node (pq_synth) or fetched at train time
# (vsb, via kagglehub) — no staging step here; this wrapper ensures the common
# stack plus iproute2 for tc netem link perturbation.
#
# Usage:  bash setup-client.sh [true|false|auto] [cuda_tag]
# Install is configurable via FL_CUDA_TAG / FL_NVIDIA_DRIVER / FL_TORCH_SPEC /
# FL_USE_GPU env vars too (see setup-common.sh); args below are forwarded through.
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

echo "### PROGRESS: [setup-client] running common setup"
bash "$SCRIPT_DIR/setup-common.sh" "$@"

# tc (from iproute2) is needed for fl.perturb; installed by common, verify here.
if ! command -v tc >/dev/null 2>&1; then
    sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq iproute2 >/dev/null || true
fi

echo "### PROGRESS: [setup-client] client/peer ready"
