This repository has been archived by the owner on Dec 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
245 lines (185 loc) · 6.19 KB
/
main.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#! /bin/bash
# apt-get
## Update all the things
sudo apt-get -y update
## Build essential ssl and git
sudo apt-get -y install build-essential libssl-dev git-core
## Curl
sudo apt-get -y install curl
## Install Memcached
sudo apt-get -y install memcached
## Install Python
sudo apt-get -y install python-dev
## Install PostgreSQL
sudo apt-get -y install libpq-dev postgresql
## Install redis
sudo apt-get -y install redis-server
## Install nginx
sudo apt-get -y install nginx
## Install MongoDB
sudo apt-get -y install mongodb
## Install Docker.io
sudo apt-get -y install docker.io
## Install unattended-upgrades
sudo apt-get install -y unattended-upgrades
# Node.js
git clone https://github.com/creationix/nvm.git /home/vagrant/.nvm
echo "[ -s /home/vagrant/.nvm/nvm.sh ] && . /home/vagrant/.nvm/nvm.sh # This loads NVM" >> /home/vagrant/.bash_profile
source /home/vagrant/.nvm/nvm.sh
nvm install 0.10
nvm alias default 0.10
sudo chown -R vagrant:vagrant /home/vagrant/.nvm/
source /home/vagrant/.bash_profile
# Node.js Libs
## Gulp CLI
npm install -g gulp
## Ember CLI
npm install -g ember-cli
## Grunt CLI
npm install -g grunt-cli
## Bower
npm install -g bower
# Heroku
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
# Nginx config
sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
sudo cat > /etc/nginx/nginx.conf <<EOF
"user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable \"msie6\";
# gzip_vary on;
gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}"
EOF
# pip
sudo wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo python ez_setup.py
sudo easy_install pip
# PostgreSQL
sudo -u postgres createdb development
sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password 'password';"
echo "listen_addresses = '*'" | sudo -u postgres tee -a /etc/postgresql/9.1/main/postgresql.conf
echo "host all all 0.0.0.0/0 md5" | sudo -u postgres tee -a /etc/postgresql/9.1/main/pg_hba.conf
sudo service postgresql restart
# Profile
echo "alias ls='ls -lah --color'" >> /home/vagrant/.bash_profile
echo "export GREP_OPTIONS='--color=auto'" >> /home/vagrant/.bash_profile
echo "export CLICOLOR=1" >> /home/vagrant/.bash_profile
echo "export LS_COLORS='di=33:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35'" >> /home/vagrant/.bash_profile
# prompt
PROMPTCONFIG=$(cat <<EOM
if [[ \$COLORTERM = gnome-* && \$TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m' # Black - Background
bakred='\e[41m' # Red
badgrn='\e[42m' # Green
bakylw='\e[43m' # Yellow
bakblu='\e[44m' # Blue
bakpur='\e[45m' # Purple
bakcyn='\e[46m' # Cyan
bakwht='\e[47m' # White
txtrst='\e[0m' # Text Reset
function parse_git_dirty() {
[[ \$(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1\$(parse_git_dirty)/"
}
PS1="\[\${txtgrn}\]\u \[\${bldblu}\]at \[\${txtylw}\]\h \[\${bldblu}\]in \[\${bldred}\]\w\[\${bldblu}\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[\${txtpur}\]\$(parse_git_branch)\[\${bldblu}\]\n\$ \[\${txtrst}\]"
EOM
)
echo "$PROMPTCONFIG" >> /home/vagrant/.bash_profile
# redis
sudo sed -i 's/bind 127.0.0.1/# bind 127.0.0.1/g' /etc/redis/redis.conf
sudo echo 'vm.overcommit_memory = 1' | sudo tee -a /etc/sysctl.conf
sudo sysctl vm.overcommit_memory=1
sudo service redis-server restart
# ssh
## Disallow root SSH access
sudo sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
## Disallow password authentication
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config
## Restart ssh
sudo service ssh restart
# Go
wget -P /home/vagrant/ http://golang.org/dl/go1.3.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.3.linux-amd64.tar.gz
echo "export GOROOT=$HOME/go" >> /home/vagrant/.bash_profile
echo "export PATH=$PATH:/usr/local/go/bin" >> /home/vagrant/.bash_profile