diff options
author | mia <mia@mia.jetzt> | 2024-06-30 18:29:59 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-06-30 18:29:59 -0700 |
commit | 809608c7ef4801f80adbd0ae07301e39c11e3951 (patch) | |
tree | bccd7c0607bd7edc3a2380fa230996c688357475 /nginx/sync.py | |
download | callosum-809608c7ef4801f80adbd0ae07301e39c11e3951.tar.gz callosum-809608c7ef4801f80adbd0ae07301e39c11e3951.zip |
initial commit
Diffstat (limited to 'nginx/sync.py')
-rw-r--r-- | nginx/sync.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/nginx/sync.py b/nginx/sync.py new file mode 100644 index 0000000..8387e99 --- /dev/null +++ b/nginx/sync.py @@ -0,0 +1,23 @@ +from commia.prelude import * +from commia.bearer import get_key, keys +from commia.ssh import scp, ssh_args, ssh_prewarm +from commia.util import with_written + +ssh_prewarm("asylum", "secrets@bearer") + +domains = get_key(keys.domains).splitlines() + +servers = [] +server_template = Path("nginx/server.conf").read_text() +for domain in domains: + servers.append(server_template.replace("%HOST%", domain)) +servers_indented = "\n".join( + map(lambda line: f"\t{line}", "\n".join(servers).splitlines()) +).strip() + +config = Path("nginx/nginx.conf").read_text().replace("%SERVERS%", servers_indented) + +with_written(config, lambda path: scp(path, "callosum:/etc/nginx/nginx.conf")) + +if run(p([*ssh_args(), "nginx", "-t"])).returncode == 0: + run_check(p([*ssh_args(), "systemctl", "restart", "nginx"])) |