]> scripts.mit.edu Git - wizard.git/commitdiff
Replace WIZARD variables in php.ini with user-specific values
authorAndrew M. Farrell <afarrell@mit.edu>
Mon, 7 Dec 2009 09:04:25 +0000 (04:04 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Mon, 28 Dec 2009 02:09:36 +0000 (21:09 -0500)
Signed-off-by: Andrew M. Farrell <afarrell@mit.edu>
wizard/app/mediawiki.py
wizard/app/php.py
wizard/app/phpBB.py
wizard/app/wordpress.py

index c6ac8ae3f419448ccebd4744426ba2f65c98380c..a527b3b491d2f2dca49601d3e05b0d23aaff95f7 100644 (file)
@@ -70,6 +70,8 @@ class Application(app.Application):
             else:
                 raise app.RecoverableInstallFailure(error_messages)
         os.rename('config/LocalSettings.php', 'LocalSettings.php')
+        php.ini_replace_vars()
+
     def upgrade(self, d, version, options):
         if not os.path.isfile("AdminSettings.php"):
             shell.call("git", "checkout", "-q", "mediawiki-" + str(version), "--", "AdminSettings.php")
index 5dbc5190869d3b8bd519579e89bb7accc595d67e..b617195949c62d38f53bd25e91a95b54203218e1 100644 (file)
@@ -7,6 +7,7 @@ Common data and functions for use in PHP applications.
 """
 
 import re
+import os
 
 from wizard import app, util
 
@@ -33,6 +34,15 @@ def re_define(var):
 def _make_filename_regex(var):
     return 'php.ini', re.compile('^(' + app.expand_re(var) + r'\s*=\s*)(.*)()$', re.M)
 
+def ini_replace_vars():
+    """
+    Replace ``WIZARD_TMPDIR`` and ``WIZARD_SESSIONNAME`` with with user-specific values.
+    """
+    text = open('php.ini', "r").read()
+    text = text.replace('WIZARD_TMPDIR', '/mit/%s/web_scripts_tmp' % os.environ['USER'])
+    text = text.replace('WIZARD_SESSIONNAME', '%s_SID' % os.environ['USER'])
+    open('php.ini', "w").write(text)
+
 seed = util.dictmap(_make_filename_regex, {
         'WIZARD_SESSIONNAME': 'session.name',
         'WIZARD_TMPDIR': ('upload_tmp_dir', 'session.save_path'),
index 4fb1602126583e47c609e2c94f92ad4237619918..fef7ac3d9fc7e5de50f6a82ab88290d8f9c8ad07 100644 (file)
@@ -45,6 +45,7 @@ class Application(app.Application):
                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 = {
index 8b1f9cb9d73e441b22bd21644a6434d98d5820a8..a068fb859ff03022057fc3632d36c4927463fb63 100644 (file)
@@ -81,6 +81,7 @@ class Application(app.Application):
         wp_options.update().where(wp_options.c.option_name == 'siteurl').values(option_value=options.web_path).execute()
         wp_options.update().where(wp_options.c.option_name == 'home').values(option_value="http://%s%s" % (options.web_host, options.web_path)).execute() # XXX: what if missing leading slash; this should be put in a function
         # should also set the username and admin password
+        php.ini_replace_vars()
     def upgrade(self, d, version, options):
         result = d.fetch("wp-admin/upgrade.php?step=1")
         if "Upgrade Complete" not in result and "No Upgrade Required" not in result: