-
Notifications
You must be signed in to change notification settings - Fork 8
/
Vagrant-provision.sh
executable file
·54 lines (43 loc) · 1.73 KB
/
Vagrant-provision.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
#!/bin/bash
# usage: Vagrant-provision.sh
set -eo pipefail
# deps
sudo apt-get update
echo "installing the essentials"
sudo apt-get install -y curl git mercurial make binutils bison gcc build-essential
echo "installing PostgreSQL"
sudo apt-get install -y postgresql postgresql-contrib
echo "installing redis"
sudo apt-get install -y redis-server
GO_VERSION=go1.4.2
if [ -d /home/vagrant/.gvm ]; then
echo "Already installed gvm"
else
echo "Installing gvm to manage Go versions"
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
fi
echo "installing Go ${GO_VERSION}"
[[ -s "/home/vagrant/.gvm/scripts/gvm" ]] && source "/home/vagrant/.gvm/scripts/gvm"
/home/vagrant/.gvm/bin/gvm install ${GO_VERSION}
gvm use ${GO_VERSION}
echo "installing Godep"
go get -u github.com/tools/godep
echo "installing forego"
go get -u github.com/ddollar/forego
echo "installing reflex"
go get -u github.com/cespare/reflex
echo "populating user's bashrc"
add_gvm_to_path="export PATH=\$PATH:/home/vagrant/.gvm/bin/"
setup_go_command="gvm use ${GO_VERSION}"
default_dir_command="cd \$GOPATH/src/github.com/liveplant/liveplant-server"
fancy_terminal_setup="export PS1=\"\[\$(tput bold)\]\[\$(tput setaf 2)\][\u]\\$ \[\$(tput sgr0)\]\""
profile_file="/home/vagrant/.bashrc"
for command_string in "$add_gvm_to_path" "$setup_go_command" "$default_dir_command" "$fancy_terminal_setup"; do
if ! grep -q "${command_string}" $profile_file; then
echo "${command_string}" >> $profile_file
fi
done
echo "symlinking project directory into GOPATH"
mkdir -p $GOPATH/src/github.com/liveplant
[[ -e $GOPATH/src/github.com/liveplant/liveplant-server ]] || ln -s /vagrant $GOPATH/src/github.com/liveplant/liveplant-server
echo "all done!"