]> scripts.mit.edu Git - wizard.git/blob - wizard/app/phpBB.py
phpBB support
[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                 self.install_2(options)
45         
46         def install_2(self, options):
47                 database_dict = {
48                                 'lang' : 'english',
49                                 'dbms' : 'mysql',
50                                 'upgrade' : '0',
51                                 'dbhost' : options.dsn.host,
52                                 'dbname' : options.dsn.database,
53                                 'dbuser' : options.dsn.username,
54                                 'dbpasswd' : options.dsn.password,
55                                 'prefix' : '',
56                                 'board_email' : options.email,
57                                 'server_name' : options.web_host,
58                                 'server_port' : '80',
59                                 'script_path' : options.web_path,
60                                 'admin_name' : options.admin_name,
61                                 'admin_pass1' : options.admin_password,
62                                 'admin_pass2' : options.admin_password,
63                                 'install_step' : '1',
64                                 'cur_lang' : 'english' }
65                 
66                 result = install.fetch(options, 'install/install.php', database_dict)
67                 logging.debug('install.php output:\n\n' + result)
68                 if 'Thank you' not in result:
69                         raise app.InstallFailure()
70                 #shutil.rmtree('install')
71                 #shutil.rmtree('contrib')
72         
73         def install_3(self, options):
74                 def install_helper(sub, post):
75                         uri = 'install/index.php?mode=install&language=en'
76                         if sub:
77                                 uri += '&sub=%s' % sub
78                         result = install.fetch(options, uri, post)
79                         logging.debug('%s (%s) output:\n\n' % (uri, sub) + result)
80                         return result
81                 
82                 # *deep breath*
83                 install_helper('', {})
84                 install_helper('requirements', {})
85                 
86                 database_dict = { 'img_imagick' : '/usr/bin/' }
87                 install_helper('database', database_dict)
88                 
89                 database_dict.update({
90                                 'dbms' : 'mysql',
91                                 'dbhost' : options.mysql_host,
92                                 'dbname' : options.mysql_db,
93                                 'dbuser' : options.mysql_user,
94                                 'dbpasswd' : options.mysql_password,
95                                 'table_prefix' : '',
96                                 'img_imagick' : '/usr/bin/',
97                                 'language' : 'en',
98                                 'testdb' : 'true' })
99                 install_helper('database', database_dict)
100                 
101                 database_dict['dbport'] = ''
102                 del database_dict['testdb']
103                 install_helper('administrator', database_dict)
104                 
105                 database_dict.update({
106                                 'default_lang' : 'en',
107                                 'admin_name' : options.admin_name,
108                                 'admin_pass1' : options.admin_password,
109                                 'admin_pass2' : options.admin_password,
110                                 'board_email1' : options.email,
111                                 'board_email2' : options.email,
112                                 'check' : 'true' })
113                 install_helper('administrator', database_dict)
114                 
115                 del database_dict['check']
116                 install_helper('config_file', database_dict)
117                 install_helper('advanced', database_dict)
118                 
119                 database_dict.update({
120                                 'email_enable' : '1',
121                                 'smtp_delivery' : '0',
122                                 'smtp_auth' : 'PLAIN',
123                                 'cookie_secure' : '0',
124                                 'force_server_vars' : '0',
125                                 'server_protocol' : 'http://',
126                                 'server_name' : options.web_host,
127                                 'server_port' : '80',
128                                 'script_path' : options.web_path })
129                 install_helper('create_table', database_dict)
130                 
131                 database_dict.update({
132                                 'ftp_path' : '',
133                                 'ftp_user' : '',
134                                 'ftp_pass' : '',
135                                 'smtp_host' : '',
136                                 'smtp_user' : '',
137                                 'smtp_pass' : '' })
138                 install_helper('final', database_dict)