diff --git a/misc/install-bunkerweb.sh b/misc/install-bunkerweb.sh index 752ada96d..47ea12b15 100644 --- a/misc/install-bunkerweb.sh +++ b/misc/install-bunkerweb.sh @@ -925,6 +925,12 @@ configure_full_config() { fi } +# Configure installation_type +configure_installation_type() { + print_status "Setting installation type to $INSTALL_TYPE" + echo "$INSTALL_TYPE" > /usr/share/bunkerweb/INSTALL_TYPE +} + # Function to install NGINX on Debian/Ubuntu install_nginx_debian() { print_step "Installing NGINX on Debian/Ubuntu" diff --git a/src/common/core/letsencrypt/jobs/certbot-auth.py b/src/common/core/letsencrypt/jobs/certbot-auth.py index 908806a6c..a0cbc7c11 100644 --- a/src/common/core/letsencrypt/jobs/certbot-auth.py +++ b/src/common/core/letsencrypt/jobs/certbot-auth.py @@ -11,7 +11,7 @@ sys_path.append(deps_path) from Database import Database # type: ignore -from common_utils import get_integration # type: ignore +from common_utils import get_integration, get_installation_type # type: ignore from logger import getLogger # type: ignore from API import API # type: ignore @@ -23,11 +23,12 @@ token = getenv("CERTBOT_TOKEN", "") validation = getenv("CERTBOT_VALIDATION", "") integration = get_integration() + install_type = get_installation_type() LOGGER.info(f"Detected {integration} integration") # Cluster case - if integration in ("Docker", "Swarm", "Kubernetes", "Autoconf"): + if integration in ("Docker", "Swarm", "Kubernetes", "Autoconf") or install_type in ("manager"): db = Database(LOGGER, sqlalchemy_string=getenv("DATABASE_URI")) instances = db.get_instances() diff --git a/src/common/core/letsencrypt/jobs/certbot-cleanup.py b/src/common/core/letsencrypt/jobs/certbot-cleanup.py index 61c09fb25..5e9030c6a 100644 --- a/src/common/core/letsencrypt/jobs/certbot-cleanup.py +++ b/src/common/core/letsencrypt/jobs/certbot-cleanup.py @@ -11,7 +11,7 @@ sys_path.append(deps_path) from Database import Database # type: ignore -from common_utils import get_integration # type: ignore +from common_utils import get_integration, get_installation_type # type: ignore from logger import getLogger # type: ignore from API import API # type: ignore @@ -22,11 +22,12 @@ # Get env vars token = getenv("CERTBOT_TOKEN", "") integration = get_integration() + install_type = get_installation_type() LOGGER.info(f"Detected {integration} integration") # Cluster case - if integration in ("Docker", "Swarm", "Kubernetes", "Autoconf"): + if integration in ("Docker", "Swarm", "Kubernetes", "Autoconf") or install_type in ("manager"): db = Database(LOGGER, sqlalchemy_string=getenv("DATABASE_URI")) instances = db.get_instances() diff --git a/src/common/utils/common_utils.py b/src/common/utils/common_utils.py index 503e1d40b..4892cbbab 100644 --- a/src/common/utils/common_utils.py +++ b/src/common/utils/common_utils.py @@ -69,6 +69,14 @@ def get_integration() -> str: except: return "Unknown" +def get_installation_type() -> str: + try: + installation_type_path = Path(sep, "usr", "share", "bunkerweb", "INSTALL_TYPE") + if installation_type_path.is_file(): + return installation_type_path.read_text(encoding="utf-8").strip() + return "Unknown" + except: + return "Unknown" def get_os_info() -> Dict[str, str]: os_data = {