mirror of
https://github.com/bunkerity/bunkerized-nginx
synced 2023-12-13 21:30:18 +01:00
Fix letsencrypt jobs
This commit is contained in:
parent
c18f743d44
commit
5deeacc3d4
5 changed files with 36 additions and 17 deletions
|
@ -30,14 +30,20 @@ try:
|
|||
# Get env vars
|
||||
bw_integration = "Linux"
|
||||
integration_path = Path(sep, "usr", "share", "bunkerweb", "INTEGRATION")
|
||||
if getenv("KUBERNETES_MODE") == "yes":
|
||||
os_release_path = Path(sep, "etc", "os-release")
|
||||
if getenv("KUBERNETES_MODE", "no") == "yes":
|
||||
bw_integration = "Kubernetes"
|
||||
elif getenv("SWARM_MODE") == "yes":
|
||||
elif getenv("SWARM_MODE", "no") == "yes":
|
||||
bw_integration = "Swarm"
|
||||
elif getenv("AUTOCONF_MODE") == "yes":
|
||||
elif getenv("AUTOCONF_MODE", "no") == "yes":
|
||||
bw_integration = "Autoconf"
|
||||
elif integration_path.is_file():
|
||||
integration = integration_path.read_text(encoding="utf-8").strip()
|
||||
bw_integration = integration_path.read_text(encoding="utf-8").strip()
|
||||
elif os_release_path.is_file() and "Alpine" in os_release_path.read_text(
|
||||
encoding="utf-8"
|
||||
):
|
||||
bw_integration = "Docker"
|
||||
|
||||
token = getenv("CERTBOT_TOKEN", "")
|
||||
validation = getenv("CERTBOT_VALIDATION", "")
|
||||
|
||||
|
|
|
@ -30,14 +30,20 @@ try:
|
|||
# Get env vars
|
||||
bw_integration = "Linux"
|
||||
integration_path = Path(sep, "usr", "share", "bunkerweb", "INTEGRATION")
|
||||
if getenv("KUBERNETES_MODE") == "yes":
|
||||
os_release_path = Path(sep, "etc", "os-release")
|
||||
if getenv("KUBERNETES_MODE", "no") == "yes":
|
||||
bw_integration = "Kubernetes"
|
||||
elif getenv("SWARM_MODE") == "yes":
|
||||
elif getenv("SWARM_MODE", "no") == "yes":
|
||||
bw_integration = "Swarm"
|
||||
elif getenv("AUTOCONF_MODE") == "yes":
|
||||
elif getenv("AUTOCONF_MODE", "no") == "yes":
|
||||
bw_integration = "Autoconf"
|
||||
elif integration_path.is_file():
|
||||
integration = integration_path.read_text(encoding="utf-8").strip()
|
||||
bw_integration = integration_path.read_text(encoding="utf-8").strip()
|
||||
elif os_release_path.is_file() and "Alpine" in os_release_path.read_text(
|
||||
encoding="utf-8"
|
||||
):
|
||||
bw_integration = "Docker"
|
||||
|
||||
token = getenv("CERTBOT_TOKEN", "")
|
||||
|
||||
# Cluster case
|
||||
|
|
|
@ -33,14 +33,20 @@ try:
|
|||
# Get env vars
|
||||
bw_integration = "Linux"
|
||||
integration_path = Path(sep, "usr", "share", "bunkerweb", "INTEGRATION")
|
||||
if getenv("KUBERNETES_MODE") == "yes":
|
||||
os_release_path = Path(sep, "etc", "os-release")
|
||||
if getenv("KUBERNETES_MODE", "no") == "yes":
|
||||
bw_integration = "Kubernetes"
|
||||
elif getenv("SWARM_MODE") == "yes":
|
||||
elif getenv("SWARM_MODE", "no") == "yes":
|
||||
bw_integration = "Swarm"
|
||||
elif getenv("AUTOCONF_MODE") == "yes":
|
||||
elif getenv("AUTOCONF_MODE", "no") == "yes":
|
||||
bw_integration = "Autoconf"
|
||||
elif integration_path.is_file():
|
||||
integration = integration_path.read_text(encoding="utf-8").strip()
|
||||
bw_integration = integration_path.read_text(encoding="utf-8").strip()
|
||||
elif os_release_path.is_file() and "Alpine" in os_release_path.read_text(
|
||||
encoding="utf-8"
|
||||
):
|
||||
bw_integration = "Docker"
|
||||
|
||||
token = getenv("CERTBOT_TOKEN", "")
|
||||
|
||||
logger.info(f"Certificates renewal for {getenv('RENEWED_DOMAINS')} successful")
|
||||
|
|
|
@ -147,10 +147,10 @@ try:
|
|||
certbot_new(domains, real_email, letsencrypt_path, letsencrypt_job_path)
|
||||
!= 0
|
||||
):
|
||||
status = 2
|
||||
logger.error(
|
||||
f"Certificate generation failed for domain(s) {domains} ...",
|
||||
)
|
||||
_exit(2)
|
||||
else:
|
||||
status = 1
|
||||
logger.info(
|
||||
|
|
|
@ -32,11 +32,11 @@ def renew(domain: str, letsencrypt_path: Path) -> int:
|
|||
join(sep, "usr", "share", "bunkerweb", "deps", "python", "bin", "certbot"),
|
||||
"renew",
|
||||
"--config-dir",
|
||||
letsencrypt_path.joinpath("etc"),
|
||||
str(letsencrypt_path.joinpath("etc")),
|
||||
"--work-dir",
|
||||
letsencrypt_path.joinpath("lib"),
|
||||
str(letsencrypt_path.joinpath("lib")),
|
||||
"--logs-dir",
|
||||
letsencrypt_path.joinpath("log"),
|
||||
str(letsencrypt_path.joinpath("log")),
|
||||
"--cert-name",
|
||||
domain,
|
||||
"--deploy-hook",
|
||||
|
@ -53,7 +53,8 @@ def renew(domain: str, letsencrypt_path: Path) -> int:
|
|||
],
|
||||
stdin=DEVNULL,
|
||||
stderr=STDOUT,
|
||||
env=environ,
|
||||
env=environ.copy()
|
||||
| {"PYTHONPATH": join(sep, "usr", "share", "bunkerweb", "deps", "python")},
|
||||
check=False,
|
||||
).returncode
|
||||
|
||||
|
|
Loading…
Reference in a new issue