Update the logic behind the check for linux os
This commit is contained in:
parent
9a325c7a9a
commit
79a46e2cf6
|
@ -60,12 +60,12 @@ def get_version():
|
|||
|
||||
def get_integration():
|
||||
try:
|
||||
if getenv("AUTOCONF_MODE") == "yes":
|
||||
return "autoconf"
|
||||
elif getenv("SWARM_MODE") == "yes":
|
||||
return "swarm"
|
||||
elif getenv("KUBERNETES_MODE") == "yes":
|
||||
if getenv("KUBERNETES_MODE", "no") == "yes":
|
||||
return "kubernetes"
|
||||
elif getenv("SWARM_MODE", "no") == "yes":
|
||||
return "swarm"
|
||||
elif getenv("AUTOCONF_MODE", "no") == "yes":
|
||||
return "autoconf"
|
||||
elif Path("/usr/share/bunkerweb/INTEGRATION").is_file():
|
||||
return Path("/usr/share/bunkerweb/INTEGRATION").read_text().strip().lower()
|
||||
elif (
|
||||
|
|
|
@ -90,8 +90,13 @@ if __name__ == "__main__":
|
|||
integration = "Swarm"
|
||||
elif getenv("AUTOCONF_MODE", "no") == "yes":
|
||||
integration = "Autoconf"
|
||||
elif Path("/usr/share/bunkerweb/INTEGRATION").exists():
|
||||
elif Path("/usr/share/bunkerweb/INTEGRATION").is_file():
|
||||
integration = Path("/usr/share/bunkerweb/INTEGRATION").read_text().strip()
|
||||
elif (
|
||||
Path("/etc/os-release").is_file()
|
||||
and "Alpine" in Path("/etc/os-release").read_text()
|
||||
):
|
||||
integration = "Docker"
|
||||
|
||||
if args.variables:
|
||||
logger.info(f"Variables : {args.variables}")
|
||||
|
@ -163,7 +168,10 @@ if __name__ == "__main__":
|
|||
)
|
||||
templator.render()
|
||||
|
||||
if integration == "Linux" and not args.no_linux_reload:
|
||||
if (
|
||||
integration not in ("Autoconf", "Swarm", "Kubernetes", "Docker")
|
||||
and not args.no_linux_reload
|
||||
):
|
||||
retries = 0
|
||||
while not Path("/var/tmp/bunkerweb/nginx.pid").exists():
|
||||
if retries == 5:
|
||||
|
|
|
@ -142,6 +142,11 @@ if __name__ == "__main__":
|
|||
integration = "Autoconf"
|
||||
elif Path("/usr/share/bunkerweb/INTEGRATION").is_file():
|
||||
integration = Path("/usr/share/bunkerweb/INTEGRATION").read_text().strip()
|
||||
elif (
|
||||
Path("/etc/os-release").is_file()
|
||||
and "Alpine" in Path("/etc/os-release").read_text()
|
||||
):
|
||||
integration = "Docker"
|
||||
|
||||
if args.init:
|
||||
logger.info(f"Detected {integration} integration")
|
||||
|
|
|
@ -76,7 +76,7 @@ class JobScheduler(ApiCaller):
|
|||
|
||||
def __reload(self):
|
||||
reload = True
|
||||
if self.__integration == "Linux":
|
||||
if self.__integration not in ("Autoconf", "Swarm", "Kubernetes", "Docker"):
|
||||
self.__logger.info("Reloading nginx ...")
|
||||
proc = run(
|
||||
["nginx", "-s", "reload"], stdin=DEVNULL, stderr=PIPE, env=self.__env
|
||||
|
|
|
@ -106,7 +106,7 @@ def generate_custom_configs(
|
|||
Path(dirname(tmp_path)).mkdir(parents=True, exist_ok=True)
|
||||
Path(tmp_path).write_bytes(custom_config["data"])
|
||||
|
||||
if integration != "Linux":
|
||||
if integration not in ("Autoconf", "Swarm", "Kubernetes", "Docker"):
|
||||
logger.info("Sending custom configs to BunkerWeb")
|
||||
ret = api_caller._send_files("/data/configs", "/custom_configs")
|
||||
|
||||
|
@ -137,7 +137,7 @@ def generate_external_plugins(
|
|||
st = stat(job_file)
|
||||
chmod(job_file, st.st_mode | S_IEXEC)
|
||||
|
||||
if integration != "Linux":
|
||||
if integration not in ("Autoconf", "Swarm", "Kubernetes", "Docker"):
|
||||
logger.info("Sending plugins to BunkerWeb")
|
||||
ret = api_caller._send_files("/data/plugins", "/plugins")
|
||||
|
||||
|
@ -377,7 +377,7 @@ if __name__ == "__main__":
|
|||
logger.info("Successfully sent /data/cache folder")
|
||||
|
||||
# restart nginx
|
||||
if integration == "Linux":
|
||||
if integration not in ("Autoconf", "Swarm", "Kubernetes", "Docker"):
|
||||
# Stop temp nginx
|
||||
logger.info("Stopping temp nginx ...")
|
||||
proc = subprocess_run(
|
||||
|
@ -461,7 +461,7 @@ if __name__ == "__main__":
|
|||
|
||||
# reload nginx
|
||||
logger.info("Reloading nginx ...")
|
||||
if integration == "Linux":
|
||||
if integration not in ("Autoconf", "Swarm", "Kubernetes", "Docker"):
|
||||
# Reloading the nginx server.
|
||||
proc = subprocess_run(
|
||||
# Reload nginx
|
||||
|
|
Loading…
Reference in New Issue