Created
February 7, 2016 22:24
-
-
Save triplepoint/00e5f015815a25c6f944 to your computer and use it in GitHub Desktop.
Bash function to only install Vagrant plugins if they're not already installed.
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
# This would install vagrant-aws, if it's not already installed | |
# And do nothing if it was already installed. | |
vagrant_plugin_install vagrant-aws |
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
# Don't reinstall Vagrant plugins, if they're already installed | |
# We can always call `vagrant plugin update` explicitly. | |
vagrant_plugin_install () { | |
set +v | |
installed_packages=$(vagrant plugin list | cut -f1 -d' ') | |
if ! [[ $installed_packages =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then | |
vagrant plugin install $1 | |
else | |
echo $'\e[4m''Notice'$'\e[0m'": Vagrant plugin '$1' is already installed. Use 'vagrant plugin update $1' to force an upgrade." | |
fi | |
set -v | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment