]> scripts.mit.edu Git - wizard.git/blob - wizard/app/phpBB.py
Update MediaWiki config regexes
[wizard.git] / wizard / app / phpBB.py
1 import shutil
2 import logging
3 import os.path
4 import distutils.version
5
6 from wizard import app, install, resolve, sql, util
7 from wizard.app import php
8
9 #phpBB                104 installs
10 #    2.0.19            87  ++++++++++++++++++++++++++++++
11 #    3.0.4             17  ++++++
12
13 CONFIG = 'config.php'
14 def make_filename_regex(var):
15     """See :ref:`versioning config <seed>` for more information."""
16     return CONFIG, php.re_var(var)
17
18 seed = util.dictmap(make_filename_regex, {
19         'WIZARD_DBSERVER' : 'dbhost',
20         'WIZARD_DBNAME' : 'dbname',
21         'WIZARD_DBUSER' : 'dbuser',
22         'WIZARD_DBPASSWORD' : 'dbpasswd' })
23
24 class Application(app.Application):
25     fullname = "phpBB"
26     install_schema = install.ArgSchema('db', 'admin', 'email', 'title')
27     database = 'mysql'
28     parametrized_files = [ CONFIG ] + php.parametrized_files
29     extractors = app.make_extractors(seed)
30     extractors.update(php.extractors)
31     substitutions = app.make_substitutions(seed)
32     substitutions.update(php.substitutions)
33
34     def checkConfig(self, deployment):
35         return os.path.getsize('config.php')
36
37     def detectVersion(self, deployment):
38         version = str(self.detectVersionFromFile('install/update_to_latest.php', php.re_var('updates_to_version')))
39         if version.startswith('.'): # blehh, but phpBB2 uses '.0.19'...
40             version = '2' + version
41         return distutils.version.LooseVersion(version)
42
43     @app.throws_database_errors
44     def remove(self, deployment, options):
45         sql.drop(deployment.dsn)
46
47     def install(self, version, options):
48         old_mode = os.stat(".").st_mode
49         os.chmod("config.php", 0777)
50         self.install_2(options)
51         os.chmod("config.php", old_mode)
52         php.ini_replace_vars()
53
54     def install_2(self, options):
55         database_dict = {
56                 'lang' : 'english',
57                 'dbms' : 'mysql',
58                 'upgrade' : '0',
59                 'dbhost' : options.dsn.host,
60                 'dbname' : options.dsn.database,
61                 'dbuser' : options.dsn.username,
62                 'dbpasswd' : options.dsn.password,
63                 'prefix' : '',
64                 'board_email' : options.email,
65                 'server_name' : options.web_host,
66                 'server_port' : '80',
67                 'script_path' : options.web_path,
68                 'admin_name' : options.admin_name,
69                 'admin_pass1' : options.admin_password,
70                 'admin_pass2' : options.admin_password,
71                 'install_step' : '1',
72                 'cur_lang' : 'english' }
73
74         result = install.fetch(options, 'install/install.php', database_dict)
75         logging.debug('install.php output:\n\n' + result)
76         if 'Thank you' not in result:
77             raise app.InstallFailure()
78         # Removing these trees will make upgrade merges annoying.  Maybe
79         # we should patch out the check and stick .htaccess files which
80         # block access for these folders (we'd probably have to make it
81         # available again for an upgrade though)
82         #shutil.rmtree('install')
83         #shutil.rmtree('contrib')
84
85     def install_3(self, options):
86         def install_helper(sub, post):
87             uri = 'install/index.php?mode=install&language=en'
88             if sub:
89                 uri += '&sub=%s' % sub
90             result = install.fetch(options, uri, post)
91             logging.debug('%s (%s) output:\n\n' % (uri, sub) + result)
92             return result
93
94         # *deep breath*
95         install_helper('', {})
96         install_helper('requirements', {})
97
98         database_dict = { 'img_imagick' : '/usr/bin/' }
99         install_helper('database', database_dict)
100
101         database_dict.update({
102                 'dbms' : 'mysql',
103                 'dbhost' : options.mysql_host,
104                 'dbname' : options.mysql_db,
105                 'dbuser' : options.mysql_user,
106                 'dbpasswd' : options.mysql_password,
107                 'table_prefix' : '',
108                 'img_imagick' : '/usr/bin/',
109                 'language' : 'en',
110                 'testdb' : 'true' })
111         install_helper('database', database_dict)
112
113         database_dict['dbport'] = ''
114         del database_dict['testdb']
115         install_helper('administrator', database_dict)
116
117         database_dict.update({
118                 'default_lang' : 'en',
119                 'admin_name' : options.admin_name,
120                 'admin_pass1' : options.admin_password,
121                 'admin_pass2' : options.admin_password,
122                 'board_email1' : options.email,
123                 'board_email2' : options.email,
124                 'check' : 'true' })
125         install_helper('administrator', database_dict)
126
127         del database_dict['check']
128         install_helper('config_file', database_dict)
129         install_helper('advanced', database_dict)
130
131         database_dict.update({
132                 'email_enable' : '1',
133                 'smtp_delivery' : '0',
134                 'smtp_auth' : 'PLAIN',
135                 'cookie_secure' : '0',
136                 'force_server_vars' : '0',
137                 'server_protocol' : 'http://',
138                 'server_name' : options.web_host,
139                 'server_port' : '80',
140                 'script_path' : options.web_path })
141         install_helper('create_table', database_dict)
142
143         database_dict.update({
144                 'ftp_path' : '',
145                 'ftp_user' : '',
146                 'ftp_pass' : '',
147                 'smtp_host' : '',
148                 'smtp_user' : '',
149                 'smtp_pass' : '' })
150         install_helper('final', database_dict)