]> scripts.mit.edu Git - wizard.git/commitdiff
phpBB support
authorAlan Huang <cesium@mit.edu>
Mon, 7 Dec 2009 08:02:13 +0000 (03:02 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Mon, 7 Dec 2009 08:06:09 +0000 (03:06 -0500)
Signed-off-by: Alan Huang <cesium@mit.edu>
tests/phpbb-install-test.sh [new file with mode: 0755]
wizard/app/phpBB.py [new file with mode: 0644]
wizard/command/prepare_pristine.py
wizard/install/__init__.py

diff --git a/tests/phpbb-install-test.sh b/tests/phpbb-install-test.sh
new file mode 100755 (executable)
index 0000000..074bca9
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash -e
+
+DEFAULT_HEAD=1
+TESTNAME="phpbb_install"
+source ./setup
+
+wizard install "phpBB-$VERSION-scripts" "$TESTDIR" --non-interactive -- --title="omgwtfphpBBq"
diff --git a/wizard/app/phpBB.py b/wizard/app/phpBB.py
new file mode 100644 (file)
index 0000000..e356857
--- /dev/null
@@ -0,0 +1,138 @@
+import shutil
+import logging
+import os.path
+
+from wizard import app, install, resolve, util
+from wizard.app import php
+
+#phpBB                104 installs
+#    2.0.19            87  ++++++++++++++++++++++++++++++
+#    3.0.4             17  ++++++
+
+CONFIG = 'config.php'
+def make_filename_regex(var):
+       return CONFIG, php.re_var(var)
+
+seed = util.dictmap(make_filename_regex, {
+               '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)
index c24a9fe18631dbcd2df5842bc8288d9443c3fbe3..3f16e2f40d142fa01b9a0e00e9f9e33e74b89620 100644 (file)
@@ -16,12 +16,13 @@ def main(argv, baton):
         with open(base, "w") as outfile:
             infile = urllib.urlopen(url)
             shutil.copyfileobj(infile, outfile)
+        sh.call("tar", "xf", base)
+        os.unlink(base)
     else:
         base = args[0]
+        sh.call("tar", "xf", base)
     # extract the files, but be smart: if only one directory is output,
     # move the contents of that directory here
-    sh.call("tar", "xf", base)
-    os.unlink(base)
     items = [f for f in os.listdir(os.getcwd()) if f[0] != "."]
     if len(items) == 1 and os.path.isdir(items[0]):
         os.rename(items[0], "_wizard_source")
index 666fcf9d3640548dbffbe79ef36ff42229435ecb..3c214a872e823f741050698fdc160dec57921cc8 100644 (file)
@@ -152,7 +152,7 @@ class ScriptsMysqlStrategy(Strategy):
         host, username, password = self._triplet
         # race condition
         database = self._username + '+' + sh.eval("/mit/scripts/sql/bin/get-next-database", os.path.basename(self.dir))
-        sh.call("/mit/scripts/sql/bin/create-database", name)
+        sh.call("/mit/scripts/sql/bin/create-database", database)
         options.dsn = sqlalchemy.engine.url.URL("mysql", username=username, password=password, host=host, database=database)
 
 class ScriptsEmailStrategy(Strategy):