cka-sim/node-tools.sh
2026-09-06 19:06:10 -06:00

18 lines
898 B
Bash
Executable File

#!/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.
set -euo pipefail
cd "$(dirname "$0")"
RT="${CONTAINER_RUNTIME:-$(cat .state/runtime 2>/dev/null || echo podman)}"
[ "$RT" = podman ] && export KIND_EXPERIMENTAL_PROVIDER=podman
for n in $(kind get nodes --name cka-sim); 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