~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to bin/ivle-config

Remove phpBB3 configuration from ivle-config.

Now the only forum-related thing in the main IVLE configuration is the forum
secret. That also now persists across configurations, rather than being
clobbered.

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
    """
130
130
# Database name"""))
131
131
 
132
 
config_options.append(ConfigOption("plugins/forum/dbname", "ivle_forum",
133
 
    """Forum Database name:""",
134
 
    """
135
 
# Forum Database name"""))
136
 
 
137
132
config_options.append(ConfigOption("database/username", "postgres",
138
133
    """Username for DB server login:""",
139
134
    """
272
267
 
273
268
    # the files that will be created/overwritten
274
269
    conffile = os.path.join(cwd, "etc/ivle.conf")
275
 
    phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php")
276
270
 
277
271
    # Get command-line arguments to avoid asking questions.
278
272
 
288
282
    if opts == []:
289
283
        # Interactive mode. Prompt the user for all the values.
290
284
 
291
 
        print """This tool will create the following files:
292
 
    %s
293
 
    %s
294
 
prompting you for details about your configuration. The file will be
295
 
overwritten if it already exists. It will *not* install or deploy IVLE.
 
285
        print """This tool will create %s, prompting you for details about
 
286
your configuration. The file will be overwritten if it already exists.
296
287
 
297
288
Please hit Ctrl+C now if you do not wish to do this.
298
 
""" % (conffile, phpBBconffile)
 
289
""" % conffile
299
290
 
300
291
        # Get information from the administrator
301
292
        # If EOF is encountered at any time during the questioning, just exit
342
333
    except KeyError:
343
334
        conf['usrmgt']['magic'] = hashlib.md5(uuid.uuid4().bytes).hexdigest()
344
335
 
345
 
    # Generate the forum secret
346
 
    forum_secret = hashlib.md5(uuid.uuid4().bytes).hexdigest()
347
336
 
348
337
    # Write ./etc/ivle.conf (even if we loaded from a different filename)
349
338
    conf.filename = conffile
350
339
 
351
340
    conf.initial_comment = ["# IVLE Configuration File"]
352
341
 
353
 
    # Add the forum secret to the config file (regenerated each config)
354
 
    config_options.append(ConfigOption('plugins/forum/secret', None, '', ''))
355
 
    conf['plugins']['forum']['secret'] = forum_secret
 
342
    try:
 
343
        conf['plugins']['forum']['secret']
 
344
    except KeyError:
 
345
        # Generate the forum secret.
 
346
        forum_secret = hashlib.md5(uuid.uuid4().bytes).hexdigest()
 
347
        conf['plugins']['forum']['secret'] = forum_secret
356
348
 
357
349
    conf.write()
358
350
 
359
351
    print "Successfully wrote %s" % conffile
360
 
 
361
 
    # Write www/php/phpBB3/config.php
362
 
 
363
 
    conf_php = open(phpBBconffile, "w")
364
 
    
365
 
    # php-pg work around
366
 
    if conf['database']['host'] == 'localhost':
367
 
        forumdb_host = '127.0.0.1'
368
 
    else:
369
 
        forumdb_host = conf['database']['host']
370
 
 
371
 
    conf_php.write( """<?php
372
 
// phpBB 3.0.x auto-generated configuration file
373
 
// Do not change anything in this file!
374
 
$dbms = 'postgres';
375
 
$dbhost = '""" + forumdb_host + """';
376
 
$dbport = '""" + str(conf['database']['port']) + """';
377
 
$dbname = '""" + conf['plugins']['forum']['dbname'] + """';
378
 
$dbuser = '""" + conf['database']['username'] + """';
379
 
$dbpasswd = '""" + conf['database']['password'] + """';
380
 
 
381
 
$table_prefix = 'phpbb_';
382
 
$acm_type = 'file';
383
 
$load_extensions = '';
384
 
@define('PHPBB_INSTALLED', true);
385
 
// @define('DEBUG', true);
386
 
//@define('DEBUG_EXTRA', true);
387
 
 
388
 
$forum_secret = '""" + forum_secret +"""';
389
 
?>"""   )
390
 
    
391
 
    conf_php.close()
392
 
 
393
 
    print "Successfully wrote %s" % phpBBconffile
394
 
 
395
 
    print
396
 
    print "You may modify the configuration at any time by editing"
397
 
    print conffile
398
 
    print phpBBconffile
399
 
    print
 
352
    print
 
353
    print "You may modify the configuration at any time by editing " + conffile
400
354
    
401
355
    return 0
402
356