finish.sh 10.8 KB
Newer Older
1
2
3
4
5
6
7
8
echo ""
echo "Running finish.sh"
echo ""

## Call the variable file so we can fill in the bits
. /tmp/variable.sh

## Make vagrant the root password for mysql
9
## mysqladmin -u root password vagrant
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

echo 'phpmyadmin phpmyadmin/dbconfig-install boolean true' | debconf-set-selections
echo 'phpmyadmin phpmyadmin/app-password-confirm password vagrant' | debconf-set-selections
echo 'phpmyadmin phpmyadmin/mysql/admin-pass password vagrant' | debconf-set-selections
echo 'phpmyadmin phpmyadmin/mysql/app-pass password vagrant' | debconf-set-selections
echo 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' | debconf-set-selections

sudo apt-get -q -y install phpmyadmin

## Add uw_wcms_tools to the local system
cd /home/vagrant
git clone https://git.uwaterloo.ca/wcms/uw_wcms_tools.git

## Make Vagrant the owner and apache the group for all the web folders
sudo chown -R vagrant:www-data /var/www
sudo chmod -R g+w /var/www

## make sure that the vagrant home folder has the correct permissions
sudo chown -R vagrant:vagrant /home/vagrant/

30
31
32
33
## add the wcms.crt to the ca-certificates.
sudo mv /tmp/WCMS.crt /usr/local/share/ca-certificates/WCMS.crt
sudo update-ca-certificates

34
35
36
37
38
39
40
41
42
## replace root with /home/vagrant so phpcs has proper drupal standards path
echo "
<?php
 \$phpCodeSnifferConfig = array (
  'installed_paths' => '/home/vagrant/.config/composer/vendor/drupal/coder/coder_sniffer',
)
?>" > /home/vagrant/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.conf


43
44
45
46
47
48
49
50
51
52
53
## Add aliases for drupal and site folders.
echo "
#my aliases

alias web='cd /var/www/'
alias sites='cd /var/www/drupal7/sites/'
alias profile='cd /var/www/drupal7/profiles/uw_base_profile'
alias profilealt='cd /var/www/drupal7alt/profiles/uw_base_profile'
alias profilerel='cd /var/www/drupal7rel/profiles/uw_base_profile'
alias profilelrel='cd /var/www/drupal7lrel/profiles/uw_base_profile'
alias profileos='cd /var/www/drupal7os/profiles/uw_base_profile'
54
55
alias profile8='cd /var/www/drupal8/profiles/uw_base_profile'
alias profile8alt='cd /var/www/drupal8alt/profiles/uw_base_profile'
56
57
58
59
alias drush7='~/drush7/vendor/bin/drush'
alias drush8='~/drush8/vendor/bin/drush'
alias defaultphp56='defaultphp5.6.sh'
alias defaultphp71='defaultphp7.1.sh'
60
61
alias enablexdebug='enable_xdebug.sh'
alias disablexdebug='disable_xdebug.sh'
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
alias ${vgrtsite}1='cd /var/www/drupal7/sites/${vgrtserver}7.${vgrtsite}1'
alias ${vgrtsite}2='cd /var/www/drupal7/sites/${vgrtserver}7.${vgrtsite}2'
alias ${vgrtsite}3='cd /var/www/drupal7/sites/${vgrtserver}7.${vgrtsite}3'
alias ${vgrtsite}4='cd /var/www/drupal7/sites/${vgrtserver}7.${vgrtsite}4'
alias ${vgrtsite}5='cd /var/www/drupal7/sites/${vgrtserver}7.${vgrtsite}5'
alias ${vgrtsite}1alt='cd /var/www/drupal7alt/sites/${vgrtserver}7alt.${vgrtsite}1'
alias ${vgrtsite}2alt='cd /var/www/drupal7alt/sites/${vgrtserver}7alt.${vgrtsite}2'
alias ${vgrtsite}3alt='cd /var/www/drupal7alt/sites/${vgrtserver}7alt.${vgrtsite}3'
alias ${vgrtsite}4alt='cd /var/www/drupal7alt/sites/${vgrtserver}7alt.${vgrtsite}4'
alias ${vgrtsite}5alt='cd /var/www/drupal7alt/sites/${vgrtserver}7alt.${vgrtsite}5'
alias ${vgrtsite}1rel='cd /var/www/drupal7rel/sites/${vgrtserver}7rel.${vgrtsite}1'
alias ${vgrtsite}2rel='cd /var/www/drupal7rel/sites/${vgrtserver}7rel.${vgrtsite}2'
alias ${vgrtsite}3rel='cd /var/www/drupal7rel/sites/${vgrtserver}7rel.${vgrtsite}3'
alias ${vgrtsite}4rel='cd /var/www/drupal7rel/sites/${vgrtserver}7rel.${vgrtsite}4'
alias ${vgrtsite}5rel='cd /var/www/drupal7rel/sites/${vgrtserver}7rel.${vgrtsite}5'
alias ${vgrtsite}1lrel='cd /var/www/drupal7lrel/sites/${vgrtserver}7lrel.${vgrtsite}1'
alias ${vgrtsite}2lrel='cd /var/www/drupal7lrel/sites/${vgrtserver}7lrel.${vgrtsite}2'
alias ${vgrtsite}3lrel='cd /var/www/drupal7lrel/sites/${vgrtserver}7lrel.${vgrtsite}3'
alias ${vgrtsite}4lrel='cd /var/www/drupal7lrel/sites/${vgrtserver}7lrel.${vgrtsite}4'
alias ${vgrtsite}5lrel='cd /var/www/drupal7lrel/sites/${vgrtserver}7lrel.${vgrtsite}5'
alias ${vgrtsite}1os='cd /var/www/drupal7os/sites/${vgrtserver}7os.${vgrtsite}1'
alias ${vgrtsite}2os='cd /var/www/drupal7os/sites/${vgrtserver}7os.${vgrtsite}2'
alias ${vgrtsite}3os='cd /var/www/drupal7os/sites/${vgrtserver}7os.${vgrtsite}3'
alias ${vgrtsite}4os='cd /var/www/drupal7os/sites/${vgrtserver}7os.${vgrtsite}4'
alias ${vgrtsite}5os='cd /var/www/drupal7os/sites/${vgrtserver}7os.${vgrtsite}5'
87
88
89
90
91
92
93
94
95
96
alias ${vgrtsite}1-8='cd /var/www/drupal8/sites/${vgrtserver}8.${vgrtsite}1'
alias ${vgrtsite}2-8='cd /var/www/drupal8/sites/${vgrtserver}8.${vgrtsite}2'
alias ${vgrtsite}3-8='cd /var/www/drupal8/sites/${vgrtserver}8.${vgrtsite}3'
alias ${vgrtsite}4-8='cd /var/www/drupal8/sites/${vgrtserver}8.${vgrtsite}4'
alias ${vgrtsite}5-8='cd /var/www/drupal8/sites/${vgrtserver}8.${vgrtsite}5'
alias ${vgrtsite}1-8alt='cd /var/www/drupal8alt/sites/${vgrtserver}8alt.${vgrtsite}1'
alias ${vgrtsite}2-8alt='cd /var/www/drupal8alt/sites/${vgrtserver}8alt.${vgrtsite}2'
alias ${vgrtsite}3-8alt='cd /var/www/drupal8alt/sites/${vgrtserver}8alt.${vgrtsite}3'
alias ${vgrtsite}4-8alt='cd /var/www/drupal8alt/sites/${vgrtserver}8alt.${vgrtsite}4'
alias ${vgrtsite}5-8alt='cd /var/www/drupal8alt/sites/${vgrtserver}8alt.${vgrtsite}5'
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
alias clr='clear'
alias cc='drush cc all'
alias updb='drush updb'
alias makedrush='drush make --working-copy --force-gitinfofile --no-core -y --contrib-destination=. makefile/site.make'
LS_COLORS=$LS_COLORS:'di=0;35:' ; export LS_COLORS" > /home/vagrant/.bash_aliases
## increase the size of the git http buffer to prevent the remote end hung up unexpectedly
git config --global http.postBuffer 1048576000

## Create the defaultphp files so we can switch between php5.6 and 7.1
echo "
echo '-------------------------------------------------'
echo 'Changing version of PHP to ${VGRTPHPDRUPAL8}'
echo '-------------------------------------------------'
sudo a2dismod php${VGRTPHPDRUPAL7} && sudo a2enmod php${VGRTPHPDRUPAL8} && sudo update-alternatives --set php /usr/bin/php${VGRTPHPDRUPAL8} && sudo service apache2 restart
echo '-------------------------------------------------'
echo 'Apache has been restarted as part of the script.'
echo '-------------------------------------------------'" > /usr/local/bin/defaultphp${VGRTPHPDRUPAL8}.sh

sudo chown vagrant:root /usr/local/bin/defaultphp${VGRTPHPDRUPAL8}.sh
sudo chmod 754 /usr/local/bin/defaultphp${VGRTPHPDRUPAL8}.sh

echo "
echo '======================================================='
echo 'Changing version of PHP to ${VGRTPHPDRUPAL7}'
echo '======================================================='
sudo a2dismod php${VGRTPHPDRUPAL8} && sudo a2enmod php${VGRTPHPDRUPAL7} && sudo update-alternatives --set php /usr/bin/php${VGRTPHPDRUPAL7} && sudo service apache2 restart
echo '======================================================='
echo 'Apache has been restarted as part of the script.'
echo '======================================================='" > /usr/local/bin/defaultphp${VGRTPHPDRUPAL7}.sh

sudo chown vagrant:root /usr/local/bin/defaultphp${VGRTPHPDRUPAL7}.sh
sudo chmod 754 /usr/local/bin/defaultphp${VGRTPHPDRUPAL7}.sh

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
## Create a script to enable Xdebug.
echo "
echo '================================================================='
echo 'Enabling xdebug...'
echo '================================================================='
sudo sed -i \"s/;zend_extension=xdebug.so/zend_extension=xdebug.so/\" /etc/php/5.6/mods-available/xdebug.ini
sudo sed -i \"s/;zend_extension=xdebug.so/zend_extension=xdebug.so/\" /etc/php/7.1/mods-available/xdebug.ini
echo '================================================================='
echo 'Xdebug should now be enabled.'
echo '================================================================='" > /usr/local/bin/enable_xdebug.sh

sudo chown vagrant:root /usr/local/bin/enable_xdebug.sh
sudo chmod 754 /usr/local/bin/enable_xdebug.sh

## Create a script to disable Xdebug.
echo "
echo '================================================================='
echo 'Disabling xdebug...'
echo '================================================================='
sudo sed -i \"s/zend_extension=xdebug.so/;zend_extension=xdebug.so/\" /etc/php/5.6/mods-available/xdebug.ini
sudo sed -i \"s/zend_extension=xdebug.so/;zend_extension=xdebug.so/\" /etc/php/7.1/mods-available/xdebug.ini
echo '================================================================='
echo 'Xdebug should now be disabled.'
echo '================================================================='" > /usr/local/bin/disable_xdebug.sh

sudo chown vagrant:root /usr/local/bin/disable_xdebug.sh
sudo chmod 754 /usr/local/bin/disable_xdebug.sh

158
159
160
161
162
163
## add a script to create the symlinks for conference and publication sites
echo "
#
# Script to create symlinks for publication and conference themes (apps folder)
#

164
if [ \$# -eq 0 ]
165
166
167
168
169
170
then
        echo "Missing parameter!"
        echo "create_theme_symlinks.sh DRUPAL-ROOT"
        echo ""
        exit 0
else
171
172
       ln -s /var/www/\$1/profiles/uw_base_profile/themes/uw_theme_publication /var/www/\$1/apps/uw_publication
       ln -s /var/www/\$1/profiles/uw_base_profile/themes/uw_theme_conference /var/www/\$1/apps/uw_theme_conference
173
174
175
176
177
178
179
180
fi

echo "Links created!"
" > /usr/local/bin/create_theme_symlinks.sh

sudo chown vagrant:root /usr/local/bin/create_theme_symlinks.sh
sudo chmod 754 /usr/local/bin/create_theme_symlinks.sh

181
182
183
## Make sure the defaultphp is set correctly
defaultphp${VGDEFAULTPHPVERSION}.sh

184
185
186
echo "
===================================================================================
Making sure everything is up to date... If the update requires manual interaction
187
it may hang and you will not see the Installation is now complete message.
188
189
If the update does hang, all the required bits are installed and you can access
your VM via ssh vagrant@${vgrtip}.
190
You may need to reboot the VM (sudo reboot) to fix an issue with the package that
191
required manual interaction. When it is up run 'sudo dpkg --configure -a' inside
192
your VM to continue to install the package.
193
194
195
===================================================================================
"

196
## Make sure everything is up to date. If there are a lot, or they require interaction it probably means you need to run vagrant update box
197
198
199
200
201
202
203
204

## sudo apt-get upgrade --assume-yes --allow-unauthenticated

## Periodically, the box we use seems to include updates for the grub boot loader which requires interaction and hangs the install.
# The code below seems to get around that by forcing certain options. We should generally use the code above and if it fails the one below.
# We should review periodically (or when the box gets updated) to check that the upgrade code above works and switch it.
##
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
205
206
207
208
209
210

echo "
***********************************************************************************
The installation is now complete. You can access you VM via ssh vagrant@${vgrtip}
***********************************************************************************
"