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 checkConfig(self, deployment):
45 return os.path.isfile(os.path.join(deployment.location, "LocalSettings.php"))
46 def install(self, options):
48 os.unlink("LocalSettings.php")
52 os.chmod("config", 0777) # XXX: vaguely sketchy
55 'Sitename': options.title,
56 'EmergencyContact': options.email,
58 'DBserver': options.mysql_host,
59 'DBname': options.mysql_db,
60 'DBuser': options.mysql_user,
61 'DBpassword': options.mysql_password,
62 'DBpassword2': options.mysql_password,
63 'defaultEmail': options.email,
64 'SysopName': options.admin_name,
65 'SysopPass': options.admin_password,
66 'SysopPass2': options.admin_password,
68 result = install.fetch(options, 'config/index.php', post=postdata)
69 if options.verbose: print result
70 if result.find("Installation successful") == -1:
71 raise install.Failure()
72 os.rename('config/LocalSettings.php', 'LocalSettings.php')
73 def upgrade(self, options):
75 sh.call("php", "maintenance/update.php")