X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/99972e96020fa15901d735e3f077206ee52c50e1..3965a0be399060b8ff0cee09633c0a0c821d319c:/wizard/app/phpBB.py diff --git a/wizard/app/phpBB.py b/wizard/app/phpBB.py index e356857..c8fa1f5 100644 --- a/wizard/app/phpBB.py +++ b/wizard/app/phpBB.py @@ -1,8 +1,9 @@ import shutil import logging import os.path +import distutils.version -from wizard import app, install, resolve, util +from wizard import app, install, resolve, sql, util from wizard.app import php #phpBB 104 installs @@ -11,128 +12,138 @@ from wizard.app import php CONFIG = 'config.php' def make_filename_regex(var): - return CONFIG, php.re_var(var) + """See :ref:`versioning config ` for more information.""" + return CONFIG, php.re_var(var) seed = util.dictmap(make_filename_regex, { - 'WIZARD_DBSERVER' : 'dbhost', - 'WIZARD_DBNAME' : 'dbname', - 'WIZARD_DBUSER' : 'dbuser', - 'WIZARD_DBPASSWORD' : 'dbpasswd' }) + 'WIZARD_DBSERVER' : 'dbhost', + 'WIZARD_DBNAME' : 'dbname', + 'WIZARD_DBUSER' : 'dbuser', + 'WIZARD_DBPASSWORD' : 'dbpasswd' }) class Application(app.Application): - install_schema = install.ArgSchema('db', 'admin', 'email', 'title') - database = 'mysql' - parametrized_files = [ CONFIG ] + php.parametrized_files - extractors = app.make_extractors(seed) - extractors.update(php.extractors) - substitutions = app.make_substitutions(seed) - substitutions.update(php.substitutions) - - def checkConfig(self, deployment): - return os.path.getsize('config.php') - - def detectVersion(self, deployment): - version = self.detectVersionFromFile('install/database_update.php', php.re_var('updates_to_version')) - if version.startswith('.'): # blehh, but phpBB2 uses '.0.19'... - version = '2' + version - return version - - def remove(self, deployment, options): - app.remove_database(deployment) - - def install(self, version, options): - self.install_2(options) - - def install_2(self, options): - database_dict = { - 'lang' : 'english', - 'dbms' : 'mysql', - 'upgrade' : '0', - 'dbhost' : options.dsn.host, - 'dbname' : options.dsn.database, - 'dbuser' : options.dsn.username, - 'dbpasswd' : options.dsn.password, - 'prefix' : '', - 'board_email' : options.email, - 'server_name' : options.web_host, - 'server_port' : '80', - 'script_path' : options.web_path, - 'admin_name' : options.admin_name, - 'admin_pass1' : options.admin_password, - 'admin_pass2' : options.admin_password, - 'install_step' : '1', - 'cur_lang' : 'english' } - - result = install.fetch(options, 'install/install.php', database_dict) - logging.debug('install.php output:\n\n' + result) - if 'Thank you' not in result: - raise app.InstallFailure() - #shutil.rmtree('install') - #shutil.rmtree('contrib') - - def install_3(self, options): - def install_helper(sub, post): - uri = 'install/index.php?mode=install&language=en' - if sub: - uri += '&sub=%s' % sub - result = install.fetch(options, uri, post) - logging.debug('%s (%s) output:\n\n' % (uri, sub) + result) - return result - - # *deep breath* - install_helper('', {}) - install_helper('requirements', {}) - - database_dict = { 'img_imagick' : '/usr/bin/' } - install_helper('database', database_dict) - - database_dict.update({ - 'dbms' : 'mysql', - 'dbhost' : options.mysql_host, - 'dbname' : options.mysql_db, - 'dbuser' : options.mysql_user, - 'dbpasswd' : options.mysql_password, - 'table_prefix' : '', - 'img_imagick' : '/usr/bin/', - 'language' : 'en', - 'testdb' : 'true' }) - install_helper('database', database_dict) - - database_dict['dbport'] = '' - del database_dict['testdb'] - install_helper('administrator', database_dict) - - database_dict.update({ - 'default_lang' : 'en', - 'admin_name' : options.admin_name, - 'admin_pass1' : options.admin_password, - 'admin_pass2' : options.admin_password, - 'board_email1' : options.email, - 'board_email2' : options.email, - 'check' : 'true' }) - install_helper('administrator', database_dict) - - del database_dict['check'] - install_helper('config_file', database_dict) - install_helper('advanced', database_dict) - - database_dict.update({ - 'email_enable' : '1', - 'smtp_delivery' : '0', - 'smtp_auth' : 'PLAIN', - 'cookie_secure' : '0', - 'force_server_vars' : '0', - 'server_protocol' : 'http://', - 'server_name' : options.web_host, - 'server_port' : '80', - 'script_path' : options.web_path }) - install_helper('create_table', database_dict) - - database_dict.update({ - 'ftp_path' : '', - 'ftp_user' : '', - 'ftp_pass' : '', - 'smtp_host' : '', - 'smtp_user' : '', - 'smtp_pass' : '' }) - install_helper('final', database_dict) + install_schema = install.ArgSchema('db', 'admin', 'email', 'title') + database = 'mysql' + parametrized_files = [ CONFIG ] + php.parametrized_files + extractors = app.make_extractors(seed) + extractors.update(php.extractors) + substitutions = app.make_substitutions(seed) + substitutions.update(php.substitutions) + + def checkConfig(self, deployment): + return os.path.getsize('config.php') + + def detectVersion(self, deployment): + version = str(self.detectVersionFromFile('install/update_to_latest.php', php.re_var('updates_to_version'))) + if version.startswith('.'): # blehh, but phpBB2 uses '.0.19'... + version = '2' + version + return distutils.version.LooseVersion(version) + + @app.throws_database_errors + def remove(self, deployment, options): + sql.drop(deployment.dsn) + + def install(self, version, options): + old_mode = os.stat(".").st_mode + os.chmod("config.php", 0777) + self.install_2(options) + os.chmod("config.php", old_mode) + php.ini_replace_vars() + + def install_2(self, options): + database_dict = { + 'lang' : 'english', + 'dbms' : 'mysql', + 'upgrade' : '0', + 'dbhost' : options.dsn.host, + 'dbname' : options.dsn.database, + 'dbuser' : options.dsn.username, + 'dbpasswd' : options.dsn.password, + 'prefix' : '', + 'board_email' : options.email, + 'server_name' : options.web_host, + 'server_port' : '80', + 'script_path' : options.web_path, + 'admin_name' : options.admin_name, + 'admin_pass1' : options.admin_password, + 'admin_pass2' : options.admin_password, + 'install_step' : '1', + 'cur_lang' : 'english' } + + result = install.fetch(options, 'install/install.php', database_dict) + logging.debug('install.php output:\n\n' + result) + if 'Thank you' not in result: + raise app.InstallFailure() + # Removing these trees will make upgrade merges annoying. Maybe + # we should patch out the check and stick .htaccess files which + # block access for these folders (we'd probably have to make it + # available again for an upgrade though) + #shutil.rmtree('install') + #shutil.rmtree('contrib') + + def install_3(self, options): + def install_helper(sub, post): + uri = 'install/index.php?mode=install&language=en' + if sub: + uri += '&sub=%s' % sub + result = install.fetch(options, uri, post) + logging.debug('%s (%s) output:\n\n' % (uri, sub) + result) + return result + + # *deep breath* + install_helper('', {}) + install_helper('requirements', {}) + + database_dict = { 'img_imagick' : '/usr/bin/' } + install_helper('database', database_dict) + + database_dict.update({ + 'dbms' : 'mysql', + 'dbhost' : options.mysql_host, + 'dbname' : options.mysql_db, + 'dbuser' : options.mysql_user, + 'dbpasswd' : options.mysql_password, + 'table_prefix' : '', + 'img_imagick' : '/usr/bin/', + 'language' : 'en', + 'testdb' : 'true' }) + install_helper('database', database_dict) + + database_dict['dbport'] = '' + del database_dict['testdb'] + install_helper('administrator', database_dict) + + database_dict.update({ + 'default_lang' : 'en', + 'admin_name' : options.admin_name, + 'admin_pass1' : options.admin_password, + 'admin_pass2' : options.admin_password, + 'board_email1' : options.email, + 'board_email2' : options.email, + 'check' : 'true' }) + install_helper('administrator', database_dict) + + del database_dict['check'] + install_helper('config_file', database_dict) + install_helper('advanced', database_dict) + + database_dict.update({ + 'email_enable' : '1', + 'smtp_delivery' : '0', + 'smtp_auth' : 'PLAIN', + 'cookie_secure' : '0', + 'force_server_vars' : '0', + 'server_protocol' : 'http://', + 'server_name' : options.web_host, + 'server_port' : '80', + 'script_path' : options.web_path }) + install_helper('create_table', database_dict) + + database_dict.update({ + 'ftp_path' : '', + 'ftp_user' : '', + 'ftp_pass' : '', + 'smtp_host' : '', + 'smtp_user' : '', + 'smtp_pass' : '' }) + install_helper('final', database_dict)