diff --git a/tools/dependency_check.sh b/tools/dependency_check.sh new file mode 100755 index 0000000..a483528 --- /dev/null +++ b/tools/dependency_check.sh @@ -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