From 5fbb0f58e6ea92d1b2a352312c998ee434334dbc Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Fri, 27 Sep 2019 14:15:00 +0200 Subject: [PATCH] Add support for custom nginx --- CHANGELOG.md | 1 + wo/cli/plugins/site_functions.py | 12 ++++++++++++ wo/cli/plugins/stack.py | 6 +++--- wo/cli/plugins/stack_upgrade.py | 6 +++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a578966..18bca5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - [STACK] Nginx server_names_hash_bucket_size automated fix - [STACK] Nginx configuration rollback in case of failure after `wo stack upgrade --nginx - [STACK] Nginx ultimate bad bots blocker with `wo stack install --ngxblocker` +- [STACK] Added support for custom Nginx compiled from source ### v3.9.9.1 - 2019-09-26 diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index cd4c19e..f4d11c2 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -847,6 +847,8 @@ def site_package_check(self, stype): apt = ["nginx"] + WOVariables.wo_nginx # apt_packages = apt_packages + WOVariables.wo_nginx post_pref(self, apt, packages) + elif os.file.isfile('/usr/sbin/nginx'): + post_pref(self, WOVariables.wo_nginx, []) else: apt_packages = apt_packages + WOVariables.wo_nginx else: @@ -920,6 +922,16 @@ def site_package_check(self, stype): else: apt_packages = apt_packages + WOVariables.wo_php73 + if self.app.pargs.ngxblocker: + if not os.path.isdir('/etc/nginx/bots.d'): + Log.debug(self, "Setting packages variable for ngxblocker") + packages = packages + \ + [["https://raw.githubusercontent.com/" + "mitchellkrogza/nginx-ultimate-bad-bot-blocker" + "/master/install-ngxblocker", + "/usr/local/sbin/install-ngxblocker", + "ngxblocker"]] + return(stack.install(apt_packages=apt_packages, packages=packages, disp_msg=False)) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index d11191e..b690777 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -159,11 +159,11 @@ class WOStackController(CementBaseController): # Nginx if pargs.nginx: Log.debug(self, "Setting apt_packages variable for Nginx") - if not (WOAptGet.is_installed(self, 'nginx-custom')): if not (WOAptGet.is_installed(self, 'nginx-plus') or WOAptGet.is_installed(self, 'nginx')): - apt_packages = apt_packages + WOVariables.wo_nginx + if not os.path.isfile('/usr/sbin/nginx'): + apt_packages = apt_packages + WOVariables.wo_nginx else: if WOAptGet.is_installed(self, 'nginx-plus'): Log.info(self, "NGINX PLUS Detected ...") @@ -177,7 +177,7 @@ class WOStackController(CementBaseController): apt = ["nginx"] + WOVariables.wo_nginx self.post_pref(apt, empty_packages) else: - Log.debug(self, "Nginx Stable already installed") + Log.debug(self, "Nginx already installed") # Redis if pargs.redis: diff --git a/wo/cli/plugins/stack_upgrade.py b/wo/cli/plugins/stack_upgrade.py index fe4eeca..b8f2a61 100644 --- a/wo/cli/plugins/stack_upgrade.py +++ b/wo/cli/plugins/stack_upgrade.py @@ -94,7 +94,11 @@ class WOStackUpgradeController(CementBaseController): if WOAptGet.is_installed(self, 'nginx-custom'): apt_packages = apt_packages + WOVariables.wo_nginx else: - Log.info(self, "Nginx Stable is not already installed") + if os.path.isfile(self, '/usr/sbin/nginx'): + Log.info(self, "Updating Nginx templates") + post_pref(self, WOVariables.wo_nginx, []) + else: + Log.info(self, "Nginx Stable is not already installed") if pargs.php: if WOAptGet.is_installed(self, 'php7.2-fpm'):