@@ -122,18 +122,24 @@ def generate_config_from_template(environ, ownership):
122
122
return config_path
123
123
124
124
125
- def run_generate_config (environ ):
125
+ def run_generate_config (environ , ownership ):
126
126
"""Run synapse with a --generate-config param to generate a template config file
127
127
128
128
Args:
129
- environ (dict): environment dictionary
129
+ environ (dict): env var dict
130
+ ownership (str): "userid:groupid" arg for chmod
130
131
131
132
Never returns.
132
133
"""
133
134
for v in ("SYNAPSE_SERVER_NAME" , "SYNAPSE_REPORT_STATS" , "SYNAPSE_CONFIG_PATH" ):
134
135
if v not in environ :
135
136
error ("Environment variable '%s' is mandatory in `generate` mode." % (v ,))
136
137
138
+ data_dir = environ .get ("SYNAPSE_DATA_DIR" , "/data" )
139
+
140
+ # make sure that synapse has perms to write to the data dir.
141
+ subprocess .check_output (["chown" , ownership , data_dir ])
142
+
137
143
args = [
138
144
"python" ,
139
145
"-m" ,
@@ -144,18 +150,21 @@ def run_generate_config(environ):
144
150
environ ["SYNAPSE_REPORT_STATS" ],
145
151
"--config-path" ,
146
152
environ ["SYNAPSE_CONFIG_PATH" ],
153
+ "--data-directory" ,
154
+ data_dir ,
147
155
"--generate-config" ,
148
156
]
157
+ # log("running %s" % (args, ))
149
158
os .execv ("/usr/local/bin/python" , args )
150
159
151
160
152
161
def main (args , environ ):
153
162
mode = args [1 ] if len (args ) > 1 else None
154
163
ownership = "{}:{}" .format (environ .get ("UID" , 991 ), environ .get ("GID" , 991 ))
155
164
156
- # In generate mode, generate a configuration, missing keys, then exit
165
+ # In generate mode, generate a configuration and missing keys, then exit
157
166
if mode == "generate" :
158
- return run_generate_config (environ )
167
+ return run_generate_config (environ , ownership )
159
168
160
169
# In normal mode, generate missing keys if any, then run synapse
161
170
if "SYNAPSE_CONFIG_PATH" in environ :
0 commit comments