From a18d77aeee539477b036093672e54e575be621ea Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 27 Jun 2022 08:50:14 +0200 Subject: [PATCH] autoconf - init work on static server configs as env var --- CHANGELOG.md | 3 ++- autoconf/DockerController.py | 12 +++++++----- autoconf/SwarmController.py | 10 +++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41e3af3d7..40507f658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## v1.4.2 - +- Fix wrong env file when running jobs using Linux integration - Fix bwcli unban command when using Linux integration - Fix permissions check when filename has a space - Fix static config (SERVER_NAME not empty) support when using autoconf/swarm/k8s @@ -9,7 +10,7 @@ - Add log_default() plugin hook - Add various certbot-dns examples - Force NGINX version dependencies in Linux packages DEB/RPM -- Add Discord to supported plugins +- Add Discord to supported official plugins ## v1.4.1 - 2022/16/06 diff --git a/autoconf/DockerController.py b/autoconf/DockerController.py index ea1d2409a..e2d52cf55 100644 --- a/autoconf/DockerController.py +++ b/autoconf/DockerController.py @@ -5,7 +5,7 @@ from docker import DockerClient from Controller import Controller from logger import log -class DockerController(Controller) : +class DockerController(Controller, ConfigCaller) : def __init__(self, docker_host) : super().__init__("docker") @@ -22,10 +22,9 @@ class DockerController(Controller) : instance["env"] = {} for env in controller_instance.attrs["Config"]["Env"] : variable = env.split("=")[0] - if variable in ["PATH", "NGINX_VERSION", "NJS_VERSION", "PKG_RELEASE"] : - continue value = env.replace(variable + "=", "", 1) - instance["env"][variable] = value + if self._is_setting(variable) : + instance["env"][variable] = value return [instance] def _get_controller_services(self) : @@ -36,7 +35,10 @@ class DockerController(Controller) : for variable, value in controller_service.labels.items() : if not variable.startswith("bunkerweb.") : continue - service[variable.replace("bunkerweb.", "", 1)] = value + real_variable = variable.replace("bunkerweb.", "", 1) + if not self._is_multisite_setting(real_variable) : + continue + service[real_variable] = value return [service] def get_configs(self) : diff --git a/autoconf/SwarmController.py b/autoconf/SwarmController.py index f35f1f5a4..e918a9b26 100644 --- a/autoconf/SwarmController.py +++ b/autoconf/SwarmController.py @@ -6,7 +6,7 @@ from base64 import b64decode from Controller import Controller -class SwarmController(Controller) : +class SwarmController(Controller, ConfigCaller) : def __init__(self, docker_host) : super().__init__("swarm") @@ -22,7 +22,8 @@ class SwarmController(Controller) : for env in controller_instance.attrs["Spec"]["TaskTemplate"]["ContainerSpec"]["Env"] : variable = env.split("=")[0] value = env.replace(variable + "=", "", 1) - instance_env[variable] = value + if self._is_setting(variable) : + instance["env"][variable] = value for task in controller_instance.tasks() : instance = {} instance["name"] = task["ID"] @@ -40,7 +41,10 @@ class SwarmController(Controller) : for variable, value in controller_service.attrs["Spec"]["Labels"].items() : if not variable.startswith("bunkerweb.") : continue - service[variable.replace("bunkerweb.", "", 1)] = value + real_variable = variable.replace("bunkerweb.", "", 1) + if not self._is_multisite_setting(real_variable) : + continue + service[real_variable] = value return [service] def get_configs(self) :