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