Created
September 6, 2017 19:37
-
-
Save bbaassssiiee/a7fc03324a7c1d7b9ab88b09ed942bb6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
## Manage Vagrant for the first time | |
if [ "$1" == "" ] | |
then | |
VAGRANT=1.9.8 | |
else | |
VAGRANT=$1 | |
fi | |
if [ ! -x /usr/local/bin/vagrant ] | |
then | |
install_vagrant=1 | |
else | |
VAGE=`vagrant -v | awk '{print $2;}'` | |
echo -n "Your vagrant is ${VAGE}, " | |
if [ "${VAGE}" != "${VAGRANT}" ] | |
then | |
echo "vagrant $VAGE is not good we need ${VAGRANT}." | |
uninstall_vagrant=1 | |
install_vagrant=1 | |
else | |
echo "vagrant ${VAGRANT} is good." | |
uninstall_vagrant=0 | |
install_vagrant=0 | |
fi | |
fi | |
if [ "${uninstall_vagrant}" == "1" ] | |
then | |
echo uninstalling vagrant ${VAGE} | |
vagrant destroy -f | |
osascript -e "do shell script \"/bin/rm -rf ${HOME}/.vagrant /opt/vagrant /usr/local/bin/vagrant\" with administrator privileges" | |
fi | |
if [ "${install_vagrant}" == "1" ] | |
then | |
echo installing vagrant ${VAGRANT} | |
wget --directory-prefix=${HOME}/Downloads https://releases.hashicorp.com/vagrant/${VAGRANT}/vagrant_${VAGRANT}.dmg | |
hdiutil mount ${HOME}/Downloads/vagrant_${VAGRANT}.dmg | |
osascript -e "do shell script \"installer -package /Volumes/Vagrant/Vagrant.pkg -target /\" with administrator privileges" | |
hdiutil unmount /Volumes/Vagrant | |
fi | |
echo installing vagrant-vbguest plugin | |
vagrant plugin install vagrant-vbguest | |
if [ ! -f Vagrantfile ] | |
then | |
cp Vagrantfile.dist Vagrantfile | |
fi | |
vagrant box update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment