commit
1f7cef1f4b
15
main.py
15
main.py
@ -42,22 +42,22 @@ def update_host(host: str) -> bool:
|
||||
if not container_name:
|
||||
print("No nginx container")
|
||||
return False
|
||||
|
||||
|
||||
gen_command = f"docker exec {container_name} certbot --nginx --email emmtvv@gmail.com --agree-tos --non-interactive -d \"{host}\""
|
||||
print(gen_command)
|
||||
|
||||
|
||||
gen_cert = call(gen_command)
|
||||
if gen_cert.code != 0:
|
||||
print(f"failed generating certificate: {gen_cert.err}")
|
||||
print("Here is the log")
|
||||
print(call(f"docker exec {container_name} cat /var/log/letsencrypt/letsencrypt.log").out)
|
||||
return False
|
||||
|
||||
|
||||
fullchain_command = call(f"docker exec {container_name} cat /etc/letsencrypt/live/{host}/fullchain.pem")
|
||||
if fullchain_command.code != 0:
|
||||
print(f"failed getting fullchain: {fullchain_command.err}")
|
||||
return True
|
||||
|
||||
|
||||
privkey_command = call(f"docker exec {container_name} cat /etc/letsencrypt/live/{host}/privkey.pem")
|
||||
if privkey_command.code != 0:
|
||||
print(f"failed getting fullchain: {privkey_command.err}")
|
||||
@ -83,10 +83,9 @@ while True:
|
||||
updated = True
|
||||
if updated:
|
||||
if os.getenv("STAGE") == "development":
|
||||
container_id_run = call(f"echo $(docker ps -q -f name=infra-development_nginx)")
|
||||
result = call(f"docker restart {container_id_run.out}")
|
||||
container_id_run = call(f"echo $(docker ps -q -f name=infra-development_nginx)").out
|
||||
else:
|
||||
result = call("docker service update --force infra_nginx")
|
||||
container_id_run = call(f"echo $(docker ps -q -f name=infra_nginx)").out
|
||||
print(call("docker exec {container_id_run} python3 prepare.py && nginx -s reload").out)
|
||||
|
||||
print(result.err, result.out)
|
||||
time.sleep(30)
|
||||
|
Loading…
Reference in New Issue
Block a user