-
Notifications
You must be signed in to change notification settings - Fork 8
/
setupEnv.sh
124 lines (109 loc) · 2.69 KB
/
setupEnv.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
#!/bin/bash
# Some of this was taken from https://gist.github.com/phatblat/1713458
NPM_VERSION=6.4.0
NODE_VERSION=`cat .nvmrc`
# Save script's current directory
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#
# Check if Homebrew is installed
#
which -s brew
if [[ $? != 0 ]] ; then
# Install Homebrew
# https://github.com/mxcl/homebrew/wiki/installation
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
brew update
fi
#
# Check if Git is installed
#
which -s git || brew install git
#
# Check if Node is installed and at the right version
#
echo "Checking for Node version ${NODE_VERSION}"
node --version | grep ${NODE_VERSION}
if [[ $? != 0 ]] ; then
# Install Node
cd `brew --prefix`
$(brew versions node | grep ${NODE_VERSION} | cut -c 16- -)
brew install node
# Reset Homebrew formulae versions
git reset HEAD `brew --repository` && git checkout -- `brew --repository`
fi
curDir=$PWD
cd /tmp
#
# Check if Node Package Manager is installed and at the right version
#
echo "Checking for NPM version ${NPM_VERSION}"
npm --version || grep ${NPM_VERSION}
if [[ $? != 0 ]] ; then
echo "Downloading npm"
git clone git://github.com/isaacs/npm.git && cd npm
git checkout v${NPM_VERSION}
make install
fi
cd $curDir
#
# MongoDB
#
if brew ls --versions mongo > /dev/null; then
# The package is installed!
echo "Mongo already installed."
else
# The package is not installed
brew install mongodb
echo 'Creating a folder for mongodb at /data/db. Please enter password.'
sudo mkdir -p /data/db
echo 'Setting up proper permissions for /data/db. Please enter password.'
sudo chown -R `id -un` /data/db
fi
if brew ls --versions docker > /dev/null; then
# The package is installed!
echo "Docker already installed."
else
# The package is not installed
echo "Installing Docker..."
curl -fsSL get.docker.com -o ${DIR}/get-docker.sh
sh get-docker.sh
fi
#
# Kubectl
#
if brew ls --versions kubernetes-cli > /dev/null; then
# The package is installed!
echo "kubernetes-cli already installed."
else
# The package is not installed
echo "Installing kubernetes-cli..."
brew install kubernetes-cli
fi
#
# gcloud
#
which -s gcloud
if [[ $? != 0 ]]; then
# The package is not installed
echo "Installing gcloud..."
brew tap caskroom/cask
brew cask install google-cloud-sdk
else
# The package is installed!
echo "gcloud already installed."
fi
#
# Create .env file
#
if [ ! -f ./.env ]; then
echo "Creating .env file. IMPORTANT: YOU MUST FILL THIS STUFF IN!"
cp ./.env.example ./.env
else
echo ".env file already created."
fi
#
# NPM install
#
echo "installing npm modules."
npm install