Check for dependencies.

This commit is contained in:
Stephane Gourichon
2025-08-05 12:24:13 +02:00
parent 8a283f2877
commit 9efff2d36e

42
tools/dependency_check.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
set -eu
# List of entries: "executable[:package]"
entries=(
"podman"
"podman-compose"
"dig:bind9-dnsutils"
)
missing_packages=()
echo "Checking required executables..."
for entry in "${entries[@]}"; do
IFS=":" read -r cmd pkg <<< "$entry"
# If pkg is empty (no colon found), default package name to executable name
if [ -z "$pkg" ]; then
pkg="$cmd"
fi
if [ -x "$(command -v "$cmd")" ]; then
echo "[FOUND] Executable '$cmd' found."
else
echo "[MISSING] Executable '$cmd' NOT found."
missing_packages+=("$pkg")
fi
done
echo
if [ ${#missing_packages[@]} -eq 0 ]; then
echo "All executables found."
else
echo >&2 "Missing ${#missing_packages[@]} executables."
echo >&2 "Suggested command to install missing packages:"
echo >&2 "sudo apt install --no-install-recommends ${missing_packages[*]}"
exit 1
fi