forked from viglesiasce/eucadev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vagrant_prep.sh
executable file
·68 lines (60 loc) · 1.7 KB
/
vagrant_prep.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#
# Script to automate the install of vagrant plugins as well
# as Vagrantfile configuration.
#
# Configuration related files
license_file="license.lic"
# Vagrant checks
check_vagrant=$(vagrant -v | wc -l)
# Check if Vagrant is installed
if [ $check_vagrant -eq 0 ] ; then
echo -e "\nVagrant not installed. Please install vagrant and re-run script...exiting.\n"
exit
else
vagrant_loc=`which vagrant`
fi
# Vagrant plugin installs
vagrant_mod() {
for val in ${plugin_checks[@]} ; do
check_plugin=`$vagrant_loc plugin list | grep -c -i $val`
if [ "$check_plugin" -eq "0" ] ; then
echo -e "\nInstalling Vagrant Plugin $val..."
if [ "$val" == "license" ] ; then
if [ -f $license_file ] ; then
$vagrant_loc plugin $val vagrant-vmware-fusion $license_file
else
echo -e "\nVMWARE $license_file file not found. Please obtain valid VMWare license and re-run script...exiting.\n"
exit
fi
else
$vagrant_loc plugin install vagrant-$val
fi
fi
done
echo -e "\nDone!"
}
# Check and/or install vagrant plugins and modify Vagrantfile for VM instance.
case "$1" in
# VirtualBox
vbox)
plugin_checks=("berkshelf" "omnibus")
vagrant_mod
vagrant up
;;
# VMWare
vmware)
plugin_checks=("vmware-fusion" "license")
vagrant_mod
;;
# Amazon Web Service
aws)
plugin_checks=("berkshelf" "omnibus" "aws")
vagrant_mod
;;
*)
echo -e "\nUsage: $0 {vbox|vmware|aws}" >&2
exit 1
;;
esac
exit 0