-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.sh
executable file
·73 lines (65 loc) · 2.02 KB
/
init.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
69
70
71
72
73
#!/bin/sh
msg='OK: Vagrant has been setup: ready for vagrant up [--provider=digital_ocean]'
if which VirtualBox; then
echo Found VirtualBox
VirtualBox --help | line
else
echo 'ACTION REQUIRED: Please install VirtualBox 4.2.18 or later from https://www.virtualbox.org/wiki/Downloads'
msg='(PLEASE RERUN SCRIPT AFTERWARDS)'
fi
if which vagrant; then
echo 'Found vagrant:'
vagrant -v
echo 'Checking vagrant plugins are installed ...'
vagrant plugin list > /tmp/t$$
for plugin in deep_merge vagrant-digitalocean vagrant-vbguest salted-rails
do
if grep $plugin < /tmp/t$$; then
echo Updating plugin $plugin
vagrant plugin update $plugin
else
echo Installing plugin $plugin
vagrant plugin install $plugin
fi
done
else
echo 'ACTION REQUIRED: Please install vagrant 1.3.3 (1.3.4 has a bug) from http://www.vagrantup.com/'
msg='(PLEASE RERUN SCRIPT AFTERWARDS)'
fi
if [ ! -f Vagrantfile ]; then
if [ -f Vagrantfile.example ]; then
if [ -f Vagrantfile ]; then
echo 'Found Vagrantfile (previously copied from example)'
else
echo 'Copying Vagrantfile.example to Vagrantfile (so you can customize it)'
cp Vagrantfile.example Vagrantfile
fi
else
echo WARNING: Vagrantfile.example not found - skipped Vagrantfile setup
msg='(Please run vagrant init in your rails project directory then edit Vagrantfile)'
fi
fi
mkdir -p "$HOME/.vagrant.d"
global_Vagrantfile="$HOME/.vagrant.d/Vagrantfile"
if [ -f "$global_Vagrantfile" ]; then
echo Found global Vagrantfile: $global_Vagrantfile
else
echo "About to set up $global_Vagrantfile"
echo -n "Enter your digital ocean client key (defaul none): "
read client_id
echo -n "Enter your digital ocean API key (defaul none): "
read api_key
if [ -n "$client_id" -a -n "$api_key" ] ; then
echo "
Vagrant.configure('2') do |config|
config.vm.provider :digital_ocean do |provider|
provider.client_id = '$client_id'
provider.api_key = '$api_key'
end
end
" > $global_Vagrantfile
fi
fi
echo
echo "$msg"
exit 0