diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-05-01 13:54:38 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-05-01 13:54:38 +0100 |
commit | 46a65c282fc92d2c783af84423ef4a0690a2cf48 (patch) | |
tree | ae09151860643c597375a918efb081736ae90372 /synapse/config | |
parent | Allow "manhole" to be ommited from the config (diff) | |
download | synapse-46a65c282fc92d2c783af84423ef4a0690a2cf48.tar.xz |
Allow generate-config to run against an existing config file to generate default keys
Diffstat (limited to 'synapse/config')
-rw-r--r-- | synapse/config/_base.py | 35 | ||||
-rw-r--r-- | synapse/config/database.py | 3 | ||||
-rw-r--r-- | synapse/config/registration.py | 2 |
3 files changed, 26 insertions, 14 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py index d7ccfcd98c..cd4bd28e8c 100644 --- a/synapse/config/_base.py +++ b/synapse/config/_base.py @@ -159,26 +159,37 @@ class Config(object): print "Most specify a server_name to a generate config for." sys.exit(1) (config_path,) = config_args.config_path - if os.path.exists(config_path): - print "Config file %r already exists. Not overwriting" % ( - config_args.config_path - ) - sys.exit(1) if not os.path.exists(config_dir_path): os.makedirs(config_dir_path) + if os.path.exists(config_path): + print "Config file %r already exists" % (config_path,) + yaml_config = cls.read_config_file(config_path) + yaml_name = yaml_config["server_name"] + if server_name != yaml_name: + print ( + "Config file %r has a different server_name: " + " %r != %r" % (config_path, server_name, yaml_name) + ) + sys.exit(1) + config_bytes, config = obj.generate_config( + config_dir_path, server_name + ) + config.update(yaml_config) + print "Generating any missing keys for %r" % (server_name,) + obj.invoke_all("generate_files", config) + sys.exit(0) with open(config_path, "wb") as config_file: - config_bytes, config = obj.generate_config( config_dir_path, server_name ) obj.invoke_all("generate_files", config) config_file.write(config_bytes) - print ( - "A config file has been generated in %s for server name" - " '%s' with corresponding SSL keys and self-signed" - " certificates. Please review this file and customise it to" - " your needs." - ) % (config_path, server_name) + print ( + "A config file has been generated in %s for server name" + " '%s' with corresponding SSL keys and self-signed" + " certificates. Please review this file and customise it to" + " your needs." + ) % (config_path, server_name) print ( "If this server name is incorrect, you will need to regenerate" " the SSL certificates" diff --git a/synapse/config/database.py b/synapse/config/database.py index ccd96c4f0f..f0611e8884 100644 --- a/synapse/config/database.py +++ b/synapse/config/database.py @@ -56,6 +56,7 @@ class DatabaseConfig(Config): args: # Path to the database database: "%(database_path)s" + # Number of events to cache in memory. event_cache_size: "10K" """ % locals() @@ -68,7 +69,7 @@ class DatabaseConfig(Config): database_path = self.abspath(database_path) if self.database_config.get("name", None) == "sqlite3": if database_path is not None: - self.database_config["database"] = database_path + self.database_config["args"]["database"] = database_path def add_arguments(self, parser): db_group = parser.add_argument_group("database") diff --git a/synapse/config/registration.py b/synapse/config/registration.py index 971965a5da..b39989a87f 100644 --- a/synapse/config/registration.py +++ b/synapse/config/registration.py @@ -49,7 +49,7 @@ class RegistrationConfig(Config): def add_arguments(self, parser): reg_group = parser.add_argument_group("registration") reg_group.add_argument( - "--enable-registration", action="store_true", + "--enable-registration", action="store_true", default=None, help="Enable registration for new users." ) |