mirror of
https://github.com/FAUSheppy/athq-vm-management
synced 2025-12-06 05:41:35 +01:00
feat: nginx main conf
This commit is contained in:
22
main.py
22
main.py
@@ -1,5 +1,7 @@
|
||||
import json
|
||||
import vm
|
||||
import sys
|
||||
import jinja2
|
||||
|
||||
ACME_CONTENT = '''
|
||||
location /.well-known/acme-challenge/ {
|
||||
@@ -10,7 +12,7 @@ location /.well-known/acme-challenge/ {
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
FILE = "vms.json"
|
||||
FILE = "./config/vms.json"
|
||||
with open(FILE) as f:
|
||||
jsonList = json.load(f)
|
||||
vmList = []
|
||||
@@ -21,18 +23,18 @@ if __name__ == "__main__":
|
||||
except ValueError as e:
|
||||
print(e, file=sys.stderr)
|
||||
|
||||
with open("./build/stream_include.conf", "w") as f:
|
||||
with open("/etc/nginx/stream_include.conf", "w") as f:
|
||||
for vmo in vmList:
|
||||
[ f.write(c) for c in vmo.dumpStreamComponents()]
|
||||
|
||||
with open("./build/http_include.conf", "w") as f:
|
||||
with open("/etc/nginx/http_include.conf", "w") as f:
|
||||
for vmo in vmList:
|
||||
[ f.write(c) for c in vmo.dumpServerComponents()]
|
||||
|
||||
with open("./build/acme-challenge.conf", "w") as f:
|
||||
with open("/etc/nginx/acme-challenge.conf", "w") as f:
|
||||
f.write(ACME_CONTENT)
|
||||
|
||||
with open("./build/cert.sh", "w") as f:
|
||||
with open("/etc/nginx/cert.sh", "w") as f:
|
||||
|
||||
f.write("certbot certonly --webroot -w /var/www \\")
|
||||
domains = []
|
||||
@@ -47,3 +49,13 @@ if __name__ == "__main__":
|
||||
f.write(" -d {} \\".format(d))
|
||||
|
||||
f.write("--rsa-key-size 2048 --expand")
|
||||
|
||||
with open("/etc/nginx/nginx.conf", "w") as f:
|
||||
|
||||
with open("./config/nginx.json") as j:
|
||||
nginxJson = json.load(j)
|
||||
env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates"))
|
||||
template = env.get_template("nginx.conf.j2")
|
||||
content = template.render(nginxJson)
|
||||
|
||||
f.write(content)
|
||||
|
||||
Reference in New Issue
Block a user