Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/boto/pyami/installers/ubuntu/trac.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 # Copyright (c) 2008 Chris Moyer http://coredumped.org | |
2 # | |
3 # Permission is hereby granted, free of charge, to any person obtaining a | |
4 # copy of this software and associated documentation files (the | |
5 # "Software"), to deal in the Software without restriction, including | |
6 # without limitation the rights to use, copy, modify, merge, publish, dis- | |
7 # tribute, sublicense, and/or sell copies of the Software, and to permit | |
8 # persons to whom the Software is furnished to do so, subject to the fol- | |
9 # lowing conditions: | |
10 # | |
11 # The above copyright notice and this permission notice shall be included | |
12 # in all copies or substantial portions of the Software. | |
13 # | |
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | |
16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | |
17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
20 # IN THE SOFTWARE. | |
21 # | |
22 from boto.pyami.installers.ubuntu.installer import Installer | |
23 import boto | |
24 import os | |
25 | |
26 class Trac(Installer): | |
27 """ | |
28 Install Trac and DAV-SVN | |
29 Sets up a Vhost pointing to [Trac]->home | |
30 Using the config parameter [Trac]->hostname | |
31 Sets up a trac environment for every directory found under [Trac]->data_dir | |
32 | |
33 [Trac] | |
34 name = My Foo Server | |
35 hostname = trac.foo.com | |
36 home = /mnt/sites/trac | |
37 data_dir = /mnt/trac | |
38 svn_dir = /mnt/subversion | |
39 server_admin = root@foo.com | |
40 sdb_auth_domain = users | |
41 # Optional | |
42 SSLCertificateFile = /mnt/ssl/foo.crt | |
43 SSLCertificateKeyFile = /mnt/ssl/foo.key | |
44 SSLCertificateChainFile = /mnt/ssl/FooCA.crt | |
45 | |
46 """ | |
47 | |
48 def install(self): | |
49 self.run('apt-get -y install trac', notify=True, exit_on_error=True) | |
50 self.run('apt-get -y install libapache2-svn', notify=True, exit_on_error=True) | |
51 self.run("a2enmod ssl") | |
52 self.run("a2enmod mod_python") | |
53 self.run("a2enmod dav_svn") | |
54 self.run("a2enmod rewrite") | |
55 # Make sure that boto.log is writable by everyone so that subversion post-commit hooks can | |
56 # write to it. | |
57 self.run("touch /var/log/boto.log") | |
58 self.run("chmod a+w /var/log/boto.log") | |
59 | |
60 def setup_vhost(self): | |
61 domain = boto.config.get("Trac", "hostname").strip() | |
62 if domain: | |
63 domain_info = domain.split('.') | |
64 cnf = open("/etc/apache2/sites-available/%s" % domain_info[0], "w") | |
65 cnf.write("NameVirtualHost *:80\n") | |
66 if boto.config.get("Trac", "SSLCertificateFile"): | |
67 cnf.write("NameVirtualHost *:443\n\n") | |
68 cnf.write("<VirtualHost *:80>\n") | |
69 cnf.write("\tServerAdmin %s\n" % boto.config.get("Trac", "server_admin").strip()) | |
70 cnf.write("\tServerName %s\n" % domain) | |
71 cnf.write("\tRewriteEngine On\n") | |
72 cnf.write("\tRewriteRule ^(.*)$ https://%s$1\n" % domain) | |
73 cnf.write("</VirtualHost>\n\n") | |
74 | |
75 cnf.write("<VirtualHost *:443>\n") | |
76 else: | |
77 cnf.write("<VirtualHost *:80>\n") | |
78 | |
79 cnf.write("\tServerAdmin %s\n" % boto.config.get("Trac", "server_admin").strip()) | |
80 cnf.write("\tServerName %s\n" % domain) | |
81 cnf.write("\tDocumentRoot %s\n" % boto.config.get("Trac", "home").strip()) | |
82 | |
83 cnf.write("\t<Directory %s>\n" % boto.config.get("Trac", "home").strip()) | |
84 cnf.write("\t\tOptions FollowSymLinks Indexes MultiViews\n") | |
85 cnf.write("\t\tAllowOverride All\n") | |
86 cnf.write("\t\tOrder allow,deny\n") | |
87 cnf.write("\t\tallow from all\n") | |
88 cnf.write("\t</Directory>\n") | |
89 | |
90 cnf.write("\t<Location />\n") | |
91 cnf.write("\t\tAuthType Basic\n") | |
92 cnf.write("\t\tAuthName \"%s\"\n" % boto.config.get("Trac", "name")) | |
93 cnf.write("\t\tRequire valid-user\n") | |
94 cnf.write("\t\tAuthUserFile /mnt/apache/passwd/passwords\n") | |
95 cnf.write("\t</Location>\n") | |
96 | |
97 data_dir = boto.config.get("Trac", "data_dir") | |
98 for env in os.listdir(data_dir): | |
99 if(env[0] != "."): | |
100 cnf.write("\t<Location /trac/%s>\n" % env) | |
101 cnf.write("\t\tSetHandler mod_python\n") | |
102 cnf.write("\t\tPythonInterpreter main_interpreter\n") | |
103 cnf.write("\t\tPythonHandler trac.web.modpython_frontend\n") | |
104 cnf.write("\t\tPythonOption TracEnv %s/%s\n" % (data_dir, env)) | |
105 cnf.write("\t\tPythonOption TracUriRoot /trac/%s\n" % env) | |
106 cnf.write("\t</Location>\n") | |
107 | |
108 svn_dir = boto.config.get("Trac", "svn_dir") | |
109 for env in os.listdir(svn_dir): | |
110 if(env[0] != "."): | |
111 cnf.write("\t<Location /svn/%s>\n" % env) | |
112 cnf.write("\t\tDAV svn\n") | |
113 cnf.write("\t\tSVNPath %s/%s\n" % (svn_dir, env)) | |
114 cnf.write("\t</Location>\n") | |
115 | |
116 cnf.write("\tErrorLog /var/log/apache2/error.log\n") | |
117 cnf.write("\tLogLevel warn\n") | |
118 cnf.write("\tCustomLog /var/log/apache2/access.log combined\n") | |
119 cnf.write("\tServerSignature On\n") | |
120 SSLCertificateFile = boto.config.get("Trac", "SSLCertificateFile") | |
121 if SSLCertificateFile: | |
122 cnf.write("\tSSLEngine On\n") | |
123 cnf.write("\tSSLCertificateFile %s\n" % SSLCertificateFile) | |
124 | |
125 SSLCertificateKeyFile = boto.config.get("Trac", "SSLCertificateKeyFile") | |
126 if SSLCertificateKeyFile: | |
127 cnf.write("\tSSLCertificateKeyFile %s\n" % SSLCertificateKeyFile) | |
128 | |
129 SSLCertificateChainFile = boto.config.get("Trac", "SSLCertificateChainFile") | |
130 if SSLCertificateChainFile: | |
131 cnf.write("\tSSLCertificateChainFile %s\n" % SSLCertificateChainFile) | |
132 cnf.write("</VirtualHost>\n") | |
133 cnf.close() | |
134 self.run("a2ensite %s" % domain_info[0]) | |
135 self.run("/etc/init.d/apache2 force-reload") | |
136 | |
137 def main(self): | |
138 self.install() | |
139 self.setup_vhost() |