4 from wizard import app, deploy, install, util
5 from wizard.app import php
7 def make_filename_regex(var):
8 return 'LocalSettings.php', re.compile('^(\$' + re.escape(var) + r'''\s*=\s*)(.*)(;)$''', re.M)
10 make_extractor = app.filename_regex_extractor(make_filename_regex)
12 class Application(deploy.Application):
13 parametrized_files = ['LocalSettings.php', 'php.ini']
16 if not self._extractors:
17 self._extractors = util.dictmap(make_extractor,
18 {'WIZARD_IP': 'IP' # obsolete, remove after we're done
19 ,'WIZARD_SITENAME': 'wgSitename'
20 ,'WIZARD_SCRIPTPATH': 'wgScriptPath'
21 ,'WIZARD_EMERGENCYCONTACT': 'wgEmergencyContact'
22 ,'WIZARD_DBSERVER': 'wgDBserver'
23 ,'WIZARD_DBNAME': 'wgDBname'
24 ,'WIZARD_DBUSER': 'wgDBuser'
25 ,'WIZARD_DBPASSWORD': 'wgDBpassword'
26 ,'WIZARD_PROXYKEY': 'wgProxyKey'
28 self._extractors.update(php.extractors)
29 return self._extractors
31 def install_handler(self):
32 handler = install.ArgHandler("mysql", "admin", "email")
33 handler.add(install.Arg("title", help="Title of your new MediaWiki install"))
35 def install(self, options):
37 os.unlink("LocalSettings.php")
42 'Sitename': options.title,
43 'EmergencyContact': options.email,
45 'DBserver': options.mysql_host,
46 'DBname': options.mysql_db,
47 'DBuser': options.mysql_user,
48 'DBpassword': options.mysql_password,
49 'DBpassword2': options.mysql_password,
50 'defaultEmail': options.email,
51 'SysopName': options.admin_name,
52 'SysopPass': options.admin_password,
53 'SysopPass2': options.admin_password,
55 result = install.fetch(options, 'config/index.php', post=postdata)
56 if options.verbose: print result
57 if result.find("Installation successful") == -1:
58 raise install.Failure()
59 os.rename('config/LocalSettings.php', 'LocalSettings.php')