-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·151 lines (136 loc) · 4.81 KB
/
setup.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
distro=`uname`
if [ $EUID == 0 ]
then
>&2 echo "This script can not be run as root (it will ask for privileges when needed)!"
exit 1
fi
if [ $distro != "Darwin" ]
then
. /etc/os-release
distro=${ID}${VERSION_ID}
fi
case $distro in
ubuntu*|neon*|debian*)
sudo apt-get update > /dev/null
install_command="sudo apt-get -qq -y install"
;;
Darwin*)
install_command="brew install"
;;
*)
echo -e "Don't know how to install packages on $distro.\n"
exit 1
;;
esac
# recommended versions
vbox_version_good=7.0.4
vagrant_version_good=2.3.3
mutagen_version_good=0.16.2
cd /tmp
vmware_version=`vmrun --version 2> /dev/null | grep "vmrun version"`
vagrant_version=`vagrant --version 2> /dev/null`
vbox_version=`VBoxManage --version 2> /dev/null`
if [ -z "$vagrant_version" ]
then
echo "vagrant not found, installing..."
if [[ -z "$vbox_version" && -z "$vmware_version" ]]
then
echo "VirtualBox not found, installing first..."
$install_command virtualbox
default_dhcp=$(VBoxManage list dhcpservers | grep NetworkName: | awk '{print $2}')
VBoxManage dhcpserver remove --netname ${default_dhcp} # workaround https://github.com/hashicorp/vagrant/issues/3083
vbox_version=`VBoxManage --version`
elif [[ -n "$vbox_version" ]]
then
echo "VirtualBox version ${vbox_version} found!"
elif [[ -n "$vmware_version" ]]
then
echo "VMware version ${vmware_version} found!"
fi
regex='([0-9]+\.[0-9]+\.[0-9]+).*'
if [[ $vbox_version =~ $regex ]]
then
vbox_version=${BASH_REMATCH[1]}
fi
if [[ -n "$vbox_version" ]]
then
vbox_extension=`VBoxManage list extpacks`
echo "vbox_extension: $vbox_extension"
regex='Pack no\. .*:.*Oracle VM VirtualBox Extension Pack'
if [[ $vbox_extension =~ $regex ]]
then
echo "VirtualBox Extension Pack found!"
else
echo "Installing VirtualBox extension pack. This requires sudo, your password may be required"
filename="Oracle_VM_VirtualBox_Extension_Pack-${vbox_version}.vbox-extpack"
curl -L -O "https://download.virtualbox.org/virtualbox/${vbox_version}/${filename}"
sudo VBoxManage extpack install "${filename}"
fi
fi
case $distro in
ubuntu*|neon*)
$install_command ruby-dev
curl -L -O https://releases.hashicorp.com/vagrant/${vagrant_version_good}/vagrant_${vagrant_version_good}_`arch`.deb
$install_command ./vagrant_${vagrant_version_good}_`arch`.deb
;;
*)
$install_command vagrant
;;
esac
if [ $? -eq 0 ]
then
echo "Installing winrm Ruby gem..."
sudo gem install winrm
sudo gem install winrm-elevated
fi
vagrant_version=`vagrant --version | awk '{print $2}'`
else
echo "vagrant version ${vagrant_version} found!"
fi
if [[ -n "$vmware_version" ]]
then
echo "VWmare found, checking vagrant plugin..."
vagrant_vmware=`vagrant plugin list | grep vmware`
if [ -z "$vagrant_vmware" ]
then
echo "... installing"
vagrant plugin install vagrant-vmware-desktop
echo "You might still need to install the VMware vagrant utility"
fi
fi
mutagen_version=`mutagen version 2> /dev/null`
if [ $? -gt 0 ]
then
echo "Mutagen not found, installing"
if [ $distro == "Darwin" ]
then
brew install mutagen-io/mutagen/mutagen
else
filename="mutagen_linux_amd64_v${mutagen_version_good}.tar.gz"
curl -O -L https://github.com/mutagen-io/mutagen/releases/download/v${mutagen_version_good}/${filename}
sudo mkdir -p /opt/mutagen
if sudo tar -xf "${filename}" -C /opt/mutagen
then sudo ln -s /opt/mutagen/mutagen /usr/local/bin/mutagen
fi
fi
mutagen_version=`mutagen version`
else
echo "mutagen version ${mutagen_version} found!"
fi
cd - > /dev/null
if [ -d "/usr/local/bin" ]
then
echo "Linking minicoin to /usr/local/bin"
sudo ln -fs $PWD/minicoin/minicoin /usr/local/bin/minicoin
fi
minicoin update 2> /dev/null
printf "\nMinicoin set up!\n"
printf "%s: %s\n" "- vagrant version" "$vagrant_version"
[[ "${vagrant_version}" < "${vagrant_version_good}" ]] && echo " You might need to upgrade to version ${vagrant_version_good}!"
printf "%s: %s\n" "- VirtualBox version" "$vbox_version"
[[ "${vbox_version}" < "${vbox_version_good}" ]] && echo " You might need to upgrade to version ${vbox_version_good}!"
printf "%s: %s\n" "- mutagen version" "$mutagen_version"
[[ "${mutagen_version}" < "${mutagen_version_good}" ]] && echo " You might need to upgrade to version ${mutagen_version_good}!"
minicoin list
[[ -z $minicoin_key ]] && printf "\nNote: 'minicoin_key' not set, some boxes will not be available!\n"