Created
July 9, 2020 17:30
-
-
Save apolzek/d941a67a1757bfb6de519c3110c783ec to your computer and use it in GitHub Desktop.
Checks and installs dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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