4 from wizard import app, deploy, install, shell, util
5 from wizard.app import php
7 def make_filename_regex(var):
8 return 'LocalSettings.php', re.compile('^(\$' + app.expand_re(var) + r'''\s*=\s*)(.*)(;)$''', re.M)
10 make_extractor = app.filename_regex_extractor(make_filename_regex)
11 make_substitution = app.filename_regex_substitution(make_filename_regex)
13 'WIZARD_IP': 'IP', # obsolete, remove after we're done
14 'WIZARD_SITENAME': 'wgSitename',
15 'WIZARD_SCRIPTPATH': 'wgScriptPath',
16 'WIZARD_EMERGENCYCONTACT': ('wgEmergencyContact', 'wgPasswordSender'),
17 'WIZARD_DBSERVER': 'wgDBserver',
18 'WIZARD_DBNAME': 'wgDBname',
19 'WIZARD_DBUSER': 'wgDBuser',
20 'WIZARD_DBPASSWORD': 'wgDBpassword',
21 'WIZARD_SECRETKEY': ('wgSecretKey', 'wgProxyKey'),
24 class Application(deploy.Application):
25 parametrized_files = ['LocalSettings.php', 'php.ini']
26 deprecated_keys = set(['WIZARD_IP']) | php.deprecated_keys
29 if not self._extractors:
30 self._extractors = util.dictmap(make_extractor, seed)
31 self._extractors.update(php.extractors)
32 return self._extractors
34 def substitutions(self):
35 if not self._substitutions:
36 self._substitutions = util.dictkmap(make_substitution, seed)
37 self._substitutions.update(php.substitutions)
38 return self._substitutions
40 def install_handler(self):
41 handler = install.ArgHandler("mysql", "admin", "email")
42 handler.add(install.Arg("title", help="Title of your new MediaWiki install"))
44 def install(self, options):
46 os.unlink("LocalSettings.php")
50 os.chmod("config", 0777) # XXX: vaguely sketchy
53 'Sitename': options.title,
54 'EmergencyContact': options.email,
56 'DBserver': options.mysql_host,
57 'DBname': options.mysql_db,
58 'DBuser': options.mysql_user,
59 'DBpassword': options.mysql_password,
60 'DBpassword2': options.mysql_password,
61 'defaultEmail': options.email,
62 'SysopName': options.admin_name,
63 'SysopPass': options.admin_password,
64 'SysopPass2': options.admin_password,
66 result = install.fetch(options, 'config/index.php', post=postdata)
67 if options.verbose: print result
68 if result.find("Installation successful") == -1:
69 raise install.Failure()
70 os.rename('config/LocalSettings.php', 'LocalSettings.php')
71 def upgrade(self, options):
73 sh.call("php", "maintenance/update.php")