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