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