ubuntu.sh 16.2 KB
Newer Older
1
2
3
echo ""
echo "Running ubuntu.sh"
echo ""
4
5
6
## Return the date so we can see how long the ubuntu.sh file runs.
date
echo ""
7
8
## Make sure that we are starting fresh with the repositories
sudo apt-get clean
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Call the variable file so we can fill in the bits
. /tmp/variable.sh

## This file gets executed the first time you do a 'vagrant up', if you want it to
## run again you'll need run 'vagrant provision'.

## Install all the ubuntu things

## Update the /etc/apt/sources.list to use the uwaterloo CSClub mirror
echo "## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
##     or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl
#

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
29
30
31
32
# deb http://archive.ubuntu.com/ubuntu xenial main restricted
# deb-src http://archive.ubuntu.com/ubuntu xenial main restricted
deb https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial main restricted
deb-src https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial main restricted
33
34
35

## Major bug fix updates produced after the final release of the
## distribution.
36
37
38
39
# deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted
# deb-src http://archive.ubuntu.com/ubuntu xenial-updates main restricted
deb https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-updates main restricted
deb-src https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-updates main restricted
40
41
42
43

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
44
45
46
47
48
49
50
51
# deb http://archive.ubuntu.com/ubuntu xenial universe
# deb-src http://archive.ubuntu.com/ubuntu xenial universe
# deb http://archive.ubuntu.com/ubuntu xenial-updates universe
# deb-src http://archive.ubuntu.com/ubuntu xenial-updates universe
deb https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial universe
deb-src https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial universe
deb https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-updates universe
deb-src https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-updates universe
52
53
54
55
56
57

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
58
59
60
61
62
63
64
65
# deb http://archive.ubuntu.com/ubuntu xenial multiverse
# deb-src http://archive.ubuntu.com/ubuntu xenial multiverse
# deb http://archive.ubuntu.com/ubuntu xenial-updates multiverse
# deb-src http://archive.ubuntu.com/ubuntu xenial-updates multiverse
deb https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial multiverse
deb-src https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial multiverse
deb https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-updates multiverse
deb-src https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-updates multiverse
66
67
68
69
70
71
72
73

## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
74
75
76
77
# deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
deb https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-backports main restricted universe multiverse
deb-src https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-backports main restricted universe multiverse
78
79
80
81
82

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
83
84
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner
85

86
87
88
89
90
91
92
93
94
# deb http://security.ubuntu.com/ubuntu xenial-security main
# deb-src http://security.ubuntu.com/ubuntu xenial-security main
deb https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-security main
deb-src https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-security main
# deb http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-security universe
deb-src https://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-security universe
# deb http://security.ubuntu.com/ubuntu xenial-security multiverse
Chris Shantz's avatar
Chris Shantz committed
95
# deb-src [arch=i386,amd64] http://mariadb.mirror.anstey.ca/repo/10.1/ubuntu xenial main
96
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse" > /etc/apt/sources.list
97
98

## Add phpmyadmin so it will install the latest version that works with php 7.0
99
100
#deb http://ppa.launchpad.net/nijel/phpmyadmin/ubuntu xenial main
#deb-src http://ppa.launchpad.net/nijel/phpmyadmin/ubuntu xenial main
101

102
## For ubuntu xenial we need to add some repos for the latest PHP version
103
export DEBIAN_FRONTEND=noninteractive
104
105
106
## Since setting the timezone above doesn't seem to do anything...
echo "setting timezone..."
sudo timedatectl set-timezone America/Toronto
107
sudo apt-get install software-properties-common
108
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
109
sudo add-apt-repository -y ppa:ondrej/php
110
111
## Add the git repo so we can get the latest git (we need 2.9.2+)
sudo add-apt-repository ppa:git-core/ppa
112
113


114
## Added so we can installs 6.x branch of nodejs.
115
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
116
117
118
119
120
121

## Added so we can install yarn for Drupal8 theme work.
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

## Added so we can install phpmyadmin.
122
123
sudo add-apt-repository -y ppa:nijel/phpmyadmin

124
## Pre-configure mysql username and password
125
126
echo "mysql-server mysql-server/root_password password vagrant" | sudo debconf-set-selections
echo "mysql-server mysql-server/root_password_again password vagrant" | sudo debconf-set-selections
127
128
129
130
131
132

## Pre-configure responses for postfix install
echo "postfix postfix/mailname string $server" | sudo debconf-set-selections
## Options are: No configuration , Internet site, Internet with smarthost, Satellite system, Local only
echo "postfix postfix/main_mailer_type string 'Internet Site'" | sudo debconf-set-selections

133
134
sudo apt-get update

135
136
echo ${VGRTPHPDRUPAL7}
echo ${VGRTPHPDRUPAL8}
137
138
echo ${VGDEFAULTPHPVERSION}
## Install php5.6 and php7.1 versions so we can switch when needed.
139
## Removed npm because it gets installed with the version of 6.x.
140
141
142
143
sudo apt-get install --assume-yes php${VGRTPHPDRUPAL7} php${VGRTPHPDRUPAL7}-common php${VGRTPHPDRUPAL7}-dev \
php${VGRTPHPDRUPAL7}-fpm php${VGRTPHPDRUPAL7}-apc php${VGRTPHPDRUPAL7}-mbstring php${VGRTPHPDRUPAL7}-gettext \
php${VGRTPHPDRUPAL7}-simplexml php${VGRTPHPDRUPAL7}-xdebug php${VGRTPHPDRUPAL7}-mysql php${VGRTPHPDRUPAL7}-sqlite3 \
php${VGRTPHPDRUPAL7}-gd php${VGRTPHPDRUPAL7}-cli php${VGRTPHPDRUPAL7}-curl php${VGRTPHPDRUPAL7}-mcrypt php${VGRTPHPDRUPAL7}-ldap \
Chris Shantz's avatar
Chris Shantz committed
144
apache2 libapache2-mod-php${VGRTPHPDRUPAL7} openssh-server mysql-server mysql-client php${VGRTPHPDRUPAL7}-zip \
145
vim php-pear git drush ruby-sass ruby-compass python-software-properties nodejs yarn dos2unix \
146
optipng jpegoptim imagemagick libapache2-mod-fcgid libapache2-mod-fastcgi php${VGRTPHPDRUPAL7}-cgi php${VGRTPHPDRUPAL7}-xml \
147
libapache2-mod-php${VGRTPHPDRUPAL8} php${VGRTPHPDRUPAL8}-xml php${VGRTPHPDRUPAL8}-fpm php${VGRTPHPDRUPAL8}-mbstring \
148
149
150
php${VGRTPHPDRUPAL8}-mysql php${VGRTPHPDRUPAL8}-zip php${VGRTPHPDRUPAL8}-gd php${VGRTPHPDRUPAL8} php${VGRTPHPDRUPAL8}-common \
php${VGRTPHPDRUPAL8}-fpm php${VGRTPHPDRUPAL8}-apc php${VGRTPHPDRUPAL8}-mbstring php${VGRTPHPDRUPAL8}-gettext php${VGRTPHPDRUPAL8}-dev \
php${VGRTPHPDRUPAL8}-simplexml php${VGRTPHPDRUPAL8}-xdebug php${VGRTPHPDRUPAL8}-sqlite3 php${VGRTPHPDRUPAL8}-gd php${VGRTPHPDRUPAL8}-cli \
151
php${VGRTPHPDRUPAL8}-curl php${VGRTPHPDRUPAL8}-mcrypt php${VGRTPHPDRUPAL8}-ldap php${VGRTPHPDRUPAL8}-cgi postfix
152
153

## enable rewrite, ssl, headers and fcgid for apache2.
154
155
a2enmod rewrite
a2enmod ssl
156
## for Content Security Policy (CSP).
157
a2enmod headers
158
159
## fcgid needed to run multiple versions of PHP under the same apache.
a2enmod fcgid
160

161
## create wcms-common.conf which contains header information including CSP.
162
163
164
165
166
167
168
169
170
171
echo "Header Always set X-UA-Compatible: \"IE=edge\"

# Added as DENY for RT#395748, changed after problems for RT#397113
Header Always set X-Frame-Options: \"SAMEORIGIN\"

# RT#395747
Header Always set X-Content-Type-Options: \"nosniff\"

# RT#395745: Content-Security-Policy
Header Always set Content-Security-Policy: \"default-src 'self' 'unsafe-inline' 'unsafe-eval' \
172
data: https://uwaterloo.ca https://*.uwaterloo.ca https://${vgrtserver}7 https://${vgrtserver}7alt https://${vgrtserver}8 https://${vgrtserver}8alt https://${vgrtserver}7rel https://${vgrtserver}7lrel https://${vgrtserver}7os https://maxcdn.bootstrapcdn.com \
173
https://maxcdn.bootstrapcdn.com https://*.google.com https://*.google-analytics.com https://*.googleapis.com https://*.gstatic.com https://*.googletagmanager.com https://*.googleusercontent.com https://stats.g.doubleclick.net https://6263835.fls.doubleclick.net https://cdnjs.cloudflare.com https://*.twitter.com https://*.twimg.com https://twitter-widgets.s3.amazonaws.com https://*.facebook.com https://*.facebook.net https://*.youtube.com https://*.youtube-nocookie.com https://*.livestream.com https://*.webspellchecker.net https://cdn.mathjax.org https://storify.com https://*.addtoany.com https://*.vimeo.com https://*.vimeocdn.com https://*.tintup.com https://*.71n7.com https://d36hc0p18k1aoc.cloudfront.net https://cdn.leafletjs.com https://cdn-geoweb.s3.amazonaws.com https://cdn.maptiks.com https://api.tiles.mapbox.com https://d591zijq8zntj.cloudfront.net https://*.libanswers.com https://secure.skype.com https://cdn-akamai.mookie1.com https://*.tiqcdn.com https://o2.eyereturn.com https://snap.licdn.com https://*.hscampaigns.com; img-src * data:\"
174
175
" > /etc/apache2/conf-available/wcms-common.conf

176

177
178
179
180
181
182
## enable the wcms-common config we created
a2enconf wcms-common

## make www-data use /bin/bash for shell
chsh -s /bin/bash www-data
## enable mcrypt
183
sudo apt-get install php7.1-mcrypt
184
185
sudo phpenmod mcrypt

186
## add upload progress
187
sudo apt-get install php-uploadprogress
188

189
190
191
192
193
## Install Composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
## Add Composer Global Bin To Path
echo "Add composer Global Bin to path"
194
printf "\nPATH=\"/home/vagrant/.config/composer/vendor/bin:\$PATH\"\n" | tee -a /home/vagrant/.profile
195

196
197
198
##wget http://static.phpmd.org/php/2.1.3/phpmd.phar
##mv phpmd.phar /usr/local/bin/phpmd
##chmod +x /usr/local/bin/phpmd
199
200
201
202
203
204
205
206
207
208

echo "Install drush 8"
mkdir /home/vagrant/drush8
cd /home/vagrant/drush8
composer require drush/drush:8.*
echo "Install drush7"
mkdir /home/vagrant/drush7
cd /home/vagrant/drush7
composer require "drush/drush:7.*"
## Remove the Ubuntu installed drush and create a symlink to drush7
209
cd /usr/bin && sudo rm drush && sudo ln -s /home/vagrant/drush8/vendor/drush/drush/drush.php drush
210
211

## Install Drupal Console
212
echo "Install Drupal Console"
213
214
215
216
217
curl https://drupalconsole.com/installer -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal

## Install Drupal Coder
218
echo "Install Drupal Coder"
219
composer global require drupal/coder
220
221
222
223
## Install Codesniffer
echo "Install CodeSniffer"
composer global require "squizlabs/php_codesniffer=*"
## Config CodeSniffer to use Drupal coding standards
224
phpcs --config-set installed_paths /home/vagrant/.config/composer/vendor/drupal/coder/coder_sniffer
225
226

## Install PHP Mess Detector
227
echo "Install Drupal Mess Detector"
228
229
composer global require phpmd/phpmd

230
231
232
## Install phpcodesniffer-composer-installer to automagically add drupal coding standards to codesniffer
composer global require dealerdirect/phpcodesniffer-composer-installer

233
234
235
236
## Move the .config file from root to vagrant home directory and adjust perms
mv /root/.config /home/vagrant/
chown -R vagrant:vagrant /home/vagrant/.config

237
## Change the PHP variables for Drupal
238
239
240
241
242
243
244
245
phpversions="${VGRTPHPDRUPAL7} ${VGRTPHPDRUPAL8}"
for phpversion in $phpversions
 do
sed -i "s/display_errors = .*/display_errors = On/" /etc/php/$phpversion/apache2/php.ini
sed -i "s/display_errors = .*/display_errors = On/" /etc/php/$phpversion/fpm/php.ini
sed -i "s/max_execution_time =.*/max_execution_time = 240/" /etc/php/$phpversion/apache2/php.ini
sed -i "s/max_input_time = .*/max_input_time = 240/" /etc/php/$phpversion/apache2/php.ini
sed -i "s/memory_limit = .*/memory_limit = 768M/" /etc/php/$phpversion/apache2/php.ini
246
sed -i "s/; max_input_vars = .*/max_input_vars = 10000/" /etc/php/$phpversion/apache2/php.ini
247
248
sed -i "s/;date.timezone = */date.timezone = America\/Toronto/" /etc/php/$phpversion/apache2/php.ini
sed -i "s/;date.timezone = */date.timezone = America\/Toronto/" /etc/php/$phpversion/cli/php.ini
249
done
250
251
## Add the include_path to the php.ini file so yarn works correctly
echo "Adding include_path to PHP${VGRTPHPDRUPAL8} ..."
252
sed -i "s/;include_path = \"\.\:\/usr\/share\/php\"*/include_path = \".:\/usr\/share\/php:\/var\/www\/drupal8\/profiles\/uw_base_profile\"/" /etc/php/${VGRTPHPDRUPAL8}/cli/php.ini
253
254
255
256
## Add max_allowed_packet to my.cnf file so large sql dump files wouldn't timeout.
echo "[mysqld]
      max_allowed_packet = 100M" >> /etc/mysql/my.cnf

257
258
259
260
261
262
263
## Install xhprof
#pecl config-set preferred_state beta
#pecl install xhprof

## Add xhprof config
#echo "[xhprof]
#extension=xhprof.so
264
#xhprof.output_dir=/var/tmp/xhprof" > /etc/php/${VGRTPHPDRUPAL7}/mods-available/xhprof.ini
265
266
267
268
269

## Add xdebug config
echo ";zend_extension=xdebug.so
xdebug.remote_enable= 1
xdebug.remote_host= 192.168.101.1
270
xdebug.max_nesting_level=256" > /etc/php/${VGRTPHPDRUPAL7}/mods-available/xdebug.ini
271

272
273
274
275
276
277
## Add xdebug config
echo ";zend_extension=xdebug.so
xdebug.remote_enable= 1
xdebug.remote_host= 192.168.101.1
xdebug.max_nesting_level=256" > /etc/php/${VGRTPHPDRUPAL8}/mods-available/xdebug.ini

278
279
280
281
282
## Install the latest npm and gulp so we have them for responsive sites.
sudo npm install npm@latest -g
sudo npm install gulp -g
sudo npm install bower -g

283
284
285
286
## Create a symlink for node to nodejs.
ln -s /usr/bin/nodejs /usr/bin/node

## Add the Servername to the apache2 conf file.
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
echo "ServerName ${vgrthostname}" >> /etc/apache2/apache2.conf

## Add fdsu sites to the hosts file
echo "
127.0.0.1       localhost
127.0.1.1       ${vgrthostname}
${vgrtip}  ${vgrtserver}7 ${vgrtserver}7alt ${vgrtserver}8 ${vgrtserver}7rel ${vgrtserver}7lrel ${vgrtserver}7os
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters" > /etc/hosts

#add the network interface .cfg file for eth1
echo "
auto eth1
iface eth1 inet static
address ${vgrtip}
netmask 255.255.255.0
network 192.168.101.1
broadcast 192.168.101.255" > /etc/network/interfaces.d/eth1.cfg

sudo chown -R vagrant:vagrant /home/vagrant

## Auto remove any files no longer needed.
apt-get autoremove --assume-yes

315
316
317
## Make PHP ${VGRTPHPDRUPAL7} the default, if not set PHP ${VGRTPHPDRUPAL8} is the default.
## update-alternatives --set php /usr/bin/php${VGRTPHPDRUPAL7}
update-alternatives --set php /usr/bin/php${VGDEFAULTPHPVERSION}
318
319
320
321
322
323
324
325

## Add the username and email we created with the setup.sh file to the .gitconfig file and move it to vagrant home folder.

git config --global user.name "${vgrtwatiamid}"
git config --global user.email ${vgrtemail}
## Set git to always rebase pulls to make code cleaner.
git config --global branch.autosetuprebase always

326
## Set git push to use the simple method by default.
327
328
git config --global push.default simple

329
330
## Set git hooks for all repositories.
git config --global core.hooksPath /home/vagrant/uw_wcms_tools/git_hooks/
331

332
mv /root/.gitconfig /home/vagrant/.gitconfig
333
334
echo ""
date
335
echo ""