To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / deploy / config @ 1601:07deb8466f65

1 1601:07deb8466f65 Chris
2
# Apache config with SSL and admin auth stubbed in. You must provide
3
# the key/cert and auth files.
4
5
# Note this has been updated for Apache 2.4, which introduced a number
6
# of (welcome) changes to access control directives.
7
8
PerlLoadModule Apache::Authn::SoundSoftware
9
10
<VirtualHost *:80>
11
        ServerName code.soundsoftware.ac.uk
12
        ServerAdmin chris.cannam@soundsoftware.ac.uk
13
14
        DocumentRoot /var/www/code/public
15
        PassengerRestartDir restart_files
16
        PassengerHighPerformance on
17
        PassengerMaxRequests 50000
18
        PassengerStatThrottleRate 5
19
	PassengerFriendlyErrorPages off
20
        RailsSpawnMethod smart
21
        ExpiresDefault "access plus 1 minute"
22
23
        # Redirect all activity to secure site
24
        Redirect seeother / "https://code.soundsoftware.ac.uk/"
25
26
        <DirectoryMatch "^/.*/\.svn/">
27
                Require all denied
28
        </DirectoryMatch>
29
30
        <DirectoryMatch "^/.*/\.hg/">
31
                Require all denied
32
        </DirectoryMatch>
33
34
        <DirectoryMatch "^/.*/\.git/">
35
                Require all denied
36
        </DirectoryMatch>
37
38
        <Directory /var/www/code/public>
39
                Options -MultiViews
40
	</Directory>
41
42
	ErrorLog /var/log/apache2/code-error.log
43
	CustomLog /var/log/apache2/code-access.log vhost_combined
44
45
        LogLevel warn
46
        ServerSignature Off
47
</VirtualHost>
48
49
<VirtualHost *:80>
50
        ServerName code.soundsoftware.ac.uk
51
        ServerAdmin chris.cannam@soundsoftware.ac.uk
52
53
        DocumentRoot /var/www/code/public
54
        PassengerRestartDir restart_files
55
        PassengerHighPerformance on
56
        PassengerMaxRequests 50000
57
        PassengerStatThrottleRate 5
58
	PassengerStartTimeout 60
59
	PassengerFriendlyErrorPages off
60
        RailsSpawnMethod smart
61
        ExpiresDefault "access plus 1 minute"
62
63
        <Location /sys>
64
		AuthType Basic
65
		AuthUserFile "/etc/apache2/auth/user.htpasswd"
66
		AuthName "code.soundsoftware.ac.uk"
67
		Require user user
68
	</Location>
69
70
	<Location /admin>
71
		AuthType Digest
72
		AuthUserFile "/etc/apache2/auth/admin.htdigest"
73
		AuthName "code.soundsoftware.ac.uk admin interface"
74
		Require user admin
75
	</Location>
76
77
        <DirectoryMatch "^/.*/\.svn/">
78
                Require all denied
79
        </DirectoryMatch>
80
81
        <DirectoryMatch "^/.*/\.hg/">
82
                Require all denied
83
        </DirectoryMatch>
84
85
        <DirectoryMatch "^/.*/\.git/">
86
                Require all denied
87
        </DirectoryMatch>
88
89
        <Directory /var/www/code/public>
90
                Options -MultiViews
91
	</Directory>
92
93
        <Directory /var/www/code/public/themes/soundsoftware/stylesheets/fonts>
94
		# Avoid other sites embedding our fonts
95
		RewriteEngine on
96
		RewriteCond %{HTTP_REFERER} !^$
97
		RewriteCond %{HTTP_REFERER} !^http(s)?://code.soundsoftware.ac.uk/.*$ [NC]
98
		RewriteRule \.(ttf|woff|eot|otf|svg|zip|gz|html|txt)$ - [F]
99
	</Directory>
100
101
	ScriptAlias /hg "/var/hg/index.cgi"
102
103
	<Location /hg>
104
               	AuthName "Mercurial"
105
                AuthType Basic
106
                Require valid-user
107
		PerlAccessHandler Apache::Authn::SoundSoftware::access_handler
108
      		PerlAuthenHandler Apache::Authn::SoundSoftware::authen_handler
109
		PerlSetVar HTTPS "on"
110
		SoundSoftwareDSN "dbi:Pg:database=code;host=localhost"
111
    		SoundSoftwareDbUser "code"
112
     		SoundSoftwareDbPass "INSERT_DATABASE_PASSWORD_HERE"
113
		SoundSoftwareRepoPrefix "/var/hg/"
114
                SoundSoftwareSslRequired "on"
115
		Options +ExecCGI
116
		AddHandler cgi-script .cgi
117
		ExpiresDefault now
118
        </Location>
119
120
	Alias /git "/var/files/git-mirror"
121
122
	<Directory "/var/files/git-mirror">
123
		Options -Indexes +FollowSymLinks
124
                Require all granted
125
	</Directory>
126
	<Directory ~ "/var/files/git-mirror/.*\.workdir">
127
                Require all denied
128
	</Directory>
129
	<Directory ~ "/var/files/git-mirror/__.*">
130
                Require all denied
131
	</Directory>
132
133
	ErrorLog /var/log/apache2/code-error.log
134
	CustomLog /var/log/apache2/code-access.log vhost_combined
135
136
        LogLevel warn
137
        ServerSignature Off
138
139
</VirtualHost>
140
141 1570:ae2f71010562 Chris
142
# A test Apache config. Lacks SSL, lacks a desirable extra layer of
143
# authentication for admin interface paths. Do not deploy this.
144
145 1593:83412a0a2389 Chris
# Note this has been updated for Apache 2.4, which introduced a number
146
# of (welcome) changes to access control directives.
147
148 1570:ae2f71010562 Chris
PerlLoadModule Apache::Authn::SoundSoftware
149
150
<VirtualHost *:80>
151
        ServerName code.soundsoftware.ac.uk
152
        ServerAdmin chris.cannam@soundsoftware.ac.uk
153
154
        DocumentRoot /var/www/code/public
155
        PassengerRestartDir restart_files
156
        PassengerHighPerformance on
157
        PassengerMaxRequests 50000
158
        PassengerStatThrottleRate 5
159
	PassengerStartTimeout 60
160 1571:4c2b25b7e85f Chris
	PassengerFriendlyErrorPages on
161 1570:ae2f71010562 Chris
        RailsSpawnMethod smart
162
        ExpiresDefault "access plus 1 minute"
163
164 1590:c18460da6620 Chris
#        <Location /sys>
165
#		AuthType Basic
166
#		AuthUserFile "/etc/apache2/auth/user.htpasswd"
167
#		AuthName "code.soundsoftware.ac.uk"
168
#		Require user user
169
#	</Location>
170
171
#	<Location /admin>
172
#		AuthType Digest
173
#		AuthUserFile "/etc/apache2/auth/admin.htdigest"
174
#		AuthName "code.soundsoftware.ac.uk admin interface"
175
#		Require user admin
176
#	</Location>
177
178 1570:ae2f71010562 Chris
        <DirectoryMatch "^/.*/\.svn/">
179 1593:83412a0a2389 Chris
                Require all denied
180 1570:ae2f71010562 Chris
        </DirectoryMatch>
181
182
        <DirectoryMatch "^/.*/\.hg/">
183 1593:83412a0a2389 Chris
                Require all denied
184 1570:ae2f71010562 Chris
        </DirectoryMatch>
185
186
        <DirectoryMatch "^/.*/\.git/">
187 1593:83412a0a2389 Chris
                Require all denied
188 1570:ae2f71010562 Chris
        </DirectoryMatch>
189
190
        <Directory /var/www/code/public>
191
                Options -MultiViews
192
	</Directory>
193
194
        <Directory /var/www/code/public/themes/soundsoftware/stylesheets/fonts>
195
		# Avoid other sites embedding our fonts
196
		RewriteEngine on
197
		RewriteCond %{HTTP_REFERER} !^$
198
		RewriteCond %{HTTP_REFERER} !^http(s)?://code.soundsoftware.ac.uk/.*$ [NC]
199
		RewriteRule \.(ttf|woff|eot|otf|svg|zip|gz|html|txt)$ - [F]
200
	</Directory>
201
202
	ScriptAlias /hg "/var/hg/index.cgi"
203
204
	<Location /hg>
205
               	AuthName "Mercurial"
206
                AuthType Basic
207
                Require valid-user
208
		PerlAccessHandler Apache::Authn::SoundSoftware::access_handler
209
      		PerlAuthenHandler Apache::Authn::SoundSoftware::authen_handler
210 1601:07deb8466f65 Chris
		PerlSetVar HTTPS "off"
211 1570:ae2f71010562 Chris
		SoundSoftwareDSN "dbi:Pg:database=code;host=localhost"
212
    		SoundSoftwareDbUser "code"
213 1593:83412a0a2389 Chris
     		SoundSoftwareDbPass "INSERT_DATABASE_PASSWORD_HERE"
214 1570:ae2f71010562 Chris
		SoundSoftwareRepoPrefix "/var/hg/"
215 1576:d1de6986e429 Chris
                #!!! "on" in production please!:
216
                SoundSoftwareSslRequired "off"
217 1570:ae2f71010562 Chris
		Options +ExecCGI
218
		AddHandler cgi-script .cgi
219
		ExpiresDefault now
220
        </Location>
221
222
	Alias /git "/var/files/git-mirror"
223
224
	<Directory "/var/files/git-mirror">
225
		Options -Indexes +FollowSymLinks
226 1593:83412a0a2389 Chris
                Require all granted
227 1570:ae2f71010562 Chris
	</Directory>
228
	<Directory ~ "/var/files/git-mirror/.*\.workdir">
229 1593:83412a0a2389 Chris
                Require all denied
230 1570:ae2f71010562 Chris
	</Directory>
231
	<Directory ~ "/var/files/git-mirror/__.*">
232 1593:83412a0a2389 Chris
                Require all denied
233 1570:ae2f71010562 Chris
	</Directory>
234
235
	ErrorLog /var/log/apache2/code-error.log
236
	CustomLog /var/log/apache2/code-access.log vhost_combined
237
238
        LogLevel warn
239
        ServerSignature Off
240
241
</VirtualHost>
242
243 1586:d0d59d12db94 Chris
#!/bin/sh
244 1590:c18460da6620 Chris
245 1586:d0d59d12db94 Chris
outfile="/var/files/backups/postgres-dumpall-`date +%Y%m%d%H%M`"
246 1590:c18460da6620 Chris
247 1586:d0d59d12db94 Chris
oldmask=`umask`
248
umask 0277
249 1590:c18460da6620 Chris
250 1586:d0d59d12db94 Chris
su postgres -c /usr/bin/pg_dumpall > "$outfile" && bzip2 "$outfile"
251 1590:c18460da6620 Chris
252 1586:d0d59d12db94 Chris
umask "$oldmask"
253
#!/bin/bash
254 1590:c18460da6620 Chris
255 1586:d0d59d12db94 Chris
cd /tmp
256 1590:c18460da6620 Chris
257 1586:d0d59d12db94 Chris
/var/www/code/docgen/extract-docs.sh
258 1590:c18460da6620 Chris
259 1586:d0d59d12db94 Chris
#!/bin/bash
260 1590:c18460da6620 Chris
261 1586:d0d59d12db94 Chris
sudo -u code sh -c "cd /var/www/code ; ./script/rails runner -e production extra/soundsoftware/get-statistics.rb >> log/statistics.log"
262 1590:c18460da6620 Chris
263 1586:d0d59d12db94 Chris
#!/bin/bash
264 1590:c18460da6620 Chris
265 1586:d0d59d12db94 Chris
tail -2 /var/log/external-repos.log
266
#!/bin/bash
267
268 1590:c18460da6620 Chris
## No longer used - this site is now static
269
270
# /usr/bin/wget -O - -q -t 1 http://www.soundsoftware.ac.uk/cron.php
271
272 1586:d0d59d12db94 Chris
#!/bin/bash
273 1590:c18460da6620 Chris
274 1586:d0d59d12db94 Chris
sudo -u code sh -c "cd /var/www/code ; ./script/rails runner \"Repository.fetch_changesets\" -e production 2>&1 | grep -v 'Not trusting' | grep -v 'svn:' | grep -v 'working copy' | grep -v 'deprecated' | grep -v 'version_requirements'"
275
exit 0
276 1590:c18460da6620 Chris
277 1586:d0d59d12db94 Chris
#!/bin/bash
278 1590:c18460da6620 Chris
279 1586:d0d59d12db94 Chris
sudo -H -u www-data /var/www/code/reposman/run-external.sh
280 1590:c18460da6620 Chris
281 1586:d0d59d12db94 Chris
#!/bin/sh
282 1590:c18460da6620 Chris
283 1586:d0d59d12db94 Chris
rm -f /var/www/code/tmp/cache/*/*/views*explore*
284
#!/bin/bash
285 1590:c18460da6620 Chris
286 1586:d0d59d12db94 Chris
logfile="/var/www/code/log/export-git.log"
287 1590:c18460da6620 Chris
288 1586:d0d59d12db94 Chris
sudo -u code sh -c "cd /tmp ; /var/www/code/extra/soundsoftware/export-git.sh production /var/hg /var/files/git-mirror >> $logfile 2>&1"
289 1590:c18460da6620 Chris
290 1586:d0d59d12db94 Chris
#!/bin/bash
291 1590:c18460da6620 Chris
292 1586:d0d59d12db94 Chris
sudo -u www-data /var/www/code/reposman/run-reposman.sh
293
294
#!/bin/sh
295 1596:45b0571b684d Chris
cd /
296 1586:d0d59d12db94 Chris
for location in var/www etc/apache2 etc/cron.*; do
297
	target="/var/files/backups/`echo $location | sed 's,/,_,g'`-`date +%Y%m%d%H%M`"
298
	oldmask=`umask`
299
	umask 0277
300
	tar cjf "$target".tar.bz2 "$location"
301
	umask "$oldmask"
302
done
303
304 1570:ae2f71010562 Chris
production:
305
  adapter: postgresql
306
  database: code
307
  host: localhost
308
  username: code
309 1593:83412a0a2389 Chris
  password: "INSERT_DATABASE_PASSWORD_HERE"
310 1570:ae2f71010562 Chris
311 1576:d1de6986e429 Chris
[paths]
312
/ = /var/hg/*
313
314
[web]
315
allow_archive = gz, zip, bz2
316
allow_push = *
317
#!/usr/bin/env python
318
#
319
# An example CGI script to export multiple hgweb repos, edit as necessary
320
321
# adjust python path if not a system-wide install:
322
#import sys
323
#sys.path.insert(0, "/path/to/python/lib")
324
325
# enable importing on demand to reduce startup time
326
from mercurial import demandimport; demandimport.enable()
327
328
# Uncomment to send python tracebacks to the browser if an error occurs:
329
import cgitb
330
cgitb.enable()
331
332
# If you'd like to serve pages with UTF-8 instead of your default
333
# locale charset, you can do so by uncommenting the following lines.
334
# Note that this will cause your .hgrc files to be interpreted in
335
# UTF-8 and all your repo files to be displayed using UTF-8.
336
#
337
import os
338
os.environ["HGENCODING"] = "UTF-8"
339
340
from mercurial.hgweb.hgwebdir_mod import hgwebdir
341
import mercurial.hgweb.wsgicgi as wsgicgi
342
343
# The config file looks like this.  You can have paths to individual
344
# repos, collections of repos in a directory tree, or both.
345
#
346
# [paths]
347
# virtual/path1 = /real/path1
348
# virtual/path2 = /real/path2
349
# virtual/root = /real/root/*
350
# / = /real/root2/*
351
# virtual/root2 = /real/root2/**
352
#
353
# [collections]
354
# /prefix/to/strip/off = /root/of/tree/full/of/repos
355
#
356
# paths example:
357
#
358
# * First two lines mount one repository into one virtual path, like
359
# '/real/path1' into 'virtual/path1'.
360
#
361
# * The third entry mounts every mercurial repository found in '/real/root'
362
# in 'virtual/root'. This format is preferred over the [collections] one,
363
# since using absolute paths as configuration keys is not supported on every
364
# platform (especially on Windows).
365
#
366
# * The fourth entry is a special case mounting all repositories in
367
# /'real/root2' in the root of the virtual directory.
368
#
369
# * The fifth entry recursively finds all repositories under the real root,
370
# and mounts them using their relative path (to given real root) under the
371
# virtual root.
372
#
373
# collections example: say directory tree /foo contains repos /foo/bar,
374
# /foo/quux/baz.  Give this config section:
375
#   [collections]
376
#   /foo = /foo
377
# Then repos will list as bar and quux/baz.
378
#
379
# Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
380
# or use a dictionary with entries like 'virtual/path': '/real/path'
381
382
application = hgwebdir('hgweb.config')
383
wsgicgi.launch(application)
384 1586:d0d59d12db94 Chris
# see "man logrotate" for details
385
# rotate log files weekly
386
weekly
387
388 1590:c18460da6620 Chris
# use the syslog group by default, since this is the owning group
389
# of /var/log/syslog.
390
su root syslog
391
392 1586:d0d59d12db94 Chris
# keep 4 weeks worth of backlogs
393
rotate 4
394
395
# create new (empty) log files after rotating old ones
396
create
397
398
# uncomment this if you want your log files compressed
399
#compress
400
401
# packages drop log rotation information into this directory
402
include /etc/logrotate.d
403
404
# no packages own wtmp, or btmp -- we'll rotate them here
405
/var/log/wtmp {
406
    missingok
407
    monthly
408
    create 0664 root utmp
409
    rotate 1
410
}
411
412
/var/log/btmp {
413
    missingok
414
    monthly
415
    create 0660 root utmp
416
    rotate 1
417
}
418
419
# system-specific logs may be configured here
420
/var/www/code/log/*.log {
421
	weekly
422
	missingok
423
	rotate 52
424
	compress
425
	delaycompress
426
	create 640 code code
427
	sharedscripts
428
	postrotate
429
		touch /var/www/code/restart_files/restart.txt
430
	endscript
431
}
432
433
/var/log/reposman.log {
434
        weekly
435
        missingok
436
        rotate 52
437
        compress
438
        delaycompress
439
        create 640 www-data code
440
        sharedscripts
441
}
442
443
/var/log/external-repos.log {
444
        weekly
445
        missingok
446
        rotate 52
447
        compress
448
        delaycompress
449
        create 640 www-data code
450
        sharedscripts
451
}
452
453 1571:4c2b25b7e85f Chris
PassengerMaxPoolSize 60
454
455
LoadModule passenger_module /var/lib/gems/2.3.0/gems/passenger-4.0.60/buildout/apache2/mod_passenger.so
456
PassengerRoot /var/lib/gems/2.3.0/gems/passenger-4.0.60
457
PassengerDefaultRuby /usr/bin/ruby2.3
458
# Apache::DBI is supposed to be a transparent replacement for Perl DBI with
459
# better performance when multiple connections are made with common DSN, user
460
# and password
461
PerlModule Apache::DBI
462 1590:c18460da6620 Chris
#!/bin/bash
463
logfile=/var/log/external-repos.log
464
(
465
flock -s 200
466
echo >> $logfile
467
date >> $logfile
468
/var/www/code/reposman/convert-external-repos.rb \
469
	-s /var/hg \
470 1593:83412a0a2389 Chris
	-r INSERT_API_SCHEME_HERE://INSERT_API_HOST_HERE/ \
471 1590:c18460da6620 Chris
	-k INSERT_API_KEY_HERE \
472
	-v \
473 1593:83412a0a2389 Chris
	--http-user=INSERT_API_USER_HERE \
474
	--http-pass=INSERT_API_PASSWORD_HERE \
475 1590:c18460da6620 Chris
        -c "/var/www/code/reposman/update-external-repo.sh" \
476
	>> $logfile 2>&1
477
date >> $logfile
478
echo Done >> $logfile
479
)200>>$logfile
480
#!/bin/bash
481
logfile=/var/log/reposman.log
482
(
483
flock -s 200
484
echo >> $logfile
485
/var/www/code/reposman/reposman-soundsoftware.rb \
486
	-s /var/hg \
487 1593:83412a0a2389 Chris
	-r INSERT_API_SCHEME_HERE://INSERT_API_HOST_HERE/ \
488 1590:c18460da6620 Chris
	-k INSERT_API_KEY_HERE \
489 1593:83412a0a2389 Chris
	--http-user=INSERT_API_USER_HERE \
490
	--http-pass=INSERT_API_PASSWORD_HERE \
491 1590:c18460da6620 Chris
	-o www-data \
492
	-g code \
493
	-c "/var/www/code/reposman/run-hginit.sh" \
494
	--scm=Mercurial \
495
	>> $logfile 2>&1
496
)200>>$logfile