5 from wizard import app, install, resolve, util
6 from wizard.app import php
9 # 2.0.19 87 ++++++++++++++++++++++++++++++
13 def make_filename_regex(var):
14 """See :ref:`versioning config <seed>` for more information."""
15 return CONFIG, php.re_var(var)
17 seed = util.dictmap(make_filename_regex, {
18 'WIZARD_DBSERVER' : 'dbhost',
19 'WIZARD_DBNAME' : 'dbname',
20 'WIZARD_DBUSER' : 'dbuser',
21 'WIZARD_DBPASSWORD' : 'dbpasswd' })
23 class Application(app.Application):
24 install_schema = install.ArgSchema('db', 'admin', 'email', 'title')
26 parametrized_files = [ CONFIG ] + php.parametrized_files
27 extractors = app.make_extractors(seed)
28 extractors.update(php.extractors)
29 substitutions = app.make_substitutions(seed)
30 substitutions.update(php.substitutions)
32 def checkConfig(self, deployment):
33 return os.path.getsize('config.php')
35 def detectVersion(self, deployment):
36 version = self.detectVersionFromFile('install/database_update.php', php.re_var('updates_to_version'))
37 if version.startswith('.'): # blehh, but phpBB2 uses '.0.19'...
38 version = '2' + version
41 def remove(self, deployment, options):
42 app.remove_database(deployment)
44 def install(self, version, options):
45 old_mode = os.stat(".").st_mode
46 os.chmod("config.php", 0777)
47 self.install_2(options)
48 os.chmod("config.php", old_mode)
49 php.ini_replace_vars()
51 def install_2(self, options):
56 'dbhost' : options.dsn.host,
57 'dbname' : options.dsn.database,
58 'dbuser' : options.dsn.username,
59 'dbpasswd' : options.dsn.password,
61 'board_email' : options.email,
62 'server_name' : options.web_host,
64 'script_path' : options.web_path,
65 'admin_name' : options.admin_name,
66 'admin_pass1' : options.admin_password,
67 'admin_pass2' : options.admin_password,
69 'cur_lang' : 'english' }
71 result = install.fetch(options, 'install/install.php', database_dict)
72 logging.debug('install.php output:\n\n' + result)
73 if 'Thank you' not in result:
74 raise app.InstallFailure()
75 #shutil.rmtree('install')
76 #shutil.rmtree('contrib')
78 def install_3(self, options):
79 def install_helper(sub, post):
80 uri = 'install/index.php?mode=install&language=en'
82 uri += '&sub=%s' % sub
83 result = install.fetch(options, uri, post)
84 logging.debug('%s (%s) output:\n\n' % (uri, sub) + result)
88 install_helper('', {})
89 install_helper('requirements', {})
91 database_dict = { 'img_imagick' : '/usr/bin/' }
92 install_helper('database', database_dict)
94 database_dict.update({
96 'dbhost' : options.mysql_host,
97 'dbname' : options.mysql_db,
98 'dbuser' : options.mysql_user,
99 'dbpasswd' : options.mysql_password,
101 'img_imagick' : '/usr/bin/',
104 install_helper('database', database_dict)
106 database_dict['dbport'] = ''
107 del database_dict['testdb']
108 install_helper('administrator', database_dict)
110 database_dict.update({
111 'default_lang' : 'en',
112 'admin_name' : options.admin_name,
113 'admin_pass1' : options.admin_password,
114 'admin_pass2' : options.admin_password,
115 'board_email1' : options.email,
116 'board_email2' : options.email,
118 install_helper('administrator', database_dict)
120 del database_dict['check']
121 install_helper('config_file', database_dict)
122 install_helper('advanced', database_dict)
124 database_dict.update({
125 'email_enable' : '1',
126 'smtp_delivery' : '0',
127 'smtp_auth' : 'PLAIN',
128 'cookie_secure' : '0',
129 'force_server_vars' : '0',
130 'server_protocol' : 'http://',
131 'server_name' : options.web_host,
132 'server_port' : '80',
133 'script_path' : options.web_path })
134 install_helper('create_table', database_dict)
136 database_dict.update({
143 install_helper('final', database_dict)