diff --git a/CHANGELOG.md b/CHANGELOG.md index db35dff..df274c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### v3.9.x - [Unreleased] +### v3.10.3 - 2019-11-11 + +#### Added + +- [ACME] Display warning about sudo usage when issuing certificate with DNS API validation (require `sudo -E`) + +#### Changed + +- [ACME] Resolve domain IP over HTTPS with Cloudflare DNS Resolver +- [CORE] Cement Framework updated to v2.10.2 +- [SITE] database name = 0 to 16 characters from the site name + 4 randomly generated character +- [SITE] database user = 0 to 12 characters from the site name + 4 randomy generated character +- [STACK] Improve sysctl tweak deployment + +#### Fixed + +- [SITE] https redirection missing on subdomains sites +- Issues with digitalocean mariadb repository +- Cement Framework output handler issues +- [CLEAN] check if Nginx is installed before purging fastcgi or opcache + ### v3.10.2 - 2019-11-06 #### Added diff --git a/install b/install index 3df23e6..39ca2e0 100755 --- a/install +++ b/install @@ -9,7 +9,7 @@ # ------------------------------------------------------------------------- # wget -qO wo wops.cc && sudo bash wo # ------------------------------------------------------------------------- -# Version 3.10.2 - 2019-11-06 +# Version 3.10.3 - 2019-11-11 # ------------------------------------------------------------------------- # CONTENTS @@ -207,13 +207,13 @@ wo_install_dep() { if [ "$wo_linux_distro" == "Ubuntu" ]; then # install dependencies apt-get -option=Dpkg::options::=--force-confmiss --option=Dpkg::options::=--force-confold --assume-yes install \ - build-essential curl gzip python3-pip python3-wheel python3-apt python3-setuptools python3-dev sqlite3 git tar software-properties-common pigz \ + build-essential curl gzip python3-pip python3-apt python3-dev sqlite3 git tar software-properties-common pigz \ gnupg2 cron ccze rsync apt-transport-https tree haveged ufw unattended-upgrades tzdata ntp >/dev/null 2>&1 curl -sL https://download.opensuse.org/repositories/home:/virtubox:/WordOps/xUbuntu_18.04/Release.key | apt-key add - else # install dependencies apt-get -option=Dpkg::options::=--force-confmiss --option=Dpkg::options::=--force-confold --assume-yes install \ - build-essential curl gzip dirmngr sudo python3-pip python3-wheel python3-apt python3-setuptools python3-dev ca-certificates sqlite3 git tar \ + build-essential curl gzip dirmngr sudo python3-pip python3-apt python3-dev ca-certificates sqlite3 git tar \ software-properties-common pigz apt-transport-https gnupg2 cron ccze rsync tree haveged ufw unattended-upgrades tzdata ntp >/dev/null 2>&1 # add php repository gpg key [ -d /etc/apt/trusted.gpg.d ] && { wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg; } @@ -631,7 +631,13 @@ wo_init() { if [ -z "$wo_travis" ]; then # import easyengine opensusebuildservice gpg key to avoid issues with packages update - apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys 3050ac3cd2ae6f03 > /dev/null 2>&1 + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3050ac3cd2ae6f03 > /dev/null 2>&1 + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xF1656F24C74CD1D8 > /dev/null 2>&1 + # fix digitalocean mariadb repository issue + sed -i 's/sfo1.mirrors.digitalocean.com\/mariadb/mariadb.mirrors.ovh.net\/MariaDB/' /etc/apt/sources.list.d/*.list > /dev/null 2>&1 + if [ -f /etc/apt/preferences.d/MariaDB.pref ]; then + sed -i 's/sfo1.mirrors.digitalocean.com/mariadb.mirrors.ovh.net/' /etc/apt/preferences.d/MariaDB.pref > /dev/null 2>&1 + fi if ! { apt-get update --allow-releaseinfo-change -qq >/dev/null 2>&1 }; then diff --git a/requirements.txt b/requirements.txt index e3ca0dd..85341d9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -cement==2.8.2 +cement==2.10.12 pystache>=0.5.4 pynginxconfig>=0.3.4 PyMySQL>=0.9.3 diff --git a/setup.py b/setup.py index 017b039..9ebae61 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ if os.geteuid() == 0: os.makedirs('/var/lib/wo/tmp/') setup(name='wordops', - version='3.10.2', + version='3.10.3', description='An essential toolset that eases server administration', long_description=LONG, long_description_content_type='text/markdown', @@ -55,7 +55,7 @@ setup(name='wordops', # Required to build documentation # "Sphinx >= 1.0", # Required to function - 'cement == 2.8.2', + 'cement == 2.10.12', 'pystache >= 0.5.4', 'pynginxconfig >= 0.3.4', 'PyMySQL >= 0.9.3', diff --git a/tests/cli/13_test_stack.py b/tests/cli/13_test_stack.py deleted file mode 100644 index fbecf58..0000000 --- a/tests/cli/13_test_stack.py +++ /dev/null @@ -1,49 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseStack(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - - def test_wo_cli_stack_install_nginx(self): - self.app = get_test_app(argv=['stack', 'install', '--nginx']) - self.app.setup() - self.app.run() - - def test_wo_cli_stack_install_php(self): - self.app = get_test_app(argv=['stack', 'install', '--php']) - self.app.setup() - self.app.run() - - def test_wo_cli_stack_install_php73(self): - self.app = get_test_app(argv=['stack', 'install', '--php73']) - self.app.setup() - self.app.run() - - def test_wo_cli_stack_install_mysql(self): - self.app = get_test_app(argv=['stack', 'install', '--mysql']) - self.app.setup() - self.app.run() - - def test_wo_cli_stack_install_wpcli(self): - self.app = get_test_app(argv=['stack', 'install', '--wpcli']) - self.app.setup() - self.app.run() - - def test_wo_cli_stack_install_phpmyadmin(self): - self.app = get_test_app(argv=['stack', 'install', '--phpmyadmin']) - self.app.setup() - self.app.run() - - def test_wo_cli_stack_install_adminer(self): - self.app = get_test_app(argv=['stack', 'install', '--adminer']) - self.app.setup() - self.app.run() - - def test_wo_cli_stack_install_utils(self): - self.app = get_test_app(argv=['stack', 'install', '--utils']) - self.app.setup() - self.app.run() diff --git a/tests/cli/13_test_stack_install.py b/tests/cli/13_test_stack_install.py new file mode 100644 index 0000000..b7a607c --- /dev/null +++ b/tests/cli/13_test_stack_install.py @@ -0,0 +1,41 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseStack(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_stack_install_nginx(self): + with WOTestApp(argv=['stack', 'install', '--nginx']) as app: + app.run() + + def test_wo_cli_stack_install_php(self): + with WOTestApp(argv=['stack', 'install', '--php']) as app: + app.run() + + def test_wo_cli_stack_install_php73(self): + with WOTestApp(argv=['stack', 'install', '--php73']) as app: + app.run() + + def test_wo_cli_stack_install_mysql(self): + with WOTestApp(argv=['stack', 'install', '--mysql']) as app: + app.run() + + def test_wo_cli_stack_install_wpcli(self): + with WOTestApp(argv=['stack', 'install', '--wpcli']) as app: + app.run() + + def test_wo_cli_stack_install_phpmyadmin(self): + with WOTestApp(argv=['stack', 'install', '--phpmyadmin']) as app: + app.run() + + def test_wo_cli_stack_install_adminer(self): + with WOTestApp(argv=['stack', 'install', '--adminer']) as app: + app.run() + + def test_wo_cli_stack_install_utils(self): + with WOTestApp(argv=['stack', 'install', '--utils']) as app: + app.run() diff --git a/tests/cli/14_test_stack_services_stop.py b/tests/cli/14_test_stack_services_stop.py new file mode 100644 index 0000000..05897c6 --- /dev/null +++ b/tests/cli/14_test_stack_services_stop.py @@ -0,0 +1,25 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseStackStop(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_stack_services_stop_nginx(self): + with WOTestApp(argv=['stack', 'stop', '--nginx']) as app: + app.run() + + def test_wo_cli_stack_services_stop_php_fpm(self): + with WOTestApp(argv=['stack', 'stop', '--php']) as app: + app.run() + + def test_wo_cli_stack_services_stop_mysql(self): + with WOTestApp(argv=['stack', 'stop', '--mysql']) as app: + app.run() + + def test_wo_cli_stack_services_stop_all(self): + with WOTestApp(argv=['stack', 'stop']) as app: + app.run() diff --git a/tests/cli/15_test_stack_services_start.py b/tests/cli/15_test_stack_services_start.py new file mode 100644 index 0000000..37e7f81 --- /dev/null +++ b/tests/cli/15_test_stack_services_start.py @@ -0,0 +1,25 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseStackStart(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_stack_services_start_nginx(self): + with WOTestApp(argv=['stack', 'start', '--nginx']) as app: + app.run() + + def test_wo_cli_stack_services_start_php_fpm(self): + with WOTestApp(argv=['stack', 'start', '--php']) as app: + app.run() + + def test_wo_cli_stack_services_start_mysql(self): + with WOTestApp(argv=['stack', 'start', '--mysql']) as app: + app.run() + + def test_wo_cli_stack_services_start_all(self): + with WOTestApp(argv=['stack', 'start']) as app: + app.run() diff --git a/tests/cli/16_test_stack_services_restart.py b/tests/cli/16_test_stack_services_restart.py new file mode 100644 index 0000000..c603ba7 --- /dev/null +++ b/tests/cli/16_test_stack_services_restart.py @@ -0,0 +1,25 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseStackRestart(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_stack_services_restart_nginx(self): + with WOTestApp(argv=['stack', 'restart', '--nginx']) as app: + app.run() + + def test_wo_cli_stack_services_restart_php_fpm(self): + with WOTestApp(argv=['stack', 'restart', '--php']) as app: + app.run() + + def test_wo_cli_stack_services_restart_mysql(self): + with WOTestApp(argv=['stack', 'restart', '--mysql']) as app: + app.run() + + def test_wo_cli_stack_services_restart_all(self): + with WOTestApp(argv=['stack', 'restart']) as app: + app.run() diff --git a/tests/cli/17_test_stack_services_status.py b/tests/cli/17_test_stack_services_status.py new file mode 100644 index 0000000..dda9b6a --- /dev/null +++ b/tests/cli/17_test_stack_services_status.py @@ -0,0 +1,25 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseStackStatus(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_stack_services_status_nginx(self): + with WOTestApp(argv=['stack', 'status', '--nginx']) as app: + app.run() + + def test_wo_cli_stack_services_status_php_fpm(self): + with WOTestApp(argv=['stack', 'status', '--php']) as app: + app.run() + + def test_wo_cli_stack_services_status_mysql(self): + with WOTestApp(argv=['stack', 'status', '--mysql']) as app: + app.run() + + def test_wo_cli_stack_services_status_all(self): + with WOTestApp(argv=['stack', 'status']) as app: + app.run() diff --git a/tests/cli/18_test_site_create.py b/tests/cli/18_test_site_create.py new file mode 100644 index 0000000..2251cb8 --- /dev/null +++ b/tests/cli/18_test_site_create.py @@ -0,0 +1,50 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseSiteCreate(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_site_create_html(self): + with WOTestApp(argv=['site', 'create', 'example1.com', + '--html']) as app: + app.config.set('wo', '', True) + app.run() + + def test_wo_cli_site_create_php(self): + with WOTestApp(argv=['site', 'create', 'example2.com', + '--php']) as app: + app.run() + + def test_wo_cli_site_create_mysql(self): + with WOTestApp(argv=['site', 'create', 'example3.com', + '--mysql']) as app: + app.run() + + def test_wo_cli_site_create_wp(self): + with WOTestApp(argv=['site', 'create', 'example4.com', + '--wp']) as app: + app.run() + + def test_wo_cli_site_create_wpsubdir(self): + with WOTestApp(argv=['site', 'create', 'example5.com', + '--wpsubdir']) as app: + app.run() + + def test_wo_cli_site_create_wpsubdomain(self): + with WOTestApp(argv=['site', 'create', 'example6.com', + '--wpsubdomain']) as app: + app.run() + + def test_wo_cli_site_create_wpfc(self): + with WOTestApp(argv=['site', 'create', 'example8.com', + '--wpfc']) as app: + app.run() + + def test_wo_cli_site_create_wpsc(self): + with WOTestApp(argv=['site', 'create', 'example9.com', + '--wpsc']) as app: + app.run() diff --git a/tests/cli/19_test_site_disable.py b/tests/cli/19_test_site_disable.py new file mode 100644 index 0000000..ad16c97 --- /dev/null +++ b/tests/cli/19_test_site_disable.py @@ -0,0 +1,13 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseSiteDisable(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_site_disable(self): + with WOTestApp(argv=['site', 'disable', 'example2.com']) as app: + app.run() diff --git a/tests/cli/20_test_site_enable.py b/tests/cli/20_test_site_enable.py new file mode 100644 index 0000000..d829431 --- /dev/null +++ b/tests/cli/20_test_site_enable.py @@ -0,0 +1,13 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseSiteEnable(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_site_enable(self): + with WOTestApp(argv=['site', 'enable', 'example2.com']) as app: + app.run() diff --git a/tests/cli/21_test_site_info.py b/tests/cli/21_test_site_info.py new file mode 100644 index 0000000..c96f9a8 --- /dev/null +++ b/tests/cli/21_test_site_info.py @@ -0,0 +1,13 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseSiteInfo(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_site_info(self): + with WOTestApp(argv=['site', 'info', 'example1.com']) as app: + app.run() diff --git a/tests/cli/22_test_site_list.py b/tests/cli/22_test_site_list.py new file mode 100644 index 0000000..33edbf4 --- /dev/null +++ b/tests/cli/22_test_site_list.py @@ -0,0 +1,17 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseSiteList(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_site_list_enable(self): + with WOTestApp(argv=['site', 'list', '--enabled']) as app: + app.run() + + def test_wo_cli_site_list_disable(self): + with WOTestApp(argv=['site', 'list', '--disabled']) as app: + app.run() diff --git a/tests/cli/23_test_site_show.py b/tests/cli/23_test_site_show.py new file mode 100644 index 0000000..5e00df3 --- /dev/null +++ b/tests/cli/23_test_site_show.py @@ -0,0 +1,13 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseSiteShow(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_show_edit(self): + with WOTestApp(argv=['site', 'show', 'example1.com']) as app: + app.run() diff --git a/tests/cli/24_test_site_update.py b/tests/cli/24_test_site_update.py new file mode 100644 index 0000000..ca34dc0 --- /dev/null +++ b/tests/cli/24_test_site_update.py @@ -0,0 +1,49 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseSiteUpdate(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_site_update_html(self): + with WOTestApp(argv=['site', 'update', 'example2.com', + '--html']) as app: + app.run() + + def test_wo_cli_site_update_php(self): + with WOTestApp(argv=['site', 'update', 'example1.com', + '--php']) as app: + app.run() + + def test_wo_cli_site_update_mysql(self): + with WOTestApp(argv=['site', 'update', 'example1.com', + '--html']) as app: + app.run() + + def test_wo_cli_site_update_wp(self): + with WOTestApp(argv=['site', 'update', 'example5.com', + '--wp']) as app: + app.run() + + def test_wo_cli_site_update_wpsubdir(self): + with WOTestApp(argv=['site', 'update', 'example4.com', + '--wpsubdir']) as app: + app.run() + + def test_wo_cli_site_update_wpsubdomain(self): + with WOTestApp(argv=['site', 'update', 'example7.com', + '--wpsubdomain']) as app: + app.run() + + def test_wo_cli_site_update_wpfc(self): + with WOTestApp(argv=['site', 'update', 'example9.com', + '--wpfc']) as app: + app.run() + + def test_wo_cli_site_update_wpsc(self): + with WOTestApp(argv=['site', 'update', 'example6.com', + '--wpsc']) as app: + app.run() diff --git a/tests/cli/25_test_clean.py b/tests/cli/25_test_clean.py new file mode 100644 index 0000000..42e7935 --- /dev/null +++ b/tests/cli/25_test_clean.py @@ -0,0 +1,29 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseClean(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_clean(self): + with WOTestApp(argv=['clean']) as app: + app.run() + + def test_wo_cli_clean_fastcgi(self): + with WOTestApp(argv=['clean', '--fastcgi']) as app: + app.run() + + def test_wo_cli_clean_all(self): + with WOTestApp(argv=['clean', '--all']) as app: + app.run() + + def test_wo_cli_clean_opcache(self): + with WOTestApp(argv=['clean', '--opcache']) as app: + app.run() + + def test_wo_cli_clean_redis(self): + with WOTestApp(argv=['clean', '--redis']) as app: + app.run() diff --git a/tests/cli/26_test_debug.py b/tests/cli/26_test_debug.py new file mode 100644 index 0000000..d2bd172 --- /dev/null +++ b/tests/cli/26_test_debug.py @@ -0,0 +1,66 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseDebug(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_debug_stop(self): + with WOTestApp(argv=['debug', '--stop']) as app: + app.run() + + def test_wo_cli_debug_start(self): + with WOTestApp(argv=['debug', '--start']) as app: + app.run() + + def test_wo_cli_debug_php(self): + with WOTestApp(argv=['debug', '--php']) as app: + app.run() + + def test_wo_cli_debug_nginx(self): + with WOTestApp(argv=['debug', '--nginx']) as app: + app.run() + + def test_wo_cli_debug_rewrite(self): + with WOTestApp(argv=['debug', '--rewrite']) as app: + app.run() + + def test_wo_cli_debug_fpm(self): + with WOTestApp(argv=['debug', '--fpm']) as app: + app.run() + + def test_wo_cli_debug_mysql(self): + with WOTestApp(argv=['debug', '--mysql']) as app: + app.run() + + def test_wo_cli_debug_import_slow_log_interval(self): + with WOTestApp(argv=['debug', '--mysql', + '--import-slow-log-interval']) as app: + app.run() + + def test_wo_cli_debug_site_name_mysql(self): + with WOTestApp(argv=['debug', 'example3.com', '--mysql']) as app: + app.run() + + def test_wo_cli_debug_site_name_wp(self): + with WOTestApp(argv=['debug', 'example4.com', '--wp']) as app: + app.run() + + def test_wo_cli_debug_site_name_nginx(self): + with WOTestApp(argv=['debug', 'example4.com', '--nginx']) as app: + app.run() + + def test_wo_cli_debug_site_name_start(self): + with WOTestApp(argv=['debug', 'example1.com', '--start']) as app: + app.run() + + def test_wo_cli_debug_site_name_stop(self): + with WOTestApp(argv=['debug', 'example1.com', '--stop']) as app: + app.run() + + def test_wo_cli_debug_site_name_rewrite(self): + with WOTestApp(argv=['debug', 'example1.com', '--rewrite']) as app: + app.run() diff --git a/tests/cli/27_test_info.py b/tests/cli/27_test_info.py new file mode 100644 index 0000000..5a6816c --- /dev/null +++ b/tests/cli/27_test_info.py @@ -0,0 +1,21 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseInfo(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_info_mysql(self): + with WOTestApp(argv=['info', '--mysql']) as app: + app.run() + + def test_wo_cli_info_php(self): + with WOTestApp(argv=['info', '--php']) as app: + app.run() + + def test_wo_cli_info_nginx(self): + with WOTestApp(argv=['info', '--nginx']) as app: + app.run() diff --git a/tests/cli/28_test_secure.py b/tests/cli/28_test_secure.py new file mode 100644 index 0000000..4500a2a --- /dev/null +++ b/tests/cli/28_test_secure.py @@ -0,0 +1,21 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseSecure(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_secure_auth(self): + with WOTestApp(argv=['secure', '--auth', 'abc', 'superpass']) as app: + app.run() + + def test_wo_cli_secure_port(self): + with WOTestApp(argv=['secure', '--port', '22222']) as app: + app.run() + + def test_wo_cli_secure_ip(self): + with WOTestApp(argv=['secure', '--ip', '172.16.0.1']) as app: + app.run() diff --git a/tests/cli/29_test_site_delete.py b/tests/cli/29_test_site_delete.py new file mode 100644 index 0000000..38cf15a --- /dev/null +++ b/tests/cli/29_test_site_delete.py @@ -0,0 +1,29 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseSiteDelete(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_site_detele(self): + with WOTestApp(argv=['site', 'delete', 'example1.com', + '--no-prompt']) as app: + app.run() + + def test_wo_cli_site_detele_all(self): + with WOTestApp(argv=['site', 'delete', 'example2.com', + '--all', '--no-prompt']) as app: + app.run() + + def test_wo_cli_site_detele_db(self): + with WOTestApp(argv=['site', 'delete', 'example3.com', + '--db', '--no-prompt']) as app: + app.run() + + def test_wo_cli_site_detele_files(self): + with WOTestApp(argv=['site', 'delete', 'example4.com', + '--files', '--no-prompt']) as app: + app.run() diff --git a/tests/cli/2_test_stack_services_start.py b/tests/cli/2_test_stack_services_start.py deleted file mode 100644 index 4eca160..0000000 --- a/tests/cli/2_test_stack_services_start.py +++ /dev/null @@ -1,34 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseStack(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_start_nginx(self): - self.app = get_test_app(argv=['stack', 'start', '--nginx']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_start_php_fpm(self): - self.app = get_test_app(argv=['stack', 'start', '--php']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_start_mysql(self): - self.app = get_test_app(argv=['stack', 'start', '--mysql']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_start_all(self): - self.app = get_test_app(argv=['stack', 'start']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/30_test_stack_remove.py b/tests/cli/30_test_stack_remove.py new file mode 100644 index 0000000..d952055 --- /dev/null +++ b/tests/cli/30_test_stack_remove.py @@ -0,0 +1,43 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseStackRemove(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_stack_remove_admin(self): + with WOTestApp(argv=['stack', 'remove', '--admin', '--force']) as app: + app.run() + + def test_wo_cli_stack_remove_nginx(self): + with WOTestApp(argv=['stack', 'remove', '--nginx', '--force']) as app: + app.run() + + def test_wo_cli_stack_remove_php(self): + with WOTestApp(argv=['stack', 'remove', '--php', '--force']) as app: + app.run() + + def test_wo_cli_stack_remove_mysql(self): + with WOTestApp(argv=['stack', 'remove', '--mysql', '--force']) as app: + app.run() + + def test_wo_cli_stack_remove_wpcli(self): + with WOTestApp(argv=['stack', 'remove', '--wpcli', '--force']) as app: + app.run() + + def test_wo_cli_stack_remove_phpmyadmin(self): + with WOTestApp(argv=['stack', 'remove', + '--phpmyadmin', '--force']) as app: + app.run() + + def test_wo_cli_stack_remove_adminer(self): + with WOTestApp( + argv=['stack', 'remove', '--adminer', '--force']) as app: + app.run() + + def test_wo_cli_stack_remove_utils(self): + with WOTestApp(argv=['stack', 'remove', '--utils', '--force']) as app: + app.run() diff --git a/tests/cli/31_test_stack_purge.py b/tests/cli/31_test_stack_purge.py new file mode 100644 index 0000000..eaef5d7 --- /dev/null +++ b/tests/cli/31_test_stack_purge.py @@ -0,0 +1,54 @@ +from wo.utils import test +from wo.cli.main import WOTestApp + + +class CliTestCaseStackPurge(test.WOTestCase): + + def test_wo_cli(self): + with WOTestApp as app: + app.run() + + def test_wo_cli_stack_purge_web(self): + with WOTestApp( + argv=['stack', 'purge', '--web', '--force']) as app: + app.run() + + def test_wo_cli_stack_purge_admin(self): + with WOTestApp( + argv=['stack', 'purge', '--admin', '--force']) as app: + app.run() + + def test_wo_cli_stack_purge_nginx(self): + with WOTestApp( + argv=['stack', 'purge', '--nginx', '--force']) as app: + app.run() + + def test_wo_cli_stack_purge_php(self): + with WOTestApp(argv=['stack', 'purge', + '--php', '--force']) as app: + app.run() + + def test_wo_cli_stack_purge_mysql(self): + with WOTestApp(argv=['stack', 'purge', + '--mysql', '--force']) as app: + app.run() + + def test_wo_cli_stack_purge_wpcli(self): + with WOTestApp(argv=['stack', 'purge', + '--wpcli', '--force']) as app: + app.run() + + def test_wo_cli_stack_purge_phpmyadmin(self): + with WOTestApp( + argv=['stack', 'purge', '--phpmyadmin', '--force']) as app: + app.run() + + def test_wo_cli_stack_purge_adminer(self): + with WOTestApp( + argv=['stack', 'purge', '--adminer', '--force']) as app: + app.run() + + def test_wo_cli_stack_purge_utils(self): + with WOTestApp(argv=['stack', 'purge', + '--utils', '--force']) as app: + app.run() diff --git a/tests/cli/3_test_stack_services_status.py b/tests/cli/3_test_stack_services_status.py deleted file mode 100644 index f0441a4..0000000 --- a/tests/cli/3_test_stack_services_status.py +++ /dev/null @@ -1,34 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseStack(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_status_nginx(self): - self.app = get_test_app(argv=['stack', 'status', '--nginx']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_status_php_fpm(self): - self.app = get_test_app(argv=['stack', 'status', '--php']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_status_mysql(self): - self.app = get_test_app(argv=['stack', 'status', '--mysql']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_status_all(self): - self.app = get_test_app(argv=['stack', 'status']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/4_test_stack_services_stop.py b/tests/cli/4_test_stack_services_stop.py deleted file mode 100644 index 577dc54..0000000 --- a/tests/cli/4_test_stack_services_stop.py +++ /dev/null @@ -1,34 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseStack(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_stop_nginx(self): - self.app = get_test_app(argv=['stack', 'stop', '--nginx']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_stop_php_fpm(self): - self.app = get_test_app(argv=['stack', 'stop', '--php']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_stop_mysql(self): - self.app = get_test_app(argv=['stack', 'stop', '--mysql']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_stop_all(self): - self.app = get_test_app(argv=['stack', 'stop']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/5_test_stack_services_restart.py b/tests/cli/5_test_stack_services_restart.py deleted file mode 100644 index 60dff84..0000000 --- a/tests/cli/5_test_stack_services_restart.py +++ /dev/null @@ -1,34 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseStack(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_restart_nginx(self): - self.app = get_test_app(argv=['stack', 'restart', '--nginx']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_restart_php_fpm(self): - self.app = get_test_app(argv=['stack', 'restart', '--php']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_restart_mysql(self): - self.app = get_test_app(argv=['stack', 'restart', '--mysql']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_services_restart_all(self): - self.app = get_test_app(argv=['stack', 'restart']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/8_test_site_create.py b/tests/cli/8_test_site_create.py deleted file mode 100644 index 2465cc6..0000000 --- a/tests/cli/8_test_site_create.py +++ /dev/null @@ -1,66 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseSite(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_create_html(self): - self.app = get_test_app(argv=['site', 'create', 'example1.com', - '--html']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_create_php(self): - self.app = get_test_app(argv=['site', 'create', 'example2.com', - '--php']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_create_mysql(self): - self.app = get_test_app(argv=['site', 'create', 'example3.com', - '--mysql']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_create_wp(self): - self.app = get_test_app(argv=['site', 'create', 'example4.com', - '--wp']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_create_wpsubdir(self): - self.app = get_test_app(argv=['site', 'create', 'example5.com', - '--wpsubdir']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_create_wpsubdomain(self): - self.app = get_test_app(argv=['site', 'create', 'example6.com', - '--wpsubdomain']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_create_wpfc(self): - self.app = get_test_app(argv=['site', 'create', 'example8.com', - '--wpfc']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_create_wpsc(self): - self.app = get_test_app(argv=['site', 'create', 'example9.com', - '--wpsc']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/91_test_site_info.py b/tests/cli/91_test_site_info.py deleted file mode 100644 index 38caeff..0000000 --- a/tests/cli/91_test_site_info.py +++ /dev/null @@ -1,16 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseSite(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_info(self): - self.app = get_test_app(argv=['site', 'info', 'example1.com']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/93_test_site_list.py b/tests/cli/93_test_site_list.py deleted file mode 100644 index da3ef8d..0000000 --- a/tests/cli/93_test_site_list.py +++ /dev/null @@ -1,22 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseSite(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_list_enable(self): - self.app = get_test_app(argv=['site', 'list', '--enabled']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_list_disable(self): - self.app = get_test_app(argv=['site', 'list', '--disabled']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/95_test_site_show.py b/tests/cli/95_test_site_show.py deleted file mode 100644 index bbf81e2..0000000 --- a/tests/cli/95_test_site_show.py +++ /dev/null @@ -1,16 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseSite(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_show_edit(self): - self.app = get_test_app(argv=['site', 'show', 'example1.com']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/97_test_site_update.py b/tests/cli/97_test_site_update.py deleted file mode 100644 index 3d111c7..0000000 --- a/tests/cli/97_test_site_update.py +++ /dev/null @@ -1,66 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseSite(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_update_html(self): - self.app = get_test_app(argv=['site', 'update', 'example2.com', - '--html']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_update_php(self): - self.app = get_test_app(argv=['site', 'update', 'example1.com', - '--php']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_update_mysql(self): - self.app = get_test_app(argv=['site', 'update', 'example1.com', - '--html']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_update_wp(self): - self.app = get_test_app(argv=['site', 'update', 'example5.com', - '--wp']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_update_wpsubdir(self): - self.app = get_test_app(argv=['site', 'update', 'example4.com', - '--wpsubdir']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_update_wpsubdomain(self): - self.app = get_test_app(argv=['site', 'update', 'example7.com', - '--wpsubdomain']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_update_wpfc(self): - self.app = get_test_app(argv=['site', 'update', 'example9.com', - '--wpfc']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_update_wpsc(self): - self.app = get_test_app(argv=['site', 'update', 'example6.com', - '--wpsc']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/9_test_site_enable.py b/tests/cli/9_test_site_enable.py deleted file mode 100644 index 08b15c9..0000000 --- a/tests/cli/9_test_site_enable.py +++ /dev/null @@ -1,16 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseSite(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_enable(self): - self.app = get_test_app(argv=['site', 'enable', 'example2.com']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/a_test_site_disable.py b/tests/cli/a_test_site_disable.py deleted file mode 100644 index 058313b..0000000 --- a/tests/cli/a_test_site_disable.py +++ /dev/null @@ -1,16 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseSite(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_disable(self): - self.app = get_test_app(argv=['site', 'disable', 'example2.com']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/plugins/test_example.py b/tests/cli/plugins/test_example.py deleted file mode 100644 index dc101f8..0000000 --- a/tests/cli/plugins/test_example.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Tests for Example Plugin.""" - -from wo.utils.test import WOTestCase - - -class ExamplePluginTestCase(WOTestCase): - def test_load_example_plugin(self): - self.app.setup() - self.app.plugin.load_plugin('example') diff --git a/tests/cli/test_clean.py b/tests/cli/test_clean.py deleted file mode 100644 index 04728c4..0000000 --- a/tests/cli/test_clean.py +++ /dev/null @@ -1,34 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseClean(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_clean(self): - self.app = get_test_app(argv=['clean']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_clean_fastcgi(self): - self.app = get_test_app(argv=['clean', '--fastcgi']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_clean_all(self): - self.app = get_test_app(argv=['clean', '--all']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_clean_opcache(self): - self.app = get_test_app(argv=['clean', '--opcache']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/test_debug.py b/tests/cli/test_debug.py deleted file mode 100644 index 026711b..0000000 --- a/tests/cli/test_debug.py +++ /dev/null @@ -1,95 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseDebug(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_stop(self): - self.app = get_test_app(argv=['debug', '--stop']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_start(self): - self.app = get_test_app(argv=['debug', '--start']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_php(self): - self.app = get_test_app(argv=['debug', '--php']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_nginx(self): - self.app = get_test_app(argv=['debug', '--nginx']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_rewrite(self): - self.app = get_test_app(argv=['debug', '--rewrite']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_fpm(self): - self.app = get_test_app(argv=['debug', '--fpm']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_mysql(self): - self.app = get_test_app(argv=['debug', '--mysql']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_import_slow_log_interval(self): - self.app = get_test_app(argv=['debug', '--mysql', - '--import-slow-log-interval']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_site_name_mysql(self): - self.app = get_test_app(argv=['debug', 'example3.com', '--mysql']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_site_name_wp(self): - self.app = get_test_app(argv=['debug', 'example4.com', '--wp']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_site_name_nginx(self): - self.app = get_test_app(argv=['debug', 'example4.com', '--nginx']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_site_name_start(self): - self.app = get_test_app(argv=['debug', 'example1.com', '--start']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_site_name_stop(self): - self.app = get_test_app(argv=['debug', 'example1.com', '--stop']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_debug_site_name_rewrite(self): - self.app = get_test_app(argv=['debug', 'example1.com', '--rewrite']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/test_info.py b/tests/cli/test_info.py deleted file mode 100644 index 0d87c45..0000000 --- a/tests/cli/test_info.py +++ /dev/null @@ -1,28 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseInfo(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_info_mysql(self): - self.app = get_test_app(argv=['info', '--mysql']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_info_php(self): - self.app = get_test_app(argv=['info', '--php']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_info_nginx(self): - self.app = get_test_app(argv=['info', '--nginx']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/test_secure.py b/tests/cli/test_secure.py deleted file mode 100644 index 1656134..0000000 --- a/tests/cli/test_secure.py +++ /dev/null @@ -1,28 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseSecure(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_secure_auth(self): - self.app = get_test_app(argv=['secure', '--auth', 'abc', 'superpass']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_secure_port(self): - self.app = get_test_app(argv=['secure', '--port', '22222']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_secure_ip(self): - self.app = get_test_app(argv=['secure', '--ip', '172.16.0.1']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/test_site_delete.py b/tests/cli/test_site_delete.py deleted file mode 100644 index 7bebf44..0000000 --- a/tests/cli/test_site_delete.py +++ /dev/null @@ -1,38 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseSite(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_detele(self): - self.app = get_test_app(argv=['site', 'delete', 'example1.com', - '--no-prompt']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_detele_all(self): - self.app = get_test_app(argv=['site', 'delete', 'example2.com', - '--all', '--no-prompt']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_detele_db(self): - self.app = get_test_app(argv=['site', 'delete', 'example3.com', - '--db', '--no-prompt']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_site_detele_files(self): - self.app = get_test_app(argv=['site', 'delete', 'example4.com', - '--files', '--no-prompt']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/test_stack_purge.py b/tests/cli/test_stack_purge.py deleted file mode 100644 index c940744..0000000 --- a/tests/cli/test_stack_purge.py +++ /dev/null @@ -1,73 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseStack(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_purge_web(self): - self.app = get_test_app(argv=['stack', 'purge', - '--web', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_purge_admin(self): - self.app = get_test_app(argv=['stack', 'purge', - '--admin', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_purge_nginx(self): - self.app = get_test_app(argv=['stack', 'purge', - '--nginx', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_purge_php(self): - self.app = get_test_app(argv=['stack', 'purge', - '--php', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_purge_mysql(self): - self.app = get_test_app(argv=['stack', 'purge', - '--mysql', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_purge_wpcli(self): - self.app = get_test_app(argv=['stack', 'purge', - '--wpcli', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_purge_phpmyadmin(self): - self.app = get_test_app( - argv=['stack', 'purge', '--phpmyadmin', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_purge_adminer(self): - self.app = get_test_app( - argv=['stack', 'purge', '--adminer', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_purge_utils(self): - self.app = get_test_app(argv=['stack', 'purge', - '--utils', '--force']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/test_stack_remove.py b/tests/cli/test_stack_remove.py deleted file mode 100644 index 08a29ad..0000000 --- a/tests/cli/test_stack_remove.py +++ /dev/null @@ -1,66 +0,0 @@ -from wo.utils import test -from wo.cli.main import get_test_app - - -class CliTestCaseStack(test.WOTestCase): - - def test_wo_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_remove_web(self): - self.app = get_test_app(argv=['stack', 'remove', '--web', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_install_admin(self): - self.app = get_test_app(argv=['stack', 'remove', '--admin', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_install_nginx(self): - self.app = get_test_app(argv=['stack', 'remove', '--nginx', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_install_php(self): - self.app = get_test_app(argv=['stack', 'remove', '--php', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_install_mysql(self): - self.app = get_test_app(argv=['stack', 'remove', '--mysql', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_install_wpcli(self): - self.app = get_test_app(argv=['stack', 'remove', '--wpcli', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_install_phpmyadmin(self): - self.app = get_test_app(argv=['stack', 'remove', - '--phpmyadmin', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_install_adminer(self): - self.app = get_test_app( - argv=['stack', 'remove', '--adminer', '--force']) - self.app.setup() - self.app.run() - self.app.close() - - def test_wo_cli_stack_install_utils(self): - self.app = get_test_app(argv=['stack', 'remove', '--utils', '--force']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/travis.sh b/tests/travis.sh index 357a5b1..40abaea 100644 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -15,9 +15,11 @@ export LANG='en_US.UTF-8' export LC_ALL='C.UTF-8' if [ -z "$1" ]; then +{ apt-get -qq purge mysql* graphviz* redis* apt-get install -qq git python3-setuptools python3-dev python3-apt ccze tree sudo apt-get -qq autoremove --purge +} > /dev/null 2>&1 fi exit_script() { @@ -221,10 +223,21 @@ else fi echo -e "${CGREEN}#############################################${CEND}" -echo -e ' various informations ' +echo -e ' WP-CLI info ' echo -e "${CGREEN}#############################################${CEND}" wp --allow-root --info + +echo +echo -e "${CGREEN}#############################################${CEND}" +echo -e ' wo site info ' +echo -e "${CGREEN}#############################################${CEND}" + wo site info wp.net + +echo +echo -e "${CGREEN}#############################################${CEND}" +echo -e ' wo info ' +echo -e "${CGREEN}#############################################${CEND}" wo info echo -e "${CGREEN}#############################################${CEND}" diff --git a/wo/cli/ext/wo_outputhandler.py b/wo/cli/ext/wo_outputhandler.py deleted file mode 100644 index c472420..0000000 --- a/wo/cli/ext/wo_outputhandler.py +++ /dev/null @@ -1,21 +0,0 @@ -# Based on https://github.com/datafolklabs/cement/issues/295 -# To avoid encoding releated error,we defined our custom output handler -# I hope we will remove this when we upgarde to Cement 2.6 (Not released yet) -import os - -from cement.ext.ext_mustache import MustacheOutputHandler -from cement.utils import fs - - -class WOOutputHandler(MustacheOutputHandler): - class Meta: - label = 'wo_output_handler' - - def _load_template_from_file(self, path): - for templ_dir in self.app._meta.template_dirs: - full_path = fs.abspath(os.path.join(templ_dir, path)) - if os.path.exists(full_path): - self.app.log.debug('loading template file %s' % full_path) - return open(full_path, encoding='utf-8', mode='r').read() - else: - continue diff --git a/wo/cli/main.py b/wo/cli/main.py index 06c247c..448aec5 100644 --- a/wo/cli/main.py +++ b/wo/cli/main.py @@ -1,13 +1,12 @@ """WordOps main application entry point.""" -import os import sys +from os import geteuid from cement.core.exc import CaughtSignal, FrameworkError from cement.core.foundation import CementApp from cement.ext.ext_argparse import ArgParseArgumentHandler from cement.utils.misc import init_defaults -from wo.cli.ext.wo_outputhandler import WOOutputHandler from wo.core import exc # this has to happen after you import sys, but before you import anything @@ -32,6 +31,17 @@ defaults['wo']['plugin_dir'] = '/var/lib/wo/plugins' defaults['wo']['template_dir'] = '/var/lib/wo/templates' +def encode_output(app, text): + """ Encode the output to be suitable for the terminal + + :param app: The Cement App (unused) + :param text: The rendered text + :return: The encoded text + """ + + return text.encode("utf-8") + + class WOArgHandler(ArgParseArgumentHandler): class Meta: label = 'wo_args_handler' @@ -57,8 +67,11 @@ class WOApp(CementApp): extensions = ['mustache'] - # default output handler - output_handler = WOOutputHandler + hooks = [ + ("post_render", encode_output) + ] + + output_handler = 'mustache' arg_handler = WOArgHandler @@ -91,7 +104,7 @@ def main(): global sys # if not root...kick out - if not os.geteuid() == 0: + if not geteuid() == 0: print("\nNon-privileged users cant use WordOps. " "Switch to root or invoke sudo.\n") app.close(1) @@ -103,14 +116,14 @@ def main(): # Catch our application errors and exit 1 (error) print('WOError > %s' % e) app.exit_code = 1 - except FrameworkError as e: - # Catch framework errors and exit 1 (error) - print('FrameworkError > %s' % e) - app.exit_code = 1 except CaughtSignal as e: # Default Cement signals are SIGINT and SIGTERM, exit 0 (non-error) print('CaughtSignal > %s' % e) app.exit_code = 0 + except FrameworkError as e: + # Catch framework errors and exit 1 (error) + print('FrameworkError > %s' % e) + app.exit_code = 1 finally: # Print an exception (if it occurred) and --debug was passed if app.debug: @@ -122,10 +135,5 @@ def main(): traceback.print_exc() -def get_test_app(**kw): - app = WOApp(**kw) - return app - - if __name__ == '__main__': main() diff --git a/wo/cli/plugins/clean.py b/wo/cli/plugins/clean.py index 3385876..a0b8338 100644 --- a/wo/cli/plugins/clean.py +++ b/wo/cli/plugins/clean.py @@ -37,9 +37,8 @@ class WOCleanController(CementBaseController): @expose(hide=True) def default(self): pargs = self.app.pargs - if (not (pargs.all or pargs.fastcgi - or pargs.opcache or - pargs.redis)): + if ((not pargs.all) and (not pargs.fastcgi) and + (not pargs.opcache) and (not pargs.redis)): self.clean_fastcgi() if pargs.all: self.clean_fastcgi() @@ -63,7 +62,8 @@ class WOCleanController(CementBaseController): @expose(hide=True) def clean_fastcgi(self): - if(os.path.isdir("/var/run/nginx-cache")): + if(os.path.isdir("/var/run/nginx-cache") and + os.path.exists('/usr/sbin/nginx')): Log.info(self, "Cleaning NGINX FastCGI cache") WOShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") WOService.restart_service(self, 'nginx') @@ -72,21 +72,24 @@ class WOCleanController(CementBaseController): @expose(hide=True) def clean_opcache(self): - try: - Log.info(self, "Cleaning opcache") - opgui = requests.get( - "https://127.0.0.1:22222/cache/opcache/opgui.php?reset=1") - if opgui.status_code != '200': - Log.warn(self, 'Cleaning opcache failed') - except Exception as e: - Log.debug(self, "{0}".format(e)) - Log.debug(self, "Unable hit url, " - " https://127.0.0.1:22222/cache/opcache/" - "opgui.php?reset=1," - " please check you have admin tools installed") - Log.debug(self, "please check you have admin tools installed," - " or install them with `wo stack install --admin`") - Log.error(self, "Unable to clean opcache", False) + if (os.path.exists('/usr/sbin/nginx') and + os.path.exists( + '/var/www/22222/htdocs/cache/opcache/opgui.php')): + try: + Log.info(self, "Cleaning opcache") + opgui = requests.get( + "https://127.0.0.1:22222/cache/opcache/opgui.php?reset=1") + if opgui.status_code != '200': + Log.warn(self, 'Cleaning opcache failed') + except Exception as e: + Log.debug(self, "{0}".format(e)) + Log.debug(self, "Unable hit url, " + " https://127.0.0.1:22222/cache/opcache/" + "opgui.php?reset=1," + " please check you have admin tools installed") + Log.debug(self, "please check you have admin tools installed," + " or install them with `wo stack install --admin`") + Log.error(self, "Unable to clean opcache", False) def load(app): diff --git a/wo/cli/plugins/site.py b/wo/cli/plugins/site.py index cb65342..cf49c15 100644 --- a/wo/cli/plugins/site.py +++ b/wo/cli/plugins/site.py @@ -733,8 +733,11 @@ class WOSiteCreateController(CementBaseController): Log.debug(self, "Going to issue Let's Encrypt certificate") acmedata = dict(acme_domains, dns=False, acme_dns='dns_cf', dnsalias=False, acme_alias='', keylength='') - acmedata['keylength'] = self.app.config.get('letsencrypt', - 'keylength') + if self.app.config.has_section('letsencrypt'): + acmedata['keylength'] = self.app.config.get( + 'letsencrypt', 'keylength') + else: + acmedata['keylength'] = 'ec-384' if pargs.dns: Log.debug(self, "DNS validation enabled") acmedata['dns'] = True @@ -813,11 +816,11 @@ class WOSiteCreateController(CementBaseController): if WOAcme.setupletsencrypt( self, acme_domains, acmedata): WOAcme.deploycert(self, wo_domain) - httpsRedirect(self, wo_domain, True, acme_wildcard) if pargs.hsts: SSL.setuphsts(self, wo_domain) + httpsRedirect(self, wo_domain, True, acme_wildcard) SSL.siteurlhttps(self, wo_domain) if not WOService.reload_service(self, 'nginx'): Log.error(self, "service nginx reload failed. " @@ -1594,7 +1597,7 @@ class WOSiteUpdateController(CementBaseController): "check issues with `nginx -t` command") updateSiteInfo(self, wo_domain, stype=stype, cache=cache, - ssl=True if check_site.is_ssl else False, + ssl=(bool(check_site.is_ssl)), php_version=check_php_version) Log.info(self, "Successfully updated site" @@ -1973,7 +1976,10 @@ class WOSiteDeleteController(CementBaseController): if wo_site_type in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']: wo_db_name = check_site.db_name wo_db_user = check_site.db_user - wo_mysql_grant_host = self.app.config.get('mysql', 'grant-host') + if self.app.config.has_section('mysql'): + wo_mysql_grant_host = self.app.config.get('mysql', 'grant-host') + else: + wo_mysql_grant_host = 'localhost' if wo_db_name == 'deleted': mark_db_deleted = True if pargs.all: diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index a592e7b..3cbdc1f 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -149,9 +149,15 @@ def setupdatabase(self, data): string.ascii_lowercase + string.digits, 24))) wo_replace_dot = wo_domain_name.replace('.', '') - prompt_dbname = self.app.config.get('mysql', 'db-name') - prompt_dbuser = self.app.config.get('mysql', 'db-user') - wo_mysql_grant_host = self.app.config.get('mysql', 'grant-host') + if self.app.config.has_section('mysql'): + prompt_dbname = self.app.config.get('mysql', 'db-name') + prompt_dbuser = self.app.config.get('mysql', 'db-user') + wo_mysql_grant_host = self.app.config.get('mysql', 'grant-host') + else: + prompt_dbname = False + prompt_dbuser = False + wo_mysql_grant_host = 'localhost' + wo_db_name = '' wo_db_username = '' wo_db_password = '' @@ -165,7 +171,7 @@ def setupdatabase(self, data): if not wo_db_name: wo_db_name = wo_replace_dot - wo_db_name = (wo_db_name[0:8] + generate_random()) + wo_db_name = (wo_db_name[0:16] + generate_random()) if prompt_dbuser == 'True' or prompt_dbuser == 'true': try: @@ -179,7 +185,7 @@ def setupdatabase(self, data): if not wo_db_username: wo_db_username = wo_replace_dot - wo_db_username = (wo_db_name[0:8] + generate_random()) + wo_db_username = (wo_db_name[0:12] + generate_random()) if not wo_db_password: wo_db_password = wo_random_pass @@ -189,8 +195,8 @@ def setupdatabase(self, data): try: if WOMysql.check_db_exists(self, wo_db_name): Log.debug(self, "Database already exists, Updating DB_NAME .. ") - wo_db_name = (wo_db_name[0:8] + generate_random()) - wo_db_username = (wo_db_name[0:8] + generate_random()) + wo_db_name = (wo_db_name[0:16] + generate_random()) + wo_db_username = (wo_db_name[0:12] + generate_random()) except MySQLConnectionError: raise SiteError("MySQL Connectivity problem occured") @@ -237,10 +243,16 @@ def setupdatabase(self, data): def setupwordpress(self, data, vhostonly=False): wo_domain_name = data['site_name'] wo_site_webroot = data['webroot'] - prompt_wpprefix = self.app.config.get('wordpress', 'prefix') - wo_wp_user = self.app.config.get('wordpress', 'user') - wo_wp_pass = self.app.config.get('wordpress', 'password') - wo_wp_email = self.app.config.get('wordpress', 'email') + if self.app.config.has_section('wordpress'): + prompt_wpprefix = self.app.config.get('wordpress', 'prefix') + wo_wp_user = self.app.config.get('wordpress', 'user') + wo_wp_pass = self.app.config.get('wordpress', 'password') + wo_wp_email = self.app.config.get('wordpress', 'email') + else: + prompt_wpprefix = False + wo_wp_user = '' + wo_wp_pass = '' + wo_wp_email = '' # Random characters wo_random_pass = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + @@ -380,10 +392,7 @@ def setupwordpress(self, data, vhostonly=False): for wp_conf in wp_conf_variables: wp_var = wp_conf[0] wp_val = wp_conf[1] - if wp_val == 'true' or wp_val == 'false': - var_raw = True - else: - var_raw = False + var_raw = (bool(wp_val == 'true' or wp_val == 'false')) try: WOShellExec.cmd_exec( self, "/bin/bash -c \"{0} --allow-root " @@ -1195,7 +1204,7 @@ def generate_random_pass(): def generate_random(): wo_random10 = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + - string.digits, 8))) + string.digits, 4))) return wo_random10 diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 0efd01c..797fae5 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -124,7 +124,7 @@ class WOStackController(CementBaseController): (not pargs.cheat) and (not pargs.nanorc) and (not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.phpredisadmin) and (not pargs.sendmail) and - (not pargs.php73)): + (not pargs.php73) and (not pargs.all)): pargs.web = True pargs.admin = True pargs.fail2ban = True @@ -563,7 +563,7 @@ class WOStackController(CementBaseController): (not pargs.cheat) and (not pargs.nanorc) and (not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.phpredisadmin) and (not pargs.sendmail) and - (not pargs.php73)): + (not pargs.php73) and (not pargs.all)): self.app.args.print_help() if pargs.all: @@ -849,7 +849,7 @@ class WOStackController(CementBaseController): (not pargs.cheat) and (not pargs.nanorc) and (not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.phpredisadmin) and (not pargs.sendmail) and - (not pargs.php73)): + (not pargs.php73) and (not pargs.all)): self.app.args.print_help() if pargs.all: diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index c1bf59b..a387cea 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -29,9 +29,9 @@ def pre_pref(self, apt_packages): # add mariadb repository excepted on raspbian and ubuntu 19.04 if (not WOVar.wo_distro == 'raspbian'): Log.info(self, "Adding repository for MySQL, please wait...") - mysql_pref = ("Package: *\nPin: origin " - "sfo1.mirrors.digitalocean.com" - "\nPin-Priority: 1000\n") + mysql_pref = ( + "Package: *\nPin: origin mariadb.mirrors.ovh.net" + "\nPin-Priority: 1000\n") with open('/etc/apt/preferences.d/' 'MariaDB.pref', 'w') as mysql_pref_file: mysql_pref_file.write(mysql_pref) @@ -215,25 +215,24 @@ def post_pref(self, apt_packages, packages, upgrade=False): self, '{0}/upstream.conf'.format(ngxcnf), 'upstream.mustache', data, overwrite=True) - data = dict(phpconf=True if - WOAptGet.is_installed(self, 'php7.2-fpm') - else False) - WOTemplate.deploy(self, - '{0}/stub_status.conf'.format(ngxcnf), - 'stub_status.mustache', data) + data = dict(phpconf=( + bool(WOAptGet.is_installed(self, 'php7.2-fpm')))) + WOTemplate.deploy( + self, '{0}/stub_status.conf'.format(ngxcnf), + 'stub_status.mustache', data) data = dict() - WOTemplate.deploy(self, - '{0}/webp.conf'.format(ngxcnf), - 'webp.mustache', data, overwrite=False) + WOTemplate.deploy( + self, '{0}/webp.conf'.format(ngxcnf), + 'webp.mustache', data, overwrite=False) - WOTemplate.deploy(self, - '{0}/cloudflare.conf'.format(ngxcnf), - 'cloudflare.mustache', data) + WOTemplate.deploy( + self, '{0}/cloudflare.conf'.format(ngxcnf), + 'cloudflare.mustache', data) - WOTemplate.deploy(self, - '{0}/map-wp-fastcgi-cache.conf'.format( - ngxcnf), - 'map-wp.mustache', data) + WOTemplate.deploy( + self, + '{0}/map-wp-fastcgi-cache.conf'.format(ngxcnf), + 'map-wp.mustache', data) except CommandExecutionError as e: Log.debug(self, "{0}".format(e)) @@ -1401,13 +1400,14 @@ def post_pref(self, apt_packages, packages, upgrade=False): Log.debug(self, "{0}".format(e)) Log.error(self, "failed to configure Anemometer", exit=False) - + if self.app.config.has_section('mysql'): + wo_grant_host = self.app.config.get('mysql', 'grant-host') + else: + wo_grant_host = 'localhost' WOMysql.execute(self, 'grant select on' ' *.* to \'anemometer\'' '@\'{0}\' IDENTIFIED' - ' BY \'{1}\''.format(self.app.config.get - ('mysql', - 'grant-host'), + ' BY \'{1}\''.format(wo_grant_host, chars)) Log.debug(self, "grant all on slow-query-log.*" " to anemometer@root_user" @@ -1447,25 +1447,35 @@ def post_pref(self, apt_packages, packages, upgrade=False): def pre_stack(self): """Inital server configuration and tweak""" - # wo sysctl tweaks - # check system type - wo_arch = os.uname()[4] - if os.path.isfile('/proc/1/environ'): - # detect lxc containers - wo_lxc = WOFileUtils.grepcheck( - self, '/proc/1/environ', 'container=lxc') - # detect wsl - wo_wsl = WOFileUtils.grepcheck( - self, '/proc/1/environ', 'wsl') - else: - wo_wsl = True - wo_lxc = True # remove old sysctl tweak if os.path.isfile('/etc/sysctl.d/60-ubuntu-nginx-web-server.conf'): - WOFileUtils.rm(self, '/etc/sysctl.d/60-ubuntu-nginx-web-server.conf') + WOFileUtils.rm( + self, '/etc/sysctl.d/60-ubuntu-nginx-web-server.conf') + # check if version.txt exist + if os.path.exists('/var/lib/wo/version.txt'): + with open('/var/lib/wo/version.txt', + mode='r', encoding='utf-8') as wo_ver: + # check version written in version.txt + wo_check = bool(wo_ver.read().strip() == + '{0}'.format(WOVar.wo_version)) + else: + wo_check = False + if wo_check is False: + # wo sysctl tweaks + # check system type + wo_arch = bool(os.uname()[4] == 'x86_x64') + if os.path.isfile('/proc/1/environ'): + # detect lxc containers + wo_lxc = WOFileUtils.grepcheck( + self, '/proc/1/environ', 'container=lxc') + # detect wsl + wo_wsl = WOFileUtils.grepcheck( + self, '/proc/1/environ', 'wsl') + else: + wo_wsl = True + wo_lxc = True - if wo_arch == 'x86_64': - if (wo_lxc is not True) and (wo_wsl is not True): + if (wo_lxc is not True) and (wo_wsl is not True) and (wo_arch is True): data = dict() WOTemplate.deploy( self, '/etc/sysctl.d/60-wo-tweaks.conf', @@ -1474,58 +1484,74 @@ def pre_stack(self): if (WOVar.wo_platform_codename == 'bionic' or WOVar.wo_platform_codename == 'disco' or WOVar.wo_platform_codename == 'buster'): - if WOShellExec.cmd_exec(self, 'modprobe tcp_bbr'): - with open("/etc/modules-load.d/bbr.conf", - encoding='utf-8', mode='w') as bbr_file: + try: + WOShellExec.cmd_exec( + self, 'modprobe tcp_bbr') + with open( + "/etc/modules-load.d/bbr.conf", + encoding='utf-8', mode='w') as bbr_file: bbr_file.write('tcp_bbr') - with open("/etc/sysctl.d/60-wo-tweaks.conf", - encoding='utf-8', mode='a') as sysctl_file: + with open( + "/etc/sysctl.d/60-wo-tweaks.conf", + encoding='utf-8', mode='a') as sysctl_file: sysctl_file.write( '\nnet.ipv4.tcp_congestion_control = bbr' '\nnet.ipv4.tcp_notsent_lowat = 16384') + except OSError as e: + Log.debug(self, str(e)) + Log.warn(self, "failed to tweak sysctl") else: - if WOShellExec.cmd_exec(self, 'modprobe tcp_htcp'): - with open("/etc/modules-load.d/htcp.conf", - encoding='utf-8', mode='w') as bbr_file: + try: + WOShellExec.cmd_exec( + self, 'modprobe tcp_htcp') + with open( + "/etc/modules-load.d/htcp.conf", + encoding='utf-8', mode='w') as bbr_file: bbr_file.write('tcp_htcp') - with open("/etc/sysctl.d/60-wo-tweaks.conf", - encoding='utf-8', mode='a') as sysctl_file: + with open( + "/etc/sysctl.d/60-wo-tweaks.conf", + encoding='utf-8', mode='a') as sysctl_file: sysctl_file.write( '\nnet.ipv4.tcp_congestion_control = htcp') + except OSError as e: + Log.debug(self, str(e)) + Log.warn(self, "failed to tweak sysctl") + # apply sysctl tweaks WOShellExec.cmd_exec( self, 'sysctl -eq -p /etc/sysctl.d/60-wo-tweaks.conf') - # sysctl tweak service - data = dict() - if not os.path.isfile('/opt/wo-kernel.sh'): - WOTemplate.deploy(self, '/opt/wo-kernel.sh', - 'wo-kernel-script.mustache', data) - if not os.path.isfile('/lib/systemd/system/wo-kernel.service'): - WOTemplate.deploy( - self, '/lib/systemd/system/wo-kernel.service', - 'wo-kernel-service.mustache', data) - WOShellExec.cmd_exec(self, 'systemctl enable wo-kernel.service') - WOService.start_service(self, 'wo-kernel') - # open_files_limit tweak - if not WOFileUtils.grepcheck(self, '/etc/security/limits.conf', '500000'): - with open("/etc/security/limits.conf", - encoding='utf-8', mode='w') as limit_file: - limit_file.write( - '* hard nofile 500000\n' - '* soft nofile 500000\n' - 'root hard nofile 500000\n' - 'root soft nofile 500000\n') - # custom motd-news - data = dict() - # check if update-motd.d directory exist - if os.path.isdir('/etc/update-motd.d/'): - if not os.path.isfile('/etc/update-motd.d/98-wo-update'): + + # sysctl tweak service + data = dict() + if not os.path.isfile('/opt/wo-kernel.sh'): + WOTemplate.deploy(self, '/opt/wo-kernel.sh', + 'wo-kernel-script.mustache', data) + if not os.path.isfile('/lib/systemd/system/wo-kernel.service'): + WOTemplate.deploy( + self, '/lib/systemd/system/wo-kernel.service', + 'wo-kernel-service.mustache', data) + WOShellExec.cmd_exec(self, 'systemctl enable wo-kernel.service') + WOService.start_service(self, 'wo-kernel') + # open_files_limit tweak + if not WOFileUtils.grepcheck(self, + '/etc/security/limits.conf', '500000'): + with open("/etc/security/limits.conf", + encoding='utf-8', mode='a') as limit_file: + limit_file.write( + '* hard nofile 500000\n' + '* soft nofile 500000\n' + 'root hard nofile 500000\n' + 'root soft nofile 500000\n') + # custom motd-news + data = dict() + # check if update-motd.d directory exist + if os.path.isdir('/etc/update-motd.d/'): # render custom motd template WOTemplate.deploy( self, '/etc/update-motd.d/98-wo-update', 'wo-update.mustache', data) WOFileUtils.chmod( self, "/etc/update-motd.d/98-wo-update", 0o755) - # restart motd-news service if available - if os.path.isfile('/lib/systemd/system/motd-news.service'): - WOService.restart_service(self, 'motd-news') + with open('/var/lib/wo/version.txt', + mode='w', encoding='utf-8') as wo_ver: + wo_ver.write('{0}'.format(WOVar.wo_version)) diff --git a/wo/cli/plugins/update.py b/wo/cli/plugins/update.py index 879ec56..7991e7b 100644 --- a/wo/cli/plugins/update.py +++ b/wo/cli/plugins/update.py @@ -65,9 +65,10 @@ class WOUpdateController(CementBaseController): wo_current = ("v{0}".format(WOVar.wo_version)) wo_latest = WODownload.latest_release(self, "WordOps/WordOps") if wo_current == wo_latest: - Log.error( + Log.info( self, "WordOps {0} is already installed" .format(wo_latest)) + self.app.close(0) if not os.path.isdir('/var/lib/wo/tmp'): os.makedirs('/var/lib/wo/tmp') diff --git a/wo/cli/templates/my.mustache b/wo/cli/templates/my.mustache index 5fec5ca..cbb14b6 100644 --- a/wo/cli/templates/my.mustache +++ b/wo/cli/templates/my.mustache @@ -53,7 +53,7 @@ max_connections = 100 connect_timeout = 5 wait_timeout = 60 max_allowed_packet = 64M -thread_cache_size = 128 +thread_cache_size = 128 sort_buffer_size = 4M bulk_insert_buffer_size = 16M tmp_table_size = {{tmp_table_size}}M diff --git a/wo/cli/templates/wpcommon.mustache b/wo/cli/templates/wpcommon.mustache index d9a3cd0..fdf2ad2 100644 --- a/wo/cli/templates/wpcommon.mustache +++ b/wo/cli/templates/wpcommon.mustache @@ -47,7 +47,7 @@ location /wp-content/uploads { expires max; try_files $uri$webp_suffix $uri =404; } - location ~* \.(php|gz|log|zip|tar|rar)$ { + location ~* \.(php|gz|log|zip|tar|rar|xz)$ { #Prevent Direct Access Of PHP Files & BackupsFrom Web Browsers deny all; } @@ -64,7 +64,7 @@ location /wp-content/plugins/ewww-image-optimizer/images { try_files $uri$webp_suffix $uri =404; } location ~ \.php$ { -#Prevent Direct Access Of PHP Files From Web Browsers + #Prevent Direct Access Of PHP Files From Web Browsers deny all; } } diff --git a/wo/core/acme.py b/wo/core/acme.py index 883559b..4c6434d 100644 --- a/wo/core/acme.py +++ b/wo/core/acme.py @@ -58,7 +58,8 @@ class WOAcme: if acmedata['dns'] is True: Log.error( self, "Please make sure your properly " - "set your DNS API credentials for acme.sh") + "set your DNS API credentials for acme.sh\n" + "If you are using sudo, use \"sudo -E wo\"") return False else: Log.error( @@ -145,10 +146,19 @@ class WOAcme: def check_dns(self, acme_domains): """Check if a list of domains point to the server IP""" - server_ip = requests.get('http://v4.wordops.eu/').text + server_ip = requests.get('https://v4.wordops.eu/').text for domain in acme_domains: - domain_ip = requests.get('http://v4.wordops.eu/dns/{0}/' - .format(domain)).text + url = ( + "https://cloudflare-dns.com/dns-query?name={0}&type=A" + .format(domain)) + headers = { + 'accept': 'application/dns-json' + } + try: + response = requests.get(url, headers=headers).json() + domain_ip = response["Answer"][0]['data'] + except requests.RequestException: + Log.error(self, 'Resolving domain IP failed') if(not domain_ip == server_ip): Log.warn( self, "{0}".format(domain) + diff --git a/wo/core/addswap.py b/wo/core/addswap.py index 04dcfd1..0741917 100644 --- a/wo/core/addswap.py +++ b/wo/core/addswap.py @@ -38,10 +38,10 @@ class WOSwap(): WOFileUtils.searchreplace(self, "/etc/dphys-swapfile", "#CONF_SWAPFILE=/var/swap", "CONF_SWAPFILE=/wo-swapfile") - WOFileUtils.searchreplace(self, "/etc/dphys-swapfile", + WOFileUtils.searchreplace(self, "/etc/dphys-swapfile", "#CONF_MAXSWAP=2048", "CONF_MAXSWAP=1024") - WOFileUtils.searchreplace(self, "/etc/dphys-swapfile", + WOFileUtils.searchreplace(self, "/etc/dphys-swapfile", "#CONF_SWAPSIZE=", "CONF_SWAPSIZE=1024") else: diff --git a/wo/core/services.py b/wo/core/services.py index 1c59e63..33ac4b6 100644 --- a/wo/core/services.py +++ b/wo/core/services.py @@ -87,11 +87,11 @@ class WOService(): output, error_output = sub.communicate() if 'emerg' not in str(error_output): Log.valide(self, "Testing Nginx configuration ") - Log.wait(self, "Restarting Nginx ") + Log.wait(self, "Restarting Nginx") service_cmd = ('service {0} restart'.format(service_name)) retcode = subprocess.getstatusoutput(service_cmd) if retcode[0] == 0: - Log.valide(self, "Restarting Nginx ") + Log.valide(self, "Restarting Nginx") return True else: Log.failed(self, "Testing Nginx configuration ") diff --git a/wo/core/variables.py b/wo/core/variables.py index 437caec..dad38e2 100644 --- a/wo/core/variables.py +++ b/wo/core/variables.py @@ -14,7 +14,7 @@ class WOVar(): """Intialization of core variables""" # WordOps version - wo_version = "3.10.2" + wo_version = "3.10.3" # WordOps packages versions wo_wp_cli = "2.3.0" wo_adminer = "4.7.3" @@ -170,15 +170,16 @@ class WOVar(): wo_clamav = ["clamav", "clamav-freshclam"] wo_ubuntu_backports = 'ppa:jonathonf/backports' - # Redis repo details + # APT repositories + wo_mysql_repo = ("deb [arch=amd64,ppc64el] " + "http://mariadb.mirrors.ovh.net/MariaDB/repo/" + "10.3/{distro} {codename} main" + .format(distro=wo_distro, + codename=wo_platform_codename)) if wo_distro == 'ubuntu': wo_php_repo = "ppa:ondrej/php" wo_redis_repo = ("ppa:chris-lea/redis-server") wo_goaccess_repo = ("ppa:alex-p/goaccess") - wo_mysql_repo = ("deb [arch=amd64,ppc64el] " - "http://mariadb.mirrors.ovh.net/MariaDB/repo/" - "10.3/ubuntu {codename} main" - .format(codename=wo_platform_codename)) else: wo_php_repo = ( @@ -187,10 +188,6 @@ class WOVar(): wo_php_key = 'AC0E47584A7A714D' wo_redis_repo = ("deb https://packages.sury.org/php/ {codename} all" .format(codename=wo_platform_codename)) - wo_mysql_repo = ("deb [arch=amd64,ppc64el] " - "http://mariadb.mirrors.ovh.net/MariaDB/repo/" - "10.3/debian {codename} main" - .format(codename=wo_platform_codename)) wo_redis = ['redis-server'] diff --git a/wo/utils/test.py b/wo/utils/test.py index 920fd62..8d323a2 100644 --- a/wo/utils/test.py +++ b/wo/utils/test.py @@ -1,9 +1,9 @@ """Testing utilities for WordOps""" -from cement.utils.test import * +from cement.utils import test from wo.cli.main import WOTestApp -class WOTestCase(CementTestCase): +class WOTestCase(test.CementTestCase): app_class = WOTestApp def setUp(self):