#!/usr/bin/env bash # Install vim/nano/less/jq on every kind node (the real exam has an editor on each node). # Re-run this after ./setup.sh if the install was skipped or the network was down. # ./node-tools.sh [TRACK] the nodes of TRACK's cluster (default: the track ./exam defaults to) set -euo pipefail cd "$(dirname "$0")" RT="${CONTAINER_RUNTIME:-$(cat .state/runtime 2>/dev/null || echo podman)}" [ "$RT" = podman ] && export KIND_EXPERIMENTAL_PROVIDER=podman cluster=$(./exam ${1:+--track "$1"} cluster-env | sed -n 's/^CLUSTER=//p') for n in $(kind get nodes --name "$cluster"); do printf '%s: ' "$n" if "$RT" exec "$n" sh -c 'command -v vim >/dev/null'; then echo "already has vim"; continue; fi if "$RT" exec "$n" sh -c 'DEBIAN_FRONTEND=noninteractive apt-get update -qq >/dev/null 2>&1 && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq vim nano less jq >/dev/null 2>&1'; then "$RT" exec "$n" sh -c 'printf "set tabstop=2\nset expandtab\nset shiftwidth=2\n" > /root/.vimrc' echo ok else echo "FAILED (no outbound network?)" fi done