Skip to content

Instantly share code, notes, and snippets.

@apolzek
Created July 9, 2020 17:30
Show Gist options
  • Save apolzek/d941a67a1757bfb6de519c3110c783ec to your computer and use it in GitHub Desktop.
Save apolzek/d941a67a1757bfb6de519c3110c783ec to your computer and use it in GitHub Desktop.
Checks and installs dependencies
#!/bin/bash
requires=(helm kubectl testscript anothertest)
function check_dependencies() {
for item in "${requires[@]}"; do
if [ -z $(which $item) ]; then
echo "[Alert] $item: not found"
else
echo "$item: installed"
fi
done
}
function install_missing_dependencies() {
for item in "${requires[@]}"; do
if ! which $item >/dev/null; then
echo -e "$item not found! Install? (y/n) \c"
read
if [ "$REPLY" == "y" ]; then
sudo apt-get install $item -y
fi
fi
done
}
install_missing_dependencies
check_dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment