diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index e8c84da..51071b3 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -16,6 +16,8 @@ from wo.core.mysql import WOMysql from wo.core.services import WOService from wo.core.shellexec import WOShellExec from wo.core.variables import WOVar +from wo.core.nginx import check_config +from wo.core.git import WOGit def wo_stack_hook(app): @@ -90,6 +92,9 @@ class WOStackController(CementBaseController): (['--nanorc'], dict(help='Install nanorc syntax highlighting', action='store_true')), + (['--brotli'], + dict(help='Enable/Disable Brotli compression for Nginx', + action='store_true')), (['--force'], dict(help='Force install/remove/purge without prompt', action='store_true')), @@ -278,6 +283,26 @@ class WOStackController(CementBaseController): Log.debug(self, "ProFTPd already installed") Log.info(self, "ProFTPd already installed") + # brotli + if pargs.brotli: + Log.wait(self, "Enabling Brotli") + if os.path.exists('/etc/nginx/conf.d/brotli.conf.disabled'): + WOFileUtils.mvfile(self, '/etc/nginx/conf.d/brotli.conf.disabled', + '/etc/nginx/conf.d/brotli.conf') + else: + Log.failed(self, "Enabling Brotli") + Log.error(self, "Brotli is already enabled") + if os.path.exists('/etc/nginx/conf.d/gzip.conf'): + WOFileUtils.mvfile(self, '/etc/nginx/conf.d/gzip.conf', + '/etc/nginx/conf.d/gzip.conf.disabled') + if check_config(self): + Log.valide(self, "Enabling Brotli") + WOGit.add(self, "/etc/nginx") + WOService.reload_service(self, "nginx") + else: + Log.failed(self, "Enabling Brotli") + WOGit.rollback(self, '/etc/nginx') + # PHPMYADMIN if pargs.phpmyadmin: pargs.composer = True @@ -656,6 +681,26 @@ class WOStackController(CementBaseController): Log.debug(self, "Remove apt_packages variable for ProFTPd") apt_packages = apt_packages + ["proftpd-basic"] + # brotli + if pargs.brotli: + Log.wait(self, "Disabling Brotli") + if os.path.exists('/etc/nginx/conf.d/brotli.conf'): + WOFileUtils.mvfile(self, '/etc/nginx/conf.d/brotli.conf', + '/etc/nginx/conf.d/brotli.conf.disabled') + else: + Log.failed(self, "Disabling Brotli") + Log.error(self, "Brotli is already disabled") + if os.path.exists('/etc/nginx/conf.d/gzip.conf.disabled'): + WOFileUtils.mvfile(self, '/etc/nginx/conf.d/gzip.conf.disabled', + '/etc/nginx/conf.d/gzip.conf') + if check_config(self): + Log.valide(self, "Disabling Brotli") + WOGit.add(self, "/etc/nginx") + WOService.reload_service(self, "nginx") + else: + Log.failed(self, "Disabling Brotli") + WOGit.rollback(self, '/etc/nginx') + # UFW if pargs.ufw: if WOAptGet.is_installed(self, 'ufw'): diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index b75eb3f..1164aca 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -417,7 +417,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): "Name: WordOps"] + ["HTTP Auth Password : {0}" .format(passwd)]) - self.msg = (self.msg + [f'WordOps backend is available on https://{server_ip}:22222]) ' + self.msg = (self.msg + [f'WordOps backend is available on https://{server_ip}:22222 ' f'or https://{WOVar.wo_fqdn}:22222']) data = dict(release=WOVar.wo_version)