Merge pull request #118 from WordOps/updating-configuration

Updating configuration
This commit is contained in:
VirtuBox
2019-08-17 02:30:18 +02:00
committed by GitHub
18 changed files with 1024 additions and 920 deletions

View File

@@ -51,14 +51,15 @@ script:
- sudo cat /etc/nginx/nginx.conf - sudo cat /etc/nginx/nginx.conf
- sudo tree -L 2 /etc/nginx - sudo tree -L 2 /etc/nginx
- sudo cat /etc/mysql/my.cnf - sudo cat /etc/mysql/my.cnf
- sudo wo stack upgrade --nginx --no-prompt - sudo wo stack upgrade --nginx --force
- sudo wo stack upgrade --php --no-prompt - sudo wo stack upgrade --php --force
- sudo wo stack upgrade --netdata --no-prompt - sudo wo stack upgrade --netdata --force
- sudo wo stack upgrade --phpmyadmin --no-prompt - sudo wo stack upgrade --phpmyadmin --force
- sudo wo stack upgrade --composer --no-prompt - sudo wo stack upgrade --composer --force
- sudo wo stack upgrade --dashboard --force
- sudo wo update --travis - sudo wo update --travis
- sudo wo stack status - sudo wo stack status
- sudo tar -I pigz -cf wordops.tar.gz /var/log/wo - sudo tar -I pigz -cf wordops.tar.gz /var/log/wo
- curl --progress-bar --upload-file wordops.tar.gz https://transfer.vtbox.net/$(basename "wordops.tar.gz") && echo "" | sudo tee -a $HOME/.transfer.log && echo "" - curl --progress-bar --upload-file wordops.tar.gz https://transfer.vtbox.net/$(basename "wordops.tar.gz") && echo "" | sudo tee -a $HOME/.transfer.log && echo ""
- echo "yes" | sudo wo stack purge --all - echo "yes" | sudo wo stack purge --all --force
- sudo bash install --purge - sudo bash install --purge

View File

@@ -8,6 +8,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### v3.9.x - [Unreleased] ### v3.9.x - [Unreleased]
#### Changed
- Extra Nginx directives moved from nginx.conf to conf.d/tweaks.conf
#### Fixed
- MySQLTuner installation
- `wo stack remove/purge --all`
- variable substitution in install script
### v3.9.8 - 2019-08-16 ### v3.9.8 - 2019-08-16
#### Added #### Added

View File

@@ -7,7 +7,7 @@
# Copyright (c) 2019 - WordOps # Copyright (c) 2019 - WordOps
# This script is licensed under M.I.T # This script is licensed under M.I.T
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Version 3.9.8 - 2019-08-16 # Version 3.9.8 - 2019-08-17
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
readonly wo_version_old="2.2.3" readonly wo_version_old="2.2.3"
readonly wo_version_new="3.9.8" readonly wo_version_new="3.9.8"
@@ -186,6 +186,7 @@ wo_install_dep() {
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 \
build-essential curl gzip python3 python3-apt python3-setuptools python3-requests python3-dev sqlite3 git tar software-properties-common pigz \ build-essential curl gzip python3 python3-apt python3-setuptools python3-requests python3-dev sqlite3 git tar software-properties-common pigz \
gnupg2 cron ccze rsync tree haveged ufw unattended-upgrades tzdata ntp > /dev/null 2>&1 gnupg2 cron ccze rsync tree haveged ufw unattended-upgrades tzdata ntp > /dev/null 2>&1
add-apt-repository ppa:wordops/nginx-wo -yu
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 \

View File

@@ -9,6 +9,12 @@ class CliTestCaseStack(test.WOTestCase):
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_install(self):
self.app = get_test_app(argv=['stack', 'install'])
self.app.setup()
self.app.run()
self.app.close()
def test_wo_cli_stack_install_web(self): def test_wo_cli_stack_install_web(self):
self.app = get_test_app(argv=['stack', 'install', '--web']) self.app = get_test_app(argv=['stack', 'install', '--web'])
self.app.setup() self.app.setup()

View File

@@ -10,19 +10,19 @@ class CliTestCaseSecure(test.WOTestCase):
self.app.close() self.app.close()
def test_wo_cli_secure_auth(self): def test_wo_cli_secure_auth(self):
self.app = get_test_app(argv=['secure', '--auth']) self.app = get_test_app(argv=['secure', '--auth', 'abc', 'superpass'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_secure_port(self): def test_wo_cli_secure_port(self):
self.app = get_test_app(argv=['secure', '--port']) self.app = get_test_app(argv=['secure', '--port', '22222'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_secure_ip(self): def test_wo_cli_secure_ip(self):
self.app = get_test_app(argv=['secure', '--ip']) self.app = get_test_app(argv=['secure', '--ip', '172.16.0.1'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()

View File

@@ -10,55 +10,64 @@ class CliTestCaseStack(test.WOTestCase):
self.app.close() self.app.close()
def test_wo_cli_stack_purge_web(self): def test_wo_cli_stack_purge_web(self):
self.app = get_test_app(argv=['stack', 'purge', '--web']) self.app = get_test_app(argv=['stack', 'purge',
'--web', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_purge_admin(self): def test_wo_cli_stack_purge_admin(self):
self.app = get_test_app(argv=['stack', 'purge', '--admin']) self.app = get_test_app(argv=['stack', 'purge',
'--admin', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_purge_nginx(self): def test_wo_cli_stack_purge_nginx(self):
self.app = get_test_app(argv=['stack', 'purge', '--nginx']) self.app = get_test_app(argv=['stack', 'purge',
'--nginx', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_purge_php(self): def test_wo_cli_stack_purge_php(self):
self.app = get_test_app(argv=['stack', 'purge', '--php']) self.app = get_test_app(argv=['stack', 'purge',
'--php', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_purge_mysql(self): def test_wo_cli_stack_purge_mysql(self):
self.app = get_test_app(argv=['stack', 'purge', '--mysql']) self.app = get_test_app(argv=['stack', 'purge',
'--mysql', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_purge_wpcli(self): def test_wo_cli_stack_purge_wpcli(self):
self.app = get_test_app(argv=['stack', 'purge', '--wpcli']) self.app = get_test_app(argv=['stack', 'purge',
'--wpcli', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_purge_phpmyadmin(self): def test_wo_cli_stack_purge_phpmyadmin(self):
self.app = get_test_app(argv=['stack', 'purge', '--phpmyadmin']) self.app = get_test_app(
argv=['stack', 'purge', '--phpmyadmin', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_purge_adminer(self): def test_wo_cli_stack_purge_adminer(self):
self.app = get_test_app(argv=['stack', 'purge', '--adminer']) self.app = get_test_app(
argv=['stack', 'purge', '--adminer', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_purge_utils(self): def test_wo_cli_stack_purge_utils(self):
self.app = get_test_app(argv=['stack', 'purge', '--utils']) self.app = get_test_app(argv=['stack', 'purge',
'--utils', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()

View File

@@ -10,55 +10,57 @@ class CliTestCaseStack(test.WOTestCase):
self.app.close() self.app.close()
def test_wo_cli_stack_remove_web(self): def test_wo_cli_stack_remove_web(self):
self.app = get_test_app(argv=['stack', 'remove', '--web']) self.app = get_test_app(argv=['stack', 'remove', '--web', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_install_admin(self): def test_wo_cli_stack_install_admin(self):
self.app = get_test_app(argv=['stack', 'remove', '--admin']) self.app = get_test_app(argv=['stack', 'remove', '--admin', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_install_nginx(self): def test_wo_cli_stack_install_nginx(self):
self.app = get_test_app(argv=['stack', 'remove', '--nginx']) self.app = get_test_app(argv=['stack', 'remove', '--nginx', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_install_php(self): def test_wo_cli_stack_install_php(self):
self.app = get_test_app(argv=['stack', 'remove', '--php']) self.app = get_test_app(argv=['stack', 'remove', '--php', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_install_mysql(self): def test_wo_cli_stack_install_mysql(self):
self.app = get_test_app(argv=['stack', 'remove', '--mysql']) self.app = get_test_app(argv=['stack', 'remove', '--mysql', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_install_wpcli(self): def test_wo_cli_stack_install_wpcli(self):
self.app = get_test_app(argv=['stack', 'remove', '--wpcli']) self.app = get_test_app(argv=['stack', 'remove', '--wpcli', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_install_phpmyadmin(self): def test_wo_cli_stack_install_phpmyadmin(self):
self.app = get_test_app(argv=['stack', 'remove', '--phpmyadmin']) self.app = get_test_app(argv=['stack', 'remove',
'--phpmyadmin', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_install_adminer(self): def test_wo_cli_stack_install_adminer(self):
self.app = get_test_app(argv=['stack', 'remove', '--adminer']) self.app = get_test_app(
argv=['stack', 'remove', '--adminer', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_wo_cli_stack_install_utils(self): def test_wo_cli_stack_install_utils(self):
self.app = get_test_app(argv=['stack', 'remove', '--utils']) self.app = get_test_app(argv=['stack', 'remove', '--utils', '--force'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()

View File

@@ -840,10 +840,6 @@ def site_package_check(self, stype):
Log.debug(self, "Setting apt_packages variable for MySQL") Log.debug(self, "Setting apt_packages variable for MySQL")
if not WOShellExec.cmd_exec(self, "/usr/bin/mysqladmin ping"): if not WOShellExec.cmd_exec(self, "/usr/bin/mysqladmin ping"):
apt_packages = apt_packages + WOVariables.wo_mysql apt_packages = apt_packages + WOVariables.wo_mysql
packages = packages + [["https://raw.githubusercontent.com/"
"major/MySQLTuner-perl/master/"
"mysqltuner.pl", "/usr/bin/mysqltuner",
"MySQLTuner"]]
if stype in ['wp', 'wpsubdir', 'wpsubdomain']: if stype in ['wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting packages variable for WP-CLI") Log.debug(self, "Setting packages variable for WP-CLI")

View File

@@ -21,7 +21,6 @@ from wo.cli.plugins.stack_migrate import WOStackMigrateController
from wo.cli.plugins.stack_services import WOStackStatusController from wo.cli.plugins.stack_services import WOStackStatusController
from wo.cli.plugins.stack_upgrade import WOStackUpgradeController from wo.cli.plugins.stack_upgrade import WOStackUpgradeController
from wo.cli.plugins.stack_pref import pre_pref, post_pref from wo.cli.plugins.stack_pref import pre_pref, post_pref
from wo.core.addswap import WOSwap
from wo.core.apt_repo import WORepo from wo.core.apt_repo import WORepo
from wo.core.aptget import WOAptGet from wo.core.aptget import WOAptGet
from wo.core.cron import WOCron from wo.core.cron import WOCron
@@ -66,6 +65,8 @@ class WOStackController(CementBaseController):
(['--mysqlclient'], (['--mysqlclient'],
dict(help='Install MySQL client for remote MySQL server', dict(help='Install MySQL client for remote MySQL server',
action='store_true')), action='store_true')),
(['--mysqltuner'],
dict(help='Install MySQLTuner stack', action='store_true')),
(['--wpcli'], (['--wpcli'],
dict(help='Install WPCLI stack', action='store_true')), dict(help='Install WPCLI stack', action='store_true')),
(['--phpmyadmin'], (['--phpmyadmin'],
@@ -114,7 +115,7 @@ class WOStackController(CementBaseController):
(not pargs.phpmyadmin) and (not pargs.composer) and (not pargs.phpmyadmin) and (not pargs.composer) and
(not pargs.netdata) and (not pargs.dashboard) and (not pargs.netdata) and (not pargs.dashboard) and
(not pargs.fail2ban) and (not pargs.security) (not pargs.fail2ban) and (not pargs.security)
and (not pargs.mysqlclient) and and (not pargs.mysqlclient) and (not pargs.mysqltuner) and
(not pargs.adminer) and (not pargs.utils) and (not pargs.adminer) and (not pargs.utils) and
(not pargs.redis) and (not pargs.proftpd) and (not pargs.redis) and (not pargs.proftpd) and
(not pargs.phpredisadmin) and (not pargs.phpredisadmin) and
@@ -147,6 +148,7 @@ class WOStackController(CementBaseController):
pargs.netdata = True pargs.netdata = True
pargs.dashboard = True pargs.dashboard = True
pargs.phpredisadmin = True pargs.phpredisadmin = True
pargs.mysqltuner = True
if pargs.security: if pargs.security:
pargs.fail2ban = True pargs.fail2ban = True
@@ -213,12 +215,6 @@ class WOStackController(CementBaseController):
Log.debug(self, "Setting apt_packages variable for MySQL") Log.debug(self, "Setting apt_packages variable for MySQL")
if not WOShellExec.cmd_exec(self, "mysqladmin ping"): if not WOShellExec.cmd_exec(self, "mysqladmin ping"):
apt_packages = apt_packages + WOVariables.wo_mysql apt_packages = apt_packages + WOVariables.wo_mysql
packages = packages + [["https://raw."
"githubusercontent.com/"
"major/MySQLTuner-perl"
"/master/mysqltuner.pl",
"/usr/bin/mysqltuner",
"MySQLTuner"]]
if pargs.mysqlclient: if pargs.mysqlclient:
Log.debug(self, "Setting apt_packages variable " Log.debug(self, "Setting apt_packages variable "
@@ -319,6 +315,15 @@ class WOStackController(CementBaseController):
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
"Adminer theme"]] "Adminer theme"]]
if pargs.mysqltuner:
Log.debug(self, "Setting packages variable for MySQLTuner ")
packages = packages + [["https://raw."
"githubusercontent.com/"
"major/MySQLTuner-perl"
"/master/mysqltuner.pl",
"/usr/bin/mysqltuner",
"MySQLTuner"]]
# Netdata # Netdata
if pargs.netdata: if pargs.netdata:
Log.debug(self, "Setting packages variable for Netdata") Log.debug(self, "Setting packages variable for Netdata")
@@ -437,7 +442,8 @@ class WOStackController(CementBaseController):
(not pargs.adminer) and (not pargs.utils) and (not pargs.adminer) and (not pargs.utils) and
(not pargs.composer) and (not pargs.netdata) and (not pargs.composer) and (not pargs.netdata) and
(not pargs.fail2ban) and (not pargs.proftpd) and (not pargs.fail2ban) and (not pargs.proftpd) and
(not pargs.security) and (not pargs.security) and (not pargs.mysqltuner) and
(not pargs.mysqlclient) and
(not pargs.all) and (not pargs.redis) and (not pargs.all) and (not pargs.redis) and
(not pargs.phpredisadmin)): (not pargs.phpredisadmin)):
pargs.web = True pargs.web = True
@@ -448,6 +454,10 @@ class WOStackController(CementBaseController):
pargs.web = True pargs.web = True
pargs.admin = True pargs.admin = True
pargs.php73 = True pargs.php73 = True
pargs.fail2ban = True
pargs.proftpd = True
pargs.utils = True
pargs.redis = True
if pargs.web: if pargs.web:
pargs.nginx = True pargs.nginx = True
@@ -459,10 +469,7 @@ class WOStackController(CementBaseController):
pargs.composer = True pargs.composer = True
pargs.utils = True pargs.utils = True
pargs.netdata = True pargs.netdata = True
if os.path.isdir('{0}22222/htdocs' pargs.mysqltuner = True
.format(WOVariables.wo_webroot)):
packages = packages + ['{0}22222/htdocs/*'
.format(WOVariables.wo_webroot)]
if pargs.security: if pargs.security:
pargs.fail2ban = True pargs.fail2ban = True
@@ -472,9 +479,7 @@ class WOStackController(CementBaseController):
if WOAptGet.is_installed(self, 'nginx-custom'): if WOAptGet.is_installed(self, 'nginx-custom'):
Log.debug(self, "Removing apt_packages variable of Nginx") Log.debug(self, "Removing apt_packages variable of Nginx")
apt_packages = apt_packages + WOVariables.wo_nginx apt_packages = apt_packages + WOVariables.wo_nginx
else:
Log.error(self, "Cannot Remove! Nginx Stable "
"version not found.")
# PHP 7.2 # PHP 7.2
if pargs.php: if pargs.php:
Log.debug(self, "Removing apt_packages variable of PHP") Log.debug(self, "Removing apt_packages variable of PHP")
@@ -484,8 +489,6 @@ class WOStackController(CementBaseController):
WOVariables.wo_php_extra WOVariables.wo_php_extra
else: else:
apt_packages = apt_packages + WOVariables.wo_php apt_packages = apt_packages + WOVariables.wo_php
else:
Log.error(self, "PHP 7.2 not found")
# PHP7.3 # PHP7.3
if pargs.php73: if pargs.php73:
@@ -496,8 +499,6 @@ class WOStackController(CementBaseController):
WOVariables.wo_php_extra WOVariables.wo_php_extra
else: else:
apt_packages = apt_packages + WOVariables.wo_php73 apt_packages = apt_packages + WOVariables.wo_php73
else:
Log.error(self, "PHP 7.3 not found")
# REDIS # REDIS
if pargs.redis: if pargs.redis:
@@ -508,43 +509,39 @@ class WOStackController(CementBaseController):
if pargs.mysql: if pargs.mysql:
Log.debug(self, "Removing apt_packages variable of MySQL") Log.debug(self, "Removing apt_packages variable of MySQL")
apt_packages = apt_packages + WOVariables.wo_mysql apt_packages = apt_packages + WOVariables.wo_mysql
packages = packages + ['/usr/bin/mysqltuner']
# fail2ban # fail2ban
if pargs.fail2ban: if pargs.fail2ban:
if WOAptGet.is_installed(self, 'fail2ban'): if WOAptGet.is_installed(self, 'fail2ban'):
Log.debug(self, "Remove apt_packages variable of Fail2ban") Log.debug(self, "Remove apt_packages variable of Fail2ban")
apt_packages = apt_packages + WOVariables.wo_fail2ban apt_packages = apt_packages + WOVariables.wo_fail2ban
else:
Log.error(self, "Fail2ban not found")
# proftpd # proftpd
if pargs.proftpd: if pargs.proftpd:
if WOAptGet.is_installed(self, 'proftpd-basic'): if WOAptGet.is_installed(self, 'proftpd-basic'):
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"]
else:
Log.error(self, "ProFTPd not found")
# WPCLI # WPCLI
if pargs.wpcli: if pargs.wpcli:
Log.debug(self, "Removing package variable of WPCLI ") Log.debug(self, "Removing package variable of WPCLI ")
if os.path.isfile('/usr/local/bin/wp'): if os.path.isfile('/usr/local/bin/wp'):
packages = packages + ['/usr/local/bin/wp'] packages = packages + ['/usr/local/bin/wp']
else:
Log.warn(self, "WP-CLI is not installed with WordOps")
# PHPMYADMIN # PHPMYADMIN
if pargs.phpmyadmin: if pargs.phpmyadmin:
Log.debug(self, "Removing package variable of phpMyAdmin ") Log.debug(self, "Removing package of phpMyAdmin ")
packages = packages + ['{0}22222/htdocs/db/pma' packages = packages + ['{0}22222/htdocs/db/pma'
.format(WOVariables.wo_webroot)] .format(WOVariables.wo_webroot)]
# Composer # Composer
if pargs.composer: if pargs.composer:
Log.debug(self, "Removing package variable of Composer ") Log.debug(self, "Removing package of Composer ")
if os.path.isfile('/usr/local/bin/composer'): if os.path.isfile('/usr/local/bin/composer'):
packages = packages + ['/usr/local/bin/composer'] packages = packages + ['/usr/local/bin/composer']
else:
Log.warn(self, "Composer is not installed with WordOps") if pargs.mysqltuner:
Log.debug(self, "Removing packages for MySQLTuner ")
packages = packages + ['/usr/bin/mysqltuner']
# PHPREDISADMIN # PHPREDISADMIN
if pargs.phpredisadmin: if pargs.phpredisadmin:
@@ -593,31 +590,30 @@ class WOStackController(CementBaseController):
'Any answer other than ' 'Any answer other than '
'"yes" will be stop this' '"yes" will be stop this'
' operation : ') ' operation : ')
if (wo_prompt != 'YES' or wo_prompt != 'yes'):
Log.error(self, "Not removing packages")
if (wo_prompt == 'YES' or wo_prompt == 'yes' if (set(["nginx-custom"]).issubset(set(apt_packages))):
or pargs.force): WOService.stop_service(self, 'nginx')
if (set(["nginx-custom"]).issubset(set(apt_packages))): # Netdata uninstaller
WOService.stop_service(self, 'nginx') if (set(['/var/lib/wo/tmp/'
'kickstart.sh']).issubset(set(packages))):
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/"
"libexec/netdata-"
"uninstaller.sh -y -f")
# Netdata uninstaller if (packages):
if (set(['/var/lib/wo/tmp/' WOFileUtils.remove(self, packages)
'kickstart.sh']).issubset(set(packages))): WOAptGet.auto_remove(self)
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/"
"libexec/netdata-"
"uninstaller.sh -y -f")
if (packages): if (apt_packages):
WOFileUtils.remove(self, packages) Log.debug(self, "Removing apt_packages")
WOAptGet.auto_remove(self) Log.info(self, "Removing packages, please wait...")
WOAptGet.remove(self, apt_packages)
WOAptGet.auto_remove(self)
if (apt_packages): Log.info(self, "Successfully removed packages")
Log.debug(self, "Removing apt_packages")
Log.info(self, "Removing packages, please wait...")
WOAptGet.remove(self, apt_packages)
WOAptGet.auto_remove(self)
Log.info(self, "Successfully removed packages")
@expose(help="Purge packages") @expose(help="Purge packages")
def purge(self): def purge(self):
@@ -633,7 +629,8 @@ class WOStackController(CementBaseController):
(not pargs.adminer) and (not pargs.utils) and (not pargs.adminer) and (not pargs.utils) and
(not pargs.composer) and (not pargs.netdata) and (not pargs.composer) and (not pargs.netdata) and
(not pargs.fail2ban) and (not pargs.proftpd) and (not pargs.fail2ban) and (not pargs.proftpd) and
(not pargs.security) and (not pargs.security) and (not pargs.mysqltuner) and
(not pargs.mysqlclient) and
(not pargs.all) and (not pargs.redis) and (not pargs.all) and (not pargs.redis) and
(not pargs.phpredisadmin)): (not pargs.phpredisadmin)):
pargs.web = True pargs.web = True
@@ -644,6 +641,10 @@ class WOStackController(CementBaseController):
pargs.web = True pargs.web = True
pargs.admin = True pargs.admin = True
pargs.php73 = True pargs.php73 = True
pargs.fail2ban = True
pargs.proftpd = True
pargs.utils = True
pargs.redis = True
if pargs.web: if pargs.web:
pargs.nginx = True pargs.nginx = True
@@ -655,10 +656,7 @@ class WOStackController(CementBaseController):
pargs.utils = True pargs.utils = True
pargs.composer = True pargs.composer = True
pargs.netdata = True pargs.netdata = True
if os.path.isdir('{0}22222/htdocs' pargs.mysqltuner = True
.format(WOVariables.wo_webroot)):
packages = packages + ['{0}22222/htdocs/*'
.format(WOVariables.wo_webroot)]
if pargs.security: if pargs.security:
pargs.fail2ban = True pargs.fail2ban = True
@@ -667,9 +665,6 @@ class WOStackController(CementBaseController):
if WOAptGet.is_installed(self, 'nginx-custom'): if WOAptGet.is_installed(self, 'nginx-custom'):
Log.debug(self, "Purge apt_packages variable of Nginx") Log.debug(self, "Purge apt_packages variable of Nginx")
apt_packages = apt_packages + WOVariables.wo_nginx apt_packages = apt_packages + WOVariables.wo_nginx
else:
Log.error(self, "Cannot Purge! "
"Nginx Stable version not found.")
# PHP # PHP
if pargs.php: if pargs.php:
@@ -680,8 +675,6 @@ class WOStackController(CementBaseController):
WOVariables.wo_php_extra WOVariables.wo_php_extra
else: else:
apt_packages = apt_packages + WOVariables.wo_php apt_packages = apt_packages + WOVariables.wo_php
else:
Log.error(self, "Cannot Purge PHP 7.2. not found.")
# PHP 7.3 # PHP 7.3
if pargs.php73: if pargs.php73:
@@ -710,8 +703,6 @@ class WOStackController(CementBaseController):
Log.debug(self, "Purge package variable WPCLI") Log.debug(self, "Purge package variable WPCLI")
if os.path.isfile('/usr/local/bin/wp'): if os.path.isfile('/usr/local/bin/wp'):
packages = packages + ['/usr/local/bin/wp'] packages = packages + ['/usr/local/bin/wp']
else:
Log.warn(self, "WP-CLI is not installed with WordOps")
# PHPMYADMIN # PHPMYADMIN
if pargs.phpmyadmin: if pargs.phpmyadmin:
@@ -724,8 +715,10 @@ class WOStackController(CementBaseController):
Log.debug(self, "Removing package variable of Composer ") Log.debug(self, "Removing package variable of Composer ")
if os.path.isfile('/usr/local/bin/composer'): if os.path.isfile('/usr/local/bin/composer'):
packages = packages + ['/usr/local/bin/composer'] packages = packages + ['/usr/local/bin/composer']
else:
Log.warn(self, "Composer is not installed with WordOps") if pargs.mysqltuner:
Log.debug(self, "Removing packages for MySQLTuner ")
packages = packages + ['/usr/bin/mysqltuner']
# PHPREDISADMIN # PHPREDISADMIN
if pargs.phpredisadmin: if pargs.phpredisadmin:
@@ -768,38 +761,39 @@ class WOStackController(CementBaseController):
.format(WOVariables.wo_webroot)] .format(WOVariables.wo_webroot)]
if (packages) or (apt_packages): if (packages) or (apt_packages):
wo_prompt = input('Are you sure you to want to purge ' if not pargs.force:
'from server ' wo_prompt = input('Are you sure you to want to purge '
'along with their configuration' 'from server '
' packages,\nAny answer other than ' 'along with their configuration'
'"yes" will be stop this ' ' packages,\nAny answer other than '
'operation :') '"yes" will be stop this '
'operation :')
if (wo_prompt != 'YES' or wo_prompt != 'yes'):
Log.error(self, "Not purging packages")
if wo_prompt == 'YES' or wo_prompt == 'yes' or pargs.force: if (set(["nginx-custom"]).issubset(set(apt_packages))):
WOService.stop_service(self, 'nginx')
if (set(["nginx-custom"]).issubset(set(apt_packages))): # Netdata uninstaller
WOService.stop_service(self, 'nginx') if (set(['/var/lib/wo/tmp/'
'kickstart.sh']).issubset(set(packages))):
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/"
"libexec/netdata-"
"uninstaller.sh -y -f")
# Netdata uninstaller if (set(["fail2ban"]).issubset(set(apt_packages))):
if (set(['/var/lib/wo/tmp/' WOService.stop_service(self, 'fail2ban')
'kickstart.sh']).issubset(set(packages))):
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/"
"libexec/netdata-"
"uninstaller.sh -y -f")
if (set(["fail2ban"]).issubset(set(apt_packages))): if (apt_packages):
WOService.stop_service(self, 'fail2ban') Log.info(self, "Purging packages, please wait...")
WOAptGet.remove(self, apt_packages, purge=True)
WOAptGet.auto_remove(self)
if (apt_packages): if (packages):
Log.info(self, "Purging packages, please wait...") WOFileUtils.remove(self, packages)
WOAptGet.remove(self, apt_packages, purge=True) WOAptGet.auto_remove(self)
WOAptGet.auto_remove(self)
if (packages): Log.info(self, "Successfully purged packages")
WOFileUtils.remove(self, packages)
WOAptGet.auto_remove(self)
Log.info(self, "Successfully purged packages")
def load(app): def load(app):

View File

@@ -91,7 +91,7 @@ class WOStackMigrateController(CementBaseController):
if ((not self.app.pargs.mariadb)): if ((not self.app.pargs.mariadb)):
self.app.args.print_help() self.app.args.print_help()
if self.app.pargs.mariadb: if self.app.pargs.mariadb:
if WOVariables.wo_mysql_host is not "localhost": if WOVariables.wo_mysql_host != "localhost":
Log.error( Log.error(
self, "Remote MySQL server in use, skipping local install") self, "Remote MySQL server in use, skipping local install")

View File

@@ -160,7 +160,7 @@ def post_pref(self, apt_packages, packages):
(data), 'nginx-core.mustache', out=wo_nginx) (data), 'nginx-core.mustache', out=wo_nginx)
wo_nginx.close() wo_nginx.close()
if not os.path.isfile('/etc/nginx/conf.d/gzip.conf'): if not os.path.isfile('/etc/nginx/conf.d/gzip.conf.disabled'):
data = dict() data = dict()
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/gzip.conf') 'file /etc/nginx/conf.d/gzip.conf')
@@ -170,7 +170,7 @@ def post_pref(self, apt_packages, packages):
(data), 'gzip.mustache', out=wo_nginx) (data), 'gzip.mustache', out=wo_nginx)
wo_nginx.close() wo_nginx.close()
if not os.path.isfile('/etc/nginx/conf.d/brotli.conf.disabled'): if not os.path.isfile('/etc/nginx/conf.d/brotli.conf'):
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/brotli.conf.disabled') 'file /etc/nginx/conf.d/brotli.conf.disabled')
wo_nginx = open('/etc/nginx/conf.d/brotli.conf.disabled', wo_nginx = open('/etc/nginx/conf.d/brotli.conf.disabled',
@@ -179,6 +179,14 @@ def post_pref(self, apt_packages, packages):
(data), 'brotli.mustache', out=wo_nginx) (data), 'brotli.mustache', out=wo_nginx)
wo_nginx.close() wo_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/tweaks.conf')
wo_nginx = open('/etc/nginx/conf.d/tweaks.conf',
encoding='utf-8', mode='w')
self.app.render(
(data), 'tweaks.mustache', out=wo_nginx)
wo_nginx.close()
# Fix for white screen death with NGINX PLUS # Fix for white screen death with NGINX PLUS
if not WOFileUtils.grep(self, '/etc/nginx/fastcgi_params', if not WOFileUtils.grep(self, '/etc/nginx/fastcgi_params',
'SCRIPT_FILENAME'): 'SCRIPT_FILENAME'):
@@ -1070,7 +1078,6 @@ def post_pref(self, apt_packages, packages):
'/var/lib/mysql/ib_logfile1.bak') '/var/lib/mysql/ib_logfile1.bak')
WOService.start_service(self, 'mysql') WOService.start_service(self, 'mysql')
WOFileUtils.chmod(self, "/usr/bin/mysqltuner", 0o775)
WOCron.setcron_weekly(self, 'mysqlcheck -Aos --auto-repair ' WOCron.setcron_weekly(self, 'mysqlcheck -Aos --auto-repair '
'> /dev/null 2>&1', '> /dev/null 2>&1',
comment='MySQL optimization cronjob ' comment='MySQL optimization cronjob '
@@ -1324,6 +1331,11 @@ def post_pref(self, apt_packages, packages):
WOVariables.wo_php_user, WOVariables.wo_php_user,
recursive=True) recursive=True)
if any('/usr/bin/mysqltuner' == x[1]
for x in packages):
Log.debug(self, "CHMOD MySQLTuner in /usr/bin/mysqltuner")
WOFileUtils.chmod(self, "/usr/bin/mysqltuner", 0o775)
# netdata install # netdata install
if any('/var/lib/wo/tmp/kickstart.sh' == x[1] if any('/var/lib/wo/tmp/kickstart.sh' == x[1]
for x in packages): for x in packages):

View File

@@ -29,6 +29,8 @@ class WOStackStatusController(CementBaseController):
pargs.nginx = True pargs.nginx = True
pargs.php = True pargs.php = True
pargs.mysql = True pargs.mysql = True
pargs.fail2ban = True
pargs.netdata = True
if pargs.nginx: if pargs.nginx:
if (WOAptGet.is_installed(self, 'nginx-custom')): if (WOAptGet.is_installed(self, 'nginx-custom')):
@@ -198,6 +200,7 @@ class WOStackStatusController(CementBaseController):
pargs.nginx = True pargs.nginx = True
pargs.php = True pargs.php = True
pargs.mysql = True pargs.mysql = True
pargs.netdata = True
if pargs.nginx: if pargs.nginx:
if (WOAptGet.is_installed(self, 'nginx-custom')): if (WOAptGet.is_installed(self, 'nginx-custom')):
@@ -281,6 +284,8 @@ class WOStackStatusController(CementBaseController):
pargs.nginx = True pargs.nginx = True
pargs.php = True pargs.php = True
pargs.mysql = True pargs.mysql = True
pargs.fail2ban = True
pargs.netdata = True
if pargs.nginx: if pargs.nginx:
if (WOAptGet.is_installed(self, 'nginx-custom')): if (WOAptGet.is_installed(self, 'nginx-custom')):
@@ -363,6 +368,7 @@ class WOStackStatusController(CementBaseController):
pargs.nginx = True pargs.nginx = True
pargs.php = True pargs.php = True
pargs.mysql = True pargs.mysql = True
pargs.fail2ban = True
if pargs.nginx: if pargs.nginx:
if (WOAptGet.is_installed(self, 'nginx-custom') or if (WOAptGet.is_installed(self, 'nginx-custom') or

View File

@@ -42,6 +42,8 @@ class WOStackUpgradeController(CementBaseController):
dict(help='Upgrade Redis', action='store_true')), dict(help='Upgrade Redis', action='store_true')),
(['--netdata'], (['--netdata'],
dict(help='Upgrade Netdata', action='store_true')), dict(help='Upgrade Netdata', action='store_true')),
(['--dashboard'],
dict(help='Upgrade WordOps Dashboard', action='store_true')),
(['--composer'], (['--composer'],
dict(help='Upgrade Composer', action='store_true')), dict(help='Upgrade Composer', action='store_true')),
(['--phpmyadmin'], (['--phpmyadmin'],
@@ -67,7 +69,7 @@ class WOStackUpgradeController(CementBaseController):
(not pargs.mysql) and (not pargs.mysql) and
(not pargs.all) and (not pargs.wpcli) and (not pargs.all) and (not pargs.wpcli) and
(not pargs.netdata) and (not pargs.composer) and (not pargs.netdata) and (not pargs.composer) and
(not pargs.phpmyadmin) and (not pargs.phpmyadmin) and (not pargs.dashboard) and
(not pargs.redis)): (not pargs.redis)):
pargs.web = True pargs.web = True
@@ -138,6 +140,21 @@ class WOStackUpgradeController(CementBaseController):
'kickstart-static64.sh', 'kickstart-static64.sh',
'/var/lib/wo/tmp/kickstart.sh', '/var/lib/wo/tmp/kickstart.sh',
'Netdata']] 'Netdata']]
if pargs.dashboard:
if os.path.isfile('/var/www/22222/htdocs/index.php'):
packages = packages + \
[["https://github.com/WordOps/wordops-dashboard/"
"releases/download/v{0}/wordops-dashboard.tar.gz"
.format(WOVariables.wo_dashboard),
"/var/lib/wo/tmp/wo-dashboard.tar.gz",
"WordOps Dashboard"],
["https://github.com/soerennb/"
"extplorer/archive/v{0}.tar.gz"
.format(WOVariables.wo_extplorer),
"/var/lib/wo/tmp/extplorer.tar.gz",
"eXtplorer"]]
if pargs.phpmyadmin: if pargs.phpmyadmin:
if os.path.isdir('/var/www/22222/htdocs/db/pma'): if os.path.isdir('/var/www/22222/htdocs/db/pma'):
packages = packages + \ packages = packages + \
@@ -184,10 +201,13 @@ class WOStackUpgradeController(CementBaseController):
if len(packages): if len(packages):
if pargs.wpcli: if pargs.wpcli:
WOFileUtils.remove(self, ['/usr/local/bin/wp']) WOFileUtils.rm(self, '/usr/local/bin/wp')
if pargs.netdata: if pargs.netdata:
WOFileUtils.remove(self, ['/var/lib/wo/tmp/kickstart.sh']) WOFileUtils.rm(self, '/var/lib/wo/tmp/kickstart.sh')
if pargs.dashboard:
WOFileUtils.rm(self, '/var/www/22222/htdocs/index.php')
Log.debug(self, "Downloading following: {0}".format(packages)) Log.debug(self, "Downloading following: {0}".format(packages))
WODownload.download(self, packages) WODownload.download(self, packages)
@@ -201,6 +221,15 @@ class WOStackUpgradeController(CementBaseController):
"kickstart.sh " "kickstart.sh "
"--dont-wait") "--dont-wait")
if pargs.dashboard:
Log.debug(self, "Extracting wo-dashboard.tar.gz "
"to location {0}22222/htdocs/"
.format(WOVariables.wo_webroot))
WOExtract.extract(self, '/var/lib/wo/tmp/'
'wo-dashboard.tar.gz',
'{0}22222/htdocs'
.format(WOVariables.wo_webroot))
if pargs.composer: if pargs.composer:
Log.info(self, "Upgrading Composer, please wait...") Log.info(self, "Upgrading Composer, please wait...")
WOShellExec.cmd_exec(self, "php -q /var/lib/wo" WOShellExec.cmd_exec(self, "php -q /var/lib/wo"

View File

@@ -15,23 +15,11 @@ events {
http { http {
## ##
# WordOps Settings # WordOps Settings
## ##
sendfile on;
sendfile_max_chunk 512k;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 8;
keepalive_requests 500;
keepalive_disable msie6;
lingering_time 20s;
lingering_timeout 5s;
# Nginx AIO : See - https://www.nginx.com/blog/thread-pools-boost-performance-9x/ # Nginx AIO : See - https://www.nginx.com/blog/thread-pools-boost-performance-9x/
# http://nginx.org/en/docs/http/ngx_http_core_module.html#aio # http://nginx.org/en/docs/http/ngx_http_core_module.html#aio
aio threads; aio threads;
@@ -40,13 +28,7 @@ http {
reset_timedout_connection on; reset_timedout_connection on;
more_set_headers "X-Powered-By : WordOps"; more_set_headers "X-Powered-By : WordOps";
open_file_cache max=50000 inactive=60s; # Limit Request
open_file_cache_errors off;
open_file_cache_min_uses 2;
open_file_cache_valid 120s;
open_log_file_cache max=10000 inactive=30s min_uses=2;
# Limit Request
limit_req_status 403; limit_req_status 403;
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
@@ -63,7 +45,6 @@ http {
# tls dynamic records patch directive # tls dynamic records patch directive
ssl_dyn_rec_enable on; ssl_dyn_rec_enable on;
## ##
# SSL Settings # SSL Settings
## ##

View File

@@ -0,0 +1,30 @@
# NGINX Tweaks - WO v3.9.8
directio 4m;
directio_alignment 512;
http2_max_field_size 16k;
http2_max_header_size 32k;
large_client_header_buffers 8 64k;
postpone_output 1460;
proxy_buffers 8 32k;
proxy_buffer_size 64k;
sendfile on;
sendfile_max_chunk 512k;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 8;
keepalive_requests 500;
keepalive_disable msie6;
lingering_time 20s;
lingering_timeout 5s;
open_file_cache max=50000 inactive=60s;
open_file_cache_errors off;
open_file_cache_min_uses 2;
open_file_cache_valid 120s;
open_log_file_cache max=10000 inactive=30s min_uses=2;

View File

@@ -1,4 +1,4 @@
# NGINX UPSTREAM CONFIGURATION - WO v3.9.7 # NGINX UPSTREAM CONFIGURATION - WO v3.9.8
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
#------------------------------- #-------------------------------
# PHP 5.6 # PHP 5.6

27
wo/core/template.py Normal file
View File

@@ -0,0 +1,27 @@
from wo.core.logging import Log
import os
"""
Render Templates
"""
class WOTemplate():
def tmpl_render(self, fileconf, template, data, overwrite=False):
if overwrite:
Log.debug(self, 'Writting the configuration to '
'file {0}'.format(fileconf))
wo_template = open('{0}'.format(fileconf),
encoding='utf-8', mode='w')
self.app.render((data), '{0}'.format(template),
out=wo_template)
wo_template.close()
else:
if not os.path.isfile('{0}'.format(fileconf)):
Log.debug(self, 'Writting the configuration to '
'file {0}'.format(fileconf))
wo_template = open('{0}'.format(fileconf),
encoding='utf-8', mode='w')
self.app.render((data), '{0}'.format(template),
out=wo_template)
wo_template.close()