bootstrap.sh: require python3 + PyYAML (used by homelab CLI)

The homelab CLI imports yaml; missing on a fresh LXC. Preflight now
checks and emits the right install hint per OS.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
root
2026-05-20 16:31:28 +02:00
parent de6f8bec42
commit 3c9d2f975d

View File

@@ -103,16 +103,28 @@ echo "[bootstrap] hostname: $HNAME"
# Check dependencies.
missing=()
for cmd in git; do command -v "$cmd" >/dev/null || missing+=("$cmd"); done
for cmd in git python3; do command -v "$cmd" >/dev/null || missing+=("$cmd"); done
# The homelab CLI needs PyYAML.
if ! python3 -c "import yaml" >/dev/null 2>&1; then
missing+=("python3-yaml")
fi
if [ "$NO_SECRETS" -eq 0 ]; then
for cmd in age sops; do command -v "$cmd" >/dev/null || missing+=("$cmd"); done
fi
if [ "${#missing[@]}" -gt 0 ]; then
echo "missing required tools: ${missing[*]}" >&2
if [ "$OS" = "Darwin" ]; then
echo " brew install ${missing[*]}"
# Translate Debian package names to brew/pip equivalents.
brew_list=()
for m in "${missing[@]}"; do
case "$m" in
python3-yaml) echo " pip3 install pyyaml (or brew install pyyaml)" >&2 ;;
*) brew_list+=("$m") ;;
esac
done
[ "${#brew_list[@]}" -gt 0 ] && echo " brew install ${brew_list[*]}" >&2
else
echo " apt install -y ${missing[*]} (or platform equivalent)"
echo " apt install -y ${missing[*]}" >&2
fi
exit 1
fi