1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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"]))
|