-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-env-dev.sh
executable file
·414 lines (358 loc) · 10.3 KB
/
install-env-dev.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
#!/bin/sh
EXTRA_APPS=0
EXTRA_THEME=0
EXTRA_SHELL=0
VERBOSE=/dev/null
dev_install_print_usage() {
cat << EOT
Setup a local development environment.
Usage: $0 [options]
Options:
-h|--help Show this help message
-apps Installs extra apps like Gimp and MySQL Workbench
-fancy-zsh Installs zsh with a bunch of extras
-theme Installs Numix circle theme
-v Shows verbose output
EOT
exit
}
while [ $# -ne 0 ]
do
arg="$1"
case "$arg" in
-h)
dev_install_print_usage
;;
--help)
dev_install_print_usage
;;
-apps)
EXTRA_APPS=1
;;
-fancy-zsh)
EXTRA_SHELL=1
;;
-theme)
EXTRA_THEME=1
;;
-v)
VERBOSE=/dev/stdout
;;
esac
shift
done
echo Removing useless folders
rm -rf ~/Public ~/Templates ~/Videos ~/Music ~/Examples
echo Creating useful folders
for dir in bin
do
if [ ! -d ~/$dir ]
then
mkdir ~/$dir
fi
done
echo Installing PPA\'s
# Google Chrome
if [ ! -f /etc/apt/sources.list.d/google-chrome.list ]
then
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - > $VERBOSE
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list'
fi
# WebUpd8 for Oracle java
sudo add-apt-repository --yes ppa:webupd8team/java > $VERBOSE 2>&1
# Leolik for Notify-OSD
sudo add-apt-repository --yes ppa:leolik/leolik > $VERBOSE 2>&1
echo Updating APT
sudo apt-get update > $VERBOSE
echo Upgrading APT
sudo apt-get --yes dist-upgrade > $VERBOSE
echo Installing software
sudo sh -c 'debconf-set-selections << "mysql-server mysql-server/root_password password "' > $VERBOSE
sudo sh -c 'debconf-set-selections << "mysql-server mysql-server/root_password_again password "' > $VERBOSE
sudo apt-get --yes --force-yes install \
apache2 \
build-essential \
curl \
dos2unix \
dpkg-dev \
git \
git-flow \
google-chrome-stable \
libapache2-mod-php5 \
libnotify-bin \
libnss-winbind \
libsqlite3-dev \
mysql-client \
mysql-server \
nodejs-legacy \
npm \
oracle-java8-installer \
php5 \
php5-cli \
php5-common \
php5-curl \
php5-dev \
php5-gd \
php5-intl \
php5-json \
php5-mcrypt \
php5-memcache \
php5-memcached \
php5-mongo \
php5-mysql \
php5-odbc \
php5-readline \
php5-redis \
php5-sybase \
php5-tidy \
php5-xsl \
php5-xdebug \
php-codesniffer \
php-invoker \
phpmd \
php-pear \
php-timer \
phpunit \
python \
python-pip \
redis-server \
redis-tools \
ruby2.2 \
ruby2.2-dev \
ruby \
ruby-dev \
software-properties-common \
vim \
wget \
whois > $VERBOSE
if [ `which grunt | wc -l` -eq "0" ]
then
echo Installing grunt
sudo npm install -g grunt-cli > $VERBOSE
fi
echo Configuring /etc/nsswitch.conf
sudo sed -ie 's/\(^hosts.*mdns4_minimal\) \(.*$\)/\1 wins \2/' /etc/nsswitch.conf
sudo sed -ie 's/\(wins\( wins\)*\)/wins/g' /etc/nsswitch.conf
sudo sed -ie 's/\sdns//g' /etc/nsswitch.conf
sudo sed -ie 's/files/files dns/g' /etc/nsswitch.conf
echo Increasing Inotify watches limit
if [ `grep fs.inotify.max_user_watches /etc/sysctl.conf | wc -l` -eq "0" ]
then
sudo sh -c 'cat >> /etc/sysctl.conf' << EOF
fs.inotify.max_user_watches = 524288
EOF
sudo sysctl -p
fi
if [ "$EXTRA_APPS" -eq "1" ]
then
sudo apt-get --yes --force-yes install gimp mysql-workbench > $VERBOSE
fi
if [ "$EXTRA_SHELL" -eq "1" ]
then
sudo apt-get --yes --force-yes install zsh powerline > $VERBOSE
# initialize zsh
echo Press ctrl+d or type exit if zsh does not close automatically
zsh -c 'exit'
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" > $VERBOSE
sudo sed -ie "s#^\($(whoami).*:\)\([^:]*\)\$#\1$(which zsh)#g" /etc/passwd
if [ -f ~/.zshrc ]
then
if [ `grep 'alias php=' ~/.zshrc | wc -l` -eq "0" ]
then
echo "alias php='php -dzend_extension=xdebug.so'" >> ~/.zshrc
fi
if [ `grep 'alias composer=' ~/.zshrc | wc -l` -eq "0" ]
then
echo "alias composer='composer.phar'" >> ~/.zshrc
fi
if [ `grep 'alias phpunit=' ~/.zshrc | wc -l` -eq "0" ]
then
echo "alias phpunit='php \$(which phpunit)'" >> ~/.zshrc
fi
if [ ! -d ~/lib ]
then
mkdir ~/lib
fi
if [ ! -d ~/lib/powerline-fonts ]
then
git clone https://github.com/powerline/fonts.git ~/lib/powerline-fonts > $VERBOSE 2>&1
~/lib/powerline-fonts/install.sh > $VERBOSE
fi
if [ ! -d ~/lib/powerline-shell ]
then
git clone //github.com/milkbikis/powerline-shell.git ~/lib/powerline-shell > $VERBOSE 2>&1
cd ~/lib/powerline-shell
cat > config.py << EOF
SEGMENTS = [
'ssh',
'cwd',
'read_only',
'git',
'jobs',
'root',
]
THEME = 'default'
EOF
./install.py > $VERBOSE
cd - > /dev/null
fi
sed -ie 's/^plugins=(.*)/plugins=(git composer cp git-flow heroku rsync redis-cli z n98-magerun)/' ~/.zshrc
sed -ie 's/^ZSH_THEME=.*$/ZSH_THEME="agnoster"/g' ~/.zshrc
cat >> ~/.zshrc <<"EOT"
function powerline_precmd() {
export PS1="$(~/lib/powerline-shell/powerline-shell.py $? --shell zsh 2> /dev/null)"
}
function install_powerline_precmd() {
for s in "${precmd_functions[@]}"; do
if [ "$s" = "powerline_precmd" ]; then
return
fi
done
precmd_functions+=(powerline_precmd)
}
install_powerline_precmd
EOT
fi
fi
if [ "$EXTRA_THEME" -eq "1" ]
then
sudo apt-get --yes --force-yes install numix-gtk-theme numix-icon-theme \
unity-tweak-tool numix-folders numix-icon-theme \
numix-icon-theme-circle numix-plymouth-theme > $VERBOSE
fi
echo Installing mailcatcher
if [ `which mailcatcher | wc -l` -eq "0" ]
then
sudo gem2.2 install mailcatcher > $VERBOSE
sudo sh -c 'cat > /etc/systemd/system/mailcatcher.service' << EOF
[Unit]
Description=Ruby MailCatcher
Documentation=http://mailcatcher.me/
[Service]
EnvironmentFile=$(which mailcatcher)
Type=simple
ExecStart=$(which mailcatcher) --foreground --http-ip 127.0.0.1
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable mailcatcher.service > $VERBOSE
sudo service mailcatcher start > $VERBOSE
fi
echo Configuring PHP
if [ ! -f /etc/php5/mods-available/custom.ini ]
then
sudo sh -c 'cat > /etc/php5/mods-available/custom.ini' << EOF
[PHP]
short_open_tag = On
max_execution_time = 0
max_input_vars = 100000
display_errors = On
display_startup_errors = On
post_max_size = 100M
upload_max_filesize = 101M
sendmail_path = /usr/bin/env $(which catchmail) -f [email protected]
[Date]
date.timezone = Europe/Amsterdam
[Xdebug]
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir=/tmp
xdebug.max_nesting_level=1000
EOF
fi
sudo rm /etc/php5/cli/conf.d/* /etc/php5/apache2/conf.d/*
if [ ! -L /etc/php5/cli/conf.d/00-custom.ini ]
then
sudo ln -s ../../mods-available/custom.ini /etc/php5/cli/conf.d/00-custom.ini
fi
if [ ! -L /etc/php5/cli/conf.d/05-opcache.ini ]
then
sudo ln -s ../../mods-available/opcache.ini /etc/php5/cli/conf.d/05-opcache.ini
fi
if [ ! -L /etc/php5/cli/conf.d/10-pdo.ini ]
then
sudo ln -s ../../mods-available/pdo.ini /etc/php5/cli/conf.d/10-pdo.ini
fi
for mod in curl gd intl json mcrypt memcached memcache mongo mssql mysqli mysql odbc pdo_dblib pdo_mysql pdo_odbc readline redis tidy xdebug
do
if [ ! -L "/etc/php5/cli/conf.d/10-${mod}.ini" ]
then
sudo ln -s ../../mods-available/${mod}.ini /etc/php5/cli/conf.d/10-${mod}.ini
fi
done
sudo cp -a /etc/php5/cli/conf.d/* /etc/php5/apache2/conf.d/
# Remove xdebug from CLI because of issues with composer, resolving this via aliases
sudo rm /etc/php5/cli/conf.d/10-xdebug.ini
echo Configuring mysql
if [ ! -f /etc/mysql/mysql.conf.d/ZZ-mysqld.cnf ]
then
sudo sh -c 'cat > /etc/mysql/mysql.conf.d/ZZ-mysqld.cnf' <<EOT
[mysqld]
max_allowed_packet = 32M
#sql_mode=STRICT_ALL_TABLES
innodb_buffer_pool_size=1600M
ft_min_word_len=3
ft_boolean_syntax=' |-><()~*:""&^'
innodb_log_file_size = 128M
EOT
sudo service mysql restart > $VERBOSE
fi
echo Configuring apache
sudo sed -ie "s/www-data/${USER}/g" /etc/apache2/envvars
for mod in rewrite alias auth_basic autoindex dir env filter headers ssl status mime deflate php5 negotiation mpm_prefork setenvif
do
sudo a2enmod $mod > $VERBOSE 2>&1
done
echo Installing composer
if [ ! -f ~/bin/composer.phar ]
then
TMP=~
curl -sS https://getcomposer.org/installer | php -- --install-dir=${TMP}/bin > $VERBOSE
fi
echo Installing n98 magerun
if [ ! -f ~/bin/n98-magerun.phar ]
then
wget http://files.magerun.net/n98-magerun-latest.phar -O ~/bin/n98-magerun.phar > $VERBOSE
chmod +x ~/bin/n98-magerun.phar
fi
if [ ! -d ~/.n98-magerun/modules/ ]
then
mkdir -p ~/.n98-magerun/modules/
fi
if [ ! -d ~/.n98-magerun/modules/mct-dev-tools ]
then
echo Installing n98 module: mediact/mct-dev-tools
git clone [email protected]:/mediact/mct-dev-tools.git ~/.n98-magerun/modules/mct-dev-tools > $VERBOSE 2>&1
cd ~/.n98-magerun/modules/mct-dev-tools
make composer.lock > $VERBOSE 2>&1
cd - > /dev/null
fi
if [ ! -d ~/.n98-magerun/modules/environment ]
then
echo Installing n98 module: lenlorijn/environment
git clone [email protected]:lenlorijn/environment.git ~/.n98-magerun/modules/environment > $VERBOSE 2>&1
cd ~/.n98-magerun/modules/environment
php ~/bin/composer.phar install --no-dev > $VERBOSE 2>&1
cd - > /dev/null
fi
if [ ! -d ~/.n98-magerun/modules/mpmd ]
then
echo Installing n98 module: Magento Project Mess Detector
git clone [email protected]:AOEpeople/mpmd.git ~/.n98-magerun/modules/mpmd > $VERBOSE 2>&1
fi
echo Cleaning up installation
sudo apt-get autoclean --yes > $VERBOSE
sudo apt-get clean --yes > $VERBOSE
sudo apt-get autoremove --yes > $VERBOSE
echo <<EOF
After installing PhpStorm add the following lines to phpstorm-path/bin/phpstorm64.vmoptions:
-Dswing.aatext=true
-Dawt.useSystemAAFontSettings=on
EOF
if [ "$EXTRA_APPS" -eq "1" ]
then
echo <<EOF
Reboot is required to automatically start zsh
EOF
fi