To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / extra / soundsoftware / scripted-deploy / vagrant @ 1583:0dcd4f8c2b8a
| 1 | 1577:e38eee2e1d47 | Chris | # -*- mode: ruby -*- |
|---|---|---|---|
| 2 | # vi: set ft=ruby : |
||
| 3 | |||
| 4 | Vagrant.configure("2") do |config|
|
||
| 5 | 1583:0dcd4f8c2b8a | Chris | config.vm.box = "ubuntu/xenial64" |
| 6 | 1577:e38eee2e1d47 | Chris | config.vm.network "forwarded_port", guest: 80, host: 8080 |
| 7 | 1581:ae8043b014c7 | Chris | config.vm.synced_folder "../../../..", "/vagrant-code" |
| 8 | 1577:e38eee2e1d47 | Chris | config.vm.provision :shell, path: "vagrant-provision.sh" |
| 9 | end |
||
| 10 | #!/bin/bash |
||
| 11 | |||
| 12 | set -e |
||
| 13 | |||
| 14 | 1582:f26dc3004b3f | Chris | if [ -x /usr/bin/yum ]; then |
| 15 | |||
| 16 | 1583:0dcd4f8c2b8a | Chris | # Assumption: CentOS 7 |
| 17 | |||
| 18 | # This doesn't work -- I got hung up on the problem of making a |
||
| 19 | # sufficiently recent Ruby act as the system /usr/bin/ruby without |
||
| 20 | # massively overcomplicating things, and decided not to persist |
||
| 21 | # with it |
||
| 22 | 1582:f26dc3004b3f | Chris | |
| 23 | yum install -y epel-release centos-release-scl && \ |
||
| 24 | yum update -y && \ |
||
| 25 | yum install -y \ |
||
| 26 | httpd \ |
||
| 27 | httpd-devel \ |
||
| 28 | gcc \ |
||
| 29 | gcc-c++ \ |
||
| 30 | curl \ |
||
| 31 | doxygen \ |
||
| 32 | git \ |
||
| 33 | mercurial \ |
||
| 34 | mod_perl \ |
||
| 35 | postgresql \ |
||
| 36 | rh-ruby24 \ |
||
| 37 | rh-ruby24-ruby-devel \ |
||
| 38 | rh-ruby24-rubygems \ |
||
| 39 | rh-ruby24-rubygems-devel \ |
||
| 40 | logrotate |
||
| 41 | |||
| 42 | if [ -f /usr/bin/ruby ]; then |
||
| 43 | yum remove -y ruby |
||
| 44 | fi |
||
| 45 | |||
| 46 | cat > /etc/profile.d/enableruby24.sh <<EOF |
||
| 47 | #!/bin/bash |
||
| 48 | source scl_source enable rh-ruby24 |
||
| 49 | EOF |
||
| 50 | |||
| 51 | else |
||
| 52 | |||
| 53 | 1583:0dcd4f8c2b8a | Chris | # Assumption: Ubuntu 16.04 |
| 54 | |||
| 55 | # This is the working one! |
||
| 56 | 1582:f26dc3004b3f | Chris | |
| 57 | apt-get update && \ |
||
| 58 | apt-get dist-upgrade -y && \ |
||
| 59 | apt-get install -y \ |
||
| 60 | ack-grep \ |
||
| 61 | apache2 \ |
||
| 62 | apache2-dev \ |
||
| 63 | apt-utils \ |
||
| 64 | build-essential \ |
||
| 65 | cron \ |
||
| 66 | curl \ |
||
| 67 | doxygen \ |
||
| 68 | exim4 \ |
||
| 69 | git \ |
||
| 70 | graphviz \ |
||
| 71 | imagemagick \ |
||
| 72 | libapache-dbi-perl \ |
||
| 73 | libapache2-mod-perl2 \ |
||
| 74 | libapr1-dev \ |
||
| 75 | libaprutil1-dev \ |
||
| 76 | libauthen-simple-ldap-perl \ |
||
| 77 | libcurl4-openssl-dev \ |
||
| 78 | libdbd-pg-perl \ |
||
| 79 | libpq-dev \ |
||
| 80 | libmagickwand-dev \ |
||
| 81 | libio-socket-ssl-perl \ |
||
| 82 | logrotate \ |
||
| 83 | mercurial \ |
||
| 84 | postgresql \ |
||
| 85 | rsync \ |
||
| 86 | ruby \ |
||
| 87 | ruby-dev \ |
||
| 88 | sudo |
||
| 89 | |||
| 90 | fi |
||
| 91 | 1577:e38eee2e1d47 | Chris | #!/bin/bash |
| 92 | |||
| 93 | set -e |
||
| 94 | |||
| 95 | # Passenger gets installed through gem, not apt |
||
| 96 | |||
| 97 | if [ ! -f /var/lib/gems/2.3.0/gems/passenger-4.0.60/buildout/apache2/mod_passenger.so ]; then |
||
| 98 | gem install passenger -v 4.0.60 --no-rdoc --no-ri |
||
| 99 | passenger-install-apache2-module --languages=ruby |
||
| 100 | fi |
||
| 101 | |||
| 102 | #!/bin/bash |
||
| 103 | |||
| 104 | set -e |
||
| 105 | |||
| 106 | if ! grep -q '^code:' /etc/passwd ; then |
||
| 107 | groupadd code |
||
| 108 | useradd -g code -G www-data code |
||
| 109 | fi |
||
| 110 | |||
| 111 | #!/bin/bash |
||
| 112 | |||
| 113 | set -e |
||
| 114 | |||
| 115 | if [ ! -d /var/www/code ]; then |
||
| 116 | cp -a /vagrant-code /var/www/code |
||
| 117 | chown -R code.www-data /var/www/code |
||
| 118 | find /var/www/code -type d -exec chmod g+s \{\} \;
|
||
| 119 | fi |
||
| 120 | |||
| 121 | #!/bin/bash |
||
| 122 | |||
| 123 | set -e |
||
| 124 | |||
| 125 | if [ ! -f /var/hg/index.cgi ]; then |
||
| 126 | mkdir -p /var/hg |
||
| 127 | chown code.www-data /var/hg |
||
| 128 | chmod g+s /var/hg |
||
| 129 | 1581:ae8043b014c7 | Chris | cp /var/www/code/extra/soundsoftware/scripted-deploy/config/index.cgi /var/hg/ |
| 130 | cp /var/www/code/extra/soundsoftware/scripted-deploy/config/hgweb.config /var/hg/ |
||
| 131 | 1577:e38eee2e1d47 | Chris | chmod +x /var/hg/index.cgi |
| 132 | fi |
||
| 133 | |||
| 134 | 1578:06ca2df3d7ca | Chris | if [ ! -d /var/hg/vamp-plugin-sdk ]; then |
| 135 | # This project can be used for testing |
||
| 136 | cd /var/hg |
||
| 137 | hg clone https://code.soundsoftware.ac.uk/hg/vamp-plugin-sdk |
||
| 138 | chown -R code.www-data vamp-plugin-sdk |
||
| 139 | fi |
||
| 140 | 1577:e38eee2e1d47 | Chris | #!/bin/bash |
| 141 | |||
| 142 | set -e |
||
| 143 | |||
| 144 | if [ ! -f /var/www/code/config/database.yml ]; then |
||
| 145 | 1581:ae8043b014c7 | Chris | cp /var/www/code/extra/soundsoftware/scripted-deploy/config/database.yml.interpolated \ |
| 146 | 1577:e38eee2e1d47 | Chris | /var/www/code/config/database.yml |
| 147 | fi |
||
| 148 | |||
| 149 | #!/bin/bash |
||
| 150 | |||
| 151 | set -e |
||
| 152 | |||
| 153 | cd /var/www/code |
||
| 154 | gem install bundler |
||
| 155 | bundle install |
||
| 156 | |||
| 157 | #!/bin/bash |
||
| 158 | |||
| 159 | set -e |
||
| 160 | |||
| 161 | cd /var/www/code |
||
| 162 | bundle exec rake generate_secret_token |
||
| 163 | |||
| 164 | #!/bin/bash |
||
| 165 | |||
| 166 | set -e |
||
| 167 | |||
| 168 | /etc/init.d/postgresql start |
||
| 169 | |||
| 170 | cd /var/www/code |
||
| 171 | |||
| 172 | if [ -f postgres-dumpall ]; then |
||
| 173 | chmod ugo+r postgres-dumpall |
||
| 174 | sudo -u postgres psql -f postgres-dumpall postgres |
||
| 175 | rm postgres-dumpall # This was just a copy of the shared folder file anyway |
||
| 176 | fi |
||
| 177 | |||
| 178 | |||
| 179 | |||
| 180 | #!/bin/bash |
||
| 181 | |||
| 182 | set -e |
||
| 183 | |||
| 184 | if [ ! -f /usr/local/lib/site_perl/Apache/Authn/SoundSoftware.pm ]; then |
||
| 185 | mkdir -p /usr/local/lib/site_perl/Apache/Authn/ |
||
| 186 | cp /var/www/code/extra/soundsoftware/SoundSoftware.pm /usr/local/lib/site_perl/Apache/Authn/ |
||
| 187 | fi |
||
| 188 | |||
| 189 | #!/bin/bash |
||
| 190 | |||
| 191 | set -e |
||
| 192 | |||
| 193 | cd /var/www/code |
||
| 194 | |||
| 195 | if [ ! -f /etc/apache2/sites-enabled/10-code.conf ]; then |
||
| 196 | |||
| 197 | rm -f /etc/apache2/sites-enabled/000-default.conf |
||
| 198 | |||
| 199 | 1581:ae8043b014c7 | Chris | cp extra/soundsoftware/scripted-deploy/config/passenger.conf /etc/apache2/mods-available/ |
| 200 | cp extra/soundsoftware/scripted-deploy/config/passenger.load /etc/apache2/mods-available/ |
||
| 201 | cp extra/soundsoftware/scripted-deploy/config/perl.conf /etc/apache2/mods-available/ |
||
| 202 | 1577:e38eee2e1d47 | Chris | |
| 203 | ln -s ../mods-available/passenger.conf /etc/apache2/mods-enabled/ |
||
| 204 | ln -s ../mods-available/passenger.load /etc/apache2/mods-enabled/ |
||
| 205 | ln -s ../mods-available/perl.conf /etc/apache2/mods-enabled/ |
||
| 206 | ln -s ../mods-available/expires.load /etc/apache2/mods-enabled/ |
||
| 207 | ln -s ../mods-available/rewrite.load /etc/apache2/mods-enabled/ |
||
| 208 | 1578:06ca2df3d7ca | Chris | ln -s ../mods-available/cgi.load /etc/apache2/mods-enabled/ |
| 209 | 1577:e38eee2e1d47 | Chris | |
| 210 | 1581:ae8043b014c7 | Chris | cp extra/soundsoftware/scripted-deploy/config/code.conf.interpolated /etc/apache2/sites-available/code.conf |
| 211 | 1577:e38eee2e1d47 | Chris | ln -s ../sites-available/code.conf /etc/apache2/sites-enabled/10-code.conf |
| 212 | |||
| 213 | apache2ctl configtest |
||
| 214 | |||
| 215 | fi |
||
| 216 | |||
| 217 | 1581:ae8043b014c7 | Chris | #!/bin/bash |
| 218 | |||
| 219 | set -e |
||
| 220 | |||
| 221 | apache2ctl restart |
||
| 222 | |||
| 223 | #!/bin/bash |
||
| 224 | |||
| 225 | dbpwd="$1" |
||
| 226 | if [ -z "$dbpwd" ]; then |
||
| 227 | echo "Usage: $0 <database-password>" 1>&2 |
||
| 228 | exit 2 |
||
| 229 | fi |
||
| 230 | |||
| 231 | set -eu |
||
| 232 | |||
| 233 | deploydir=./extra/soundsoftware/scripted-deploy |
||
| 234 | if [ ! -d "$deploydir" ]; then |
||
| 235 | echo "Run this script from the root of a working copy of soundsoftware-site" |
||
| 236 | exit 2 |
||
| 237 | fi |
||
| 238 | |||
| 239 | managerdir="$deploydir/vagrant" |
||
| 240 | if [ ! -d "$managerdir" ]; then |
||
| 241 | echo "ERROR: Required directory $managerdir not found" |
||
| 242 | exit 2 |
||
| 243 | fi |
||
| 244 | |||
| 245 | configdir="$deploydir/config" |
||
| 246 | if [ ! -d "$configdir" ]; then |
||
| 247 | echo "ERROR: Required directory $configdir not found" |
||
| 248 | exit 2 |
||
| 249 | fi |
||
| 250 | |||
| 251 | if [ ! -f "postgres-dumpall" ]; then |
||
| 252 | echo "ERROR: I expect to find a Postgres SQL multi-db dump file in ./postgres-dumpall" |
||
| 253 | exit 2 |
||
| 254 | fi |
||
| 255 | |||
| 256 | for f in database.yml code.conf ; do |
||
| 257 | cat "$configdir/$f" | |
||
| 258 | sed 's/INSERT_POSTGRES_PASSWORD_HERE/'"$dbpwd"'/g' > \ |
||
| 259 | "$configdir/$f.interpolated" |
||
| 260 | done |
||
| 261 | |||
| 262 | cd "$managerdir" |
||
| 263 | |||
| 264 | vagrant up |
||
| 265 | |||
| 266 | 1577:e38eee2e1d47 | Chris | #!/bin/bash |
| 267 | |||
| 268 | #!!! still not covered: |
||
| 269 | # * cron jobs |
||
| 270 | # * https |
||
| 271 | # * web fonts |
||
| 272 | |||
| 273 | set -e |
||
| 274 | |||
| 275 | 1582:f26dc3004b3f | Chris | for f in /vagrant-code/extra/soundsoftware/scripted-deploy/vagrant/provision.d/[0-9]* ; do |
| 276 | 1577:e38eee2e1d47 | Chris | case "$f" in |
| 277 | *~) ;; |
||
| 278 | *) echo "Running provision script: $f" |
||
| 279 | /bin/bash "$f";; |
||
| 280 | esac |
||
| 281 | done |