mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-03-03 07:49:14 -05:00
Add a main() function
This commit is contained in:
parent
b1fddb7f69
commit
3f24e4dce7
@ -129,16 +129,15 @@ def run_generate_config(environ):
|
|||||||
os.execv("/usr/local/bin/python", args)
|
os.execv("/usr/local/bin/python", args)
|
||||||
|
|
||||||
|
|
||||||
# Prepare the configuration
|
def main(args, environ):
|
||||||
mode = sys.argv[1] if len(sys.argv) > 1 else None
|
mode = args[1] if len(args) > 1 else None
|
||||||
ownership = "{}:{}".format(environ.get("UID", 991), environ.get("GID", 991))
|
ownership = "{}:{}".format(environ.get("UID", 991), environ.get("GID", 991))
|
||||||
|
|
||||||
# In generate mode, generate a configuration, missing keys, then exit
|
# In generate mode, generate a configuration, missing keys, then exit
|
||||||
if mode == "generate":
|
if mode == "generate":
|
||||||
run_generate_config(environ)
|
return run_generate_config(environ)
|
||||||
|
|
||||||
# In normal mode, generate missing keys if any, then run synapse
|
# In normal mode, generate missing keys if any, then run synapse
|
||||||
else:
|
|
||||||
if "SYNAPSE_CONFIG_PATH" in environ:
|
if "SYNAPSE_CONFIG_PATH" in environ:
|
||||||
config_path = environ["SYNAPSE_CONFIG_PATH"]
|
config_path = environ["SYNAPSE_CONFIG_PATH"]
|
||||||
else:
|
else:
|
||||||
@ -158,3 +157,7 @@ else:
|
|||||||
# Generate missing keys and start synapse
|
# Generate missing keys and start synapse
|
||||||
subprocess.check_output(args + ["--generate-keys"])
|
subprocess.check_output(args + ["--generate-keys"])
|
||||||
os.execv("/sbin/su-exec", ["su-exec", ownership] + args)
|
os.execv("/sbin/su-exec", ["su-exec", ownership] + args)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main(sys.argv, os.environ)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user