From 9efff2d36e1c39cb1fa249dc129b84537c5460c4 Mon Sep 17 00:00:00 2001 From: Stephane Gourichon Date: Tue, 5 Aug 2025 12:24:13 +0200 Subject: [PATCH] Check for dependencies. --- tools/dependency_check.sh | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 tools/dependency_check.sh 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