Check for dependencies.
This commit is contained in:
42
tools/dependency_check.sh
Executable file
42
tools/dependency_check.sh
Executable 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
|
||||
Reference in New Issue
Block a user