Merge pull request #657 from WordOps/updating-configuration

Add stack --brotli to enable/disable brotli compression in Nginx
This commit is contained in:
VirtuBox
2024-06-01 23:53:09 +02:00
committed by GitHub
3 changed files with 50 additions and 5 deletions

View File

@@ -9,7 +9,7 @@
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# wget -qO wo wops.cc && sudo -E bash wo # wget -qO wo wops.cc && sudo -E bash wo
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Version 3.21.0 - 2024-05-03 # Version 3.21.0 - 2024-06-01
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# CONTENTS # CONTENTS
@@ -213,7 +213,6 @@ wo_install_dep() {
build-essential curl gzip python3-pip python3-apt python3-venv gcc python3-dev sqlite3 git tar software-properties-common pigz \ build-essential curl gzip python3-pip python3-apt python3-venv gcc python3-dev sqlite3 git tar software-properties-common pigz \
gnupg2 cron ccze rsync apt-transport-https tree haveged ufw unattended-upgrades tzdata ntp zstd idn \ gnupg2 cron ccze rsync apt-transport-https tree haveged ufw unattended-upgrades tzdata ntp zstd idn \
python3-distutils-extra libapt-pkg-dev bash-completion >/dev/null 2>&1 python3-distutils-extra libapt-pkg-dev bash-completion >/dev/null 2>&1
curl -fsSL https://build.opensuse.org/projects/home:virtubox/public_key | gpg --dearmor -o /usr/share/keyrings/wordops-archive-keyring.gpg
else else
# install dependencies # install dependencies
apt-get --option=Dpkg::options::=--force-confmiss --option=Dpkg::options::=--force-confold --assume-yes install \ apt-get --option=Dpkg::options::=--force-confmiss --option=Dpkg::options::=--force-confold --assume-yes install \
@@ -223,8 +222,7 @@ wo_install_dep() {
# add php repository gpg key # add php repository gpg key
curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
dpkg -i /tmp/debsuryorg-archive-keyring.deb && rm -f /tmp/debsuryorg-archive-keyring.deb dpkg -i /tmp/debsuryorg-archive-keyring.deb && rm -f /tmp/debsuryorg-archive-keyring.deb
# add nginx repository gpg key sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
curl -fsSL https://build.opensuse.org/projects/home:virtubox/public_key | gpg --dearmor -o /usr/share/keyrings/wordops-archive-keyring.gpg
fi fi
locale-gen en locale-gen en
# enable unattended upgades # enable unattended upgades

View File

@@ -16,6 +16,8 @@ from wo.core.mysql import WOMysql
from wo.core.services import WOService from wo.core.services import WOService
from wo.core.shellexec import WOShellExec from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVar from wo.core.variables import WOVar
from wo.core.nginx import check_config
from wo.core.git import WOGit
def wo_stack_hook(app): def wo_stack_hook(app):
@@ -90,6 +92,9 @@ class WOStackController(CementBaseController):
(['--nanorc'], (['--nanorc'],
dict(help='Install nanorc syntax highlighting', dict(help='Install nanorc syntax highlighting',
action='store_true')), action='store_true')),
(['--brotli'],
dict(help='Enable/Disable Brotli compression for Nginx',
action='store_true')),
(['--force'], (['--force'],
dict(help='Force install/remove/purge without prompt', dict(help='Force install/remove/purge without prompt',
action='store_true')), action='store_true')),
@@ -278,6 +283,27 @@ class WOStackController(CementBaseController):
Log.debug(self, "ProFTPd already installed") Log.debug(self, "ProFTPd already installed")
Log.info(self, "ProFTPd already installed") Log.info(self, "ProFTPd already installed")
# brotli
if pargs.brotli:
Log.wait(self, "Enabling Brotli")
WOGit.add(self, ["/etc/nginx"], msg="Commiting pending changes")
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"], msg="Enabling Brotli")
WOService.reload_service(self, "nginx")
else:
Log.failed(self, "Enabling Brotli")
WOGit.rollback(self, ["/etc/nginx"])
# PHPMYADMIN # PHPMYADMIN
if pargs.phpmyadmin: if pargs.phpmyadmin:
pargs.composer = True pargs.composer = True
@@ -656,6 +682,27 @@ class WOStackController(CementBaseController):
Log.debug(self, "Remove apt_packages variable for ProFTPd") Log.debug(self, "Remove apt_packages variable for ProFTPd")
apt_packages = apt_packages + ["proftpd-basic"] apt_packages = apt_packages + ["proftpd-basic"]
# brotli
if pargs.brotli:
Log.wait(self, "Disabling Brotli")
WOGit.add(self, ["/etc/nginx"], msg="Commiting pending changes")
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"], msg="Disabling Brotli")
WOService.reload_service(self, "nginx")
else:
Log.failed(self, "Disabling Brotli")
WOGit.rollback(self, ["/etc/nginx"])
# UFW # UFW
if pargs.ufw: if pargs.ufw:
if WOAptGet.is_installed(self, 'ufw'): if WOAptGet.is_installed(self, 'ufw'):

View File

@@ -417,7 +417,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"Name: WordOps"] + "Name: WordOps"] +
["HTTP Auth Password : {0}" ["HTTP Auth Password : {0}"
.format(passwd)]) .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']) f'or https://{WOVar.wo_fqdn}:22222'])
data = dict(release=WOVar.wo_version) data = dict(release=WOVar.wo_version)