Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rafaelcalleja/1fd1b7709f4526f1419c033ce7b334e1 to your computer and use it in GitHub Desktop.

Select an option

Save rafaelcalleja/1fd1b7709f4526f1419c033ce7b334e1 to your computer and use it in GitHub Desktop.
bash: dependency checker
########################################
# BASH DEPENDENCY CHECKER
#
########################################
# create an array of packages depended on
declare -a DEPENDENCIES=(
'pwd' 'curl' 'missing-package'
)
# loop through each dependency. if it doesn't exist,
# recomend a package control install based on what's available
# or, at the very least, echo "Please install $PACKAGE"
for PACKAGE in ${DEPENDENCIES[@]}; do
if [ "$(which "$PACKAGE")" = "" ]; then
echo
echo "Please install $PACKAGE!"
echo
echo -n "Try:"
if [ "$(which brew)" ]; then
echo " $ brew install $PACKAGE"
elif [ "$(which port)" ]; then
echo " $ port install $PACKAGE"
elif [ "$(which apt-get)" ]; then
echo " $ apt-get install $PACKAGE"
elif [ "$(which yum)" ]; then
echo " $ yum install $PACKAGE"
elif [ "$(which rpm)" ]; then
echo " $ rpm --install $PACKAGE"
else
echo
fi
exit 1 # if your name's not on the list, we can't let you in buddy.
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment