Compare commits
No commits in common. "d4af35ddbf85c221c71405f74f2306bc3b91c58c" and "c0eefdf3f0cec33d6046c78fbac689c0187c739f" have entirely different histories.
d4af35ddbf
...
c0eefdf3f0
17
main.py
17
main.py
@ -28,22 +28,9 @@ def get_hosts() -> list[str]:
|
|||||||
def update_host(host: str):
|
def update_host(host: str):
|
||||||
gen_cert = call(f"docker exec $(docker ps -q -f name=infra_nginx) certbot --nginx --email emmtvv@gmail.com --agree-tos -d \"{host}\"")
|
gen_cert = call(f"docker exec $(docker ps -q -f name=infra_nginx) certbot --nginx --email emmtvv@gmail.com --agree-tos -d \"{host}\"")
|
||||||
if gen_cert.code != 0:
|
if gen_cert.code != 0:
|
||||||
print(f"failed generating certificate: {gen_cert.err}")
|
print("failed generating certificate")
|
||||||
return
|
return
|
||||||
|
|
||||||
fullchain_command = call(f"docker exec $(docker ps -q -f name=infra_nginx) cat /etc/letsencrypt/live/{host}/fullchain.pem")
|
|
||||||
if fullchain_command.code != 0:
|
|
||||||
print(f"failed getting fullchain: {fullchain_command.err}")
|
|
||||||
return
|
|
||||||
|
|
||||||
privkey_command = call(f"docker exec $(docker ps -q -f name=infra_nginx) cat /etc/letsencrypt/live/{host}/privkey.pem")
|
|
||||||
if privkey_command.code != 0:
|
|
||||||
print(f"failed getting fullchain: {privkey_command.err}")
|
|
||||||
return
|
|
||||||
fullchain = fullchain_command.out.encode("utf-8")
|
|
||||||
privkey = privkey_command.out.encode("utf-8")
|
|
||||||
minio.put_object("certupdater", f"certificates/{host}/fullchain.pem", fullchain, len(fullchain))
|
|
||||||
minio.put_object("certupdater", f"certificates/{host}/privkey.pem", privkey, len(privkey))
|
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@ -53,5 +40,5 @@ while True:
|
|||||||
if now + datetime.timedelta(days=14) > mongo_hosts.get(host, {"expire_time": datetime.datetime.fromtimestamp(1)})["expire_time"]:
|
if now + datetime.timedelta(days=14) > mongo_hosts.get(host, {"expire_time": datetime.datetime.fromtimestamp(1)})["expire_time"]:
|
||||||
update_host(host)
|
update_host(host)
|
||||||
print(f"Host {host} updated")
|
print(f"Host {host} updated")
|
||||||
mongo.update_date(host)
|
minio.put_object("certupdater", "nginx.conf", )
|
||||||
time.sleep(5 * 60)
|
time.sleep(5 * 60)
|
Loading…
Reference in New Issue
Block a user