diff --git a/misc/update-version.sh b/misc/update-version.sh index a5ffab00..28d1a86d 100755 --- a/misc/update-version.sh +++ b/misc/update-version.sh @@ -24,4 +24,6 @@ sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" README.md sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" tests/ui/docker-compose.yml for test in tests/core/* ; do sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" ${test}/docker-compose.yml -done \ No newline at end of file +done +# linux +sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" src/linux/scripts*.sh diff --git a/src/common/core/letsencrypt/jobs/certbot-new.py b/src/common/core/letsencrypt/jobs/certbot-new.py index 72bbec2b..5ca293db 100755 --- a/src/common/core/letsencrypt/jobs/certbot-new.py +++ b/src/common/core/letsencrypt/jobs/certbot-new.py @@ -95,6 +95,23 @@ try: parents=True, exist_ok=True ) + # Get env vars + bw_integration = "Linux" + integration_path = Path(sep, "usr", "share", "bunkerweb", "INTEGRATION") + os_release_path = Path(sep, "etc", "os-release") + if getenv("KUBERNETES_MODE", "no") == "yes": + bw_integration = "Kubernetes" + elif getenv("SWARM_MODE", "no") == "yes": + bw_integration = "Swarm" + elif getenv("AUTOCONF_MODE", "no") == "yes": + bw_integration = "Autoconf" + elif integration_path.is_file(): + 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" + # Extract letsencrypt folder if it exists in db db = Database( logger, @@ -103,7 +120,7 @@ try: ) tgz = get_file_in_db("folder.tgz", db, job_name="certbot-renew") - if tgz: + if tgz and bw_integration in ("Docker", "Swarm", "Kubernetes", "Autoconf"): # Delete folder if needed if letsencrypt_path.exists(): rmtree(str(letsencrypt_path), ignore_errors=True) diff --git a/src/common/core/letsencrypt/jobs/certbot-renew.py b/src/common/core/letsencrypt/jobs/certbot-renew.py index 970186a1..1a29c059 100755 --- a/src/common/core/letsencrypt/jobs/certbot-renew.py +++ b/src/common/core/letsencrypt/jobs/certbot-renew.py @@ -87,6 +87,23 @@ try: parents=True, exist_ok=True ) + # Get env vars + bw_integration = "Linux" + integration_path = Path(sep, "usr", "share", "bunkerweb", "INTEGRATION") + os_release_path = Path(sep, "etc", "os-release") + if getenv("KUBERNETES_MODE", "no") == "yes": + bw_integration = "Kubernetes" + elif getenv("SWARM_MODE", "no") == "yes": + bw_integration = "Swarm" + elif getenv("AUTOCONF_MODE", "no") == "yes": + bw_integration = "Autoconf" + elif integration_path.is_file(): + 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" + # Extract letsencrypt folder if it exists in db db = Database( logger, @@ -95,7 +112,7 @@ try: ) tgz = get_file_in_db("folder.tgz", db) - if tgz: + if tgz and bw_integration in ("Docker", "Swarm", "Kubernetes", "Autoconf"): # Delete folder if needed if letsencrypt_path.exists(): rmtree(str(letsencrypt_path), ignore_errors=True) diff --git a/src/linux/scripts/beforeInstall.sh b/src/linux/scripts/beforeInstall.sh index 9cf31fef..30647dfa 100644 --- a/src/linux/scripts/beforeInstall.sh +++ b/src/linux/scripts/beforeInstall.sh @@ -22,7 +22,7 @@ if [ -f /etc/os-release ]; then if [[ "$OS" == "Ubuntu" || "$OS" == "Debian" ]]; then # Get the version of the package VERSION=$(dpkg-query -W -f='${Version}' bunkerweb) - if dpkg --compare-versions "$VERSION" lt "1.5.0" && [ -f /var/tmp/variables.env ] && [ -f /var/tmp/ui.env ]; then + if dpkg --compare-versions "$VERSION" lt "1.5.1" && [ -f /var/tmp/variables.env ] && [ -f /var/tmp/ui.env ]; then echo "ℹ️ Copy /var/tmp/variables.env to /etc/bunkerweb/variables.env" do_and_check_cmd cp -f /var/tmp/variables.env /etc/bunkerweb/variables.env echo "ℹ️ Copy /var/tmp/ui.env to /etc/bunkerweb/ui.env" @@ -31,7 +31,7 @@ if [ -f /etc/os-release ]; then elif [[ "$OS" == "CentOS Linux" || "$OS" == "Fedora" ]]; then # Get the version of the package VERSION=$(rpm -q --queryformat '%{VERSION}' bunkerweb) - if [ "$(printf '%s\n' "$VERSION" "$(echo '1.5.0' | tr -d ' ')" | sort -V | head -n 1)" = "$VERSION" ] && [ -f /var/tmp/variables.env ] && [ -f /var/tmp/ui.env ]; then + if [ "$(printf '%s\n' "$VERSION" "$(echo '1.5.1' | tr -d ' ')" | sort -V | head -n 1)" = "$VERSION" ] && [ -f /var/tmp/variables.env ] && [ -f /var/tmp/ui.env ]; then echo "ℹ️ Copy /var/tmp/variables.env to /etc/bunkerweb/variables.env" do_and_check_cmd cp -f /var/tmp/variables.env /etc/bunkerweb/variables.env echo "ℹ️ Copy /var/tmp/ui.env to /etc/bunkerweb/ui.env" @@ -41,4 +41,4 @@ if [ -f /etc/os-release ]; then else echo "❌ Error: /etc/os-release not found" exit 1 -fi \ No newline at end of file +fi diff --git a/src/linux/scripts/start.sh b/src/linux/scripts/start.sh index d4f732fd..b4670770 100644 --- a/src/linux/scripts/start.sh +++ b/src/linux/scripts/start.sh @@ -193,4 +193,4 @@ case $1 in echo "Invalid option!" echo "List of options availables:" display_help -esac \ No newline at end of file +esac diff --git a/tests/LinuxTest.py b/tests/LinuxTest.py index 36699823..da28f8af 100644 --- a/tests/LinuxTest.py +++ b/tests/LinuxTest.py @@ -112,7 +112,7 @@ class LinuxTest(Test): setup = f"{test}/setup-linux.sh" if isfile(setup): proc = self.docker_exec( - self.__distro, f"cd /opt/{self._name} && ./setup-linux.sh" + self.__distro, f"cd /opt/{self._name} && ./setup-linux.sh && chmod -R nginx:nginx /etc/bunkerweb/configs" ) if proc.returncode != 0: raise Exception("docker exec setup failed (test)")