From 9459db9712f646bb7128fd3062a54ee4ae4693f9 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 21 Aug 2023 16:17:24 +0200 Subject: [PATCH 1/7] Fix netdata conf path --- wo/cli/plugins/stack_pref.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index b49b3fe..3647fb4 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -1175,10 +1175,11 @@ def post_pref(self, apt_packages, packages, upgrade=False): 'SEND_EMAIL="YES"', 'SEND_EMAIL="NO"') - WOFileUtils.searchreplace( - self, "{0}etc/netdata/orig/health_alarm_notify.conf", - 'SEND_EMAIL="YES"', - 'SEND_EMAIL="NO"') + if os.path.isdir('/etc/netdata/orig/health_alarm_notify.conf'): + WOFileUtils.searchreplace( + self, "/etc/netdata/orig/health_alarm_notify.conf", + 'SEND_EMAIL="YES"', + 'SEND_EMAIL="NO"') # check if mysql credentials are available if WOShellExec.cmd_exec(self, "mysqladmin ping"): try: From d393cb06498492277fa782827dfdc2993d3a4b43 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 5 Aug 2023 12:07:10 +0200 Subject: [PATCH 2/7] Revert "Refactor site detection" This reverts commit 4b71b4e679a645c9295eb8ce33f0166753394ba8. --- wo/cli/plugins/site_functions.py | 273 ++++++++++++++++++++++++++++--- 1 file changed, 251 insertions(+), 22 deletions(-) diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index 893f776..7af1f50 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -1076,39 +1076,268 @@ def detSitePar(opts): 2. raises RuntimeError when wrong combination is used like "--wp --wpsubdir" or "--html --wp" """ - # Initialize sitetype and cachetype sitetype, cachetype = '', '' - - # Initialize type and cache lists typelist = list() cachelist = list() - - # Populate type and cache lists based on opts for key, val in opts.items(): if val and key in ['html', 'php', 'mysql', 'wp', - 'wpsubdir', 'wpsubdomain', - 'php72', 'php73', 'php74', - 'php80', 'php81', 'php82']: + 'wpsubdir', 'wpsubdomain', 'php72', + 'php73', 'php74', 'php80', 'php81', 'php82', ]: typelist.append(key) elif val and key in ['wpfc', 'wpsc', 'wpredis', 'wprocket', 'wpce']: cachelist.append(key) - # Determine sitetype and cachetype if len(typelist) > 1 or len(cachelist) > 1: - raise RuntimeError( - "Could not determine site or cache type. " - "Multiple types or caches entered.") - - # If no type or cache specified, set to None - if not typelist and not cachelist: - sitetype = None - cachetype = None + if len(cachelist) > 1: + raise RuntimeError( + "Could not determine cache type." + "Multiple cache parameter entered") + elif False not in [x in ('php', 'mysql', 'html') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php72', 'mysql', 'html') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php73', 'mysql', 'html') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php74', 'mysql', 'html') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php80', 'mysql', 'html') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php81', 'mysql', 'html') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php82', 'mysql', 'html') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php', 'mysql') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php72', 'mysql') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php73', 'mysql') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php74', 'mysql') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php80', 'mysql') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php81', 'mysql') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php82', 'mysql') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('html', 'mysql') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('php', 'html') for x in typelist]: + sitetype = 'php' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wp', 'wpsubdir') for x in typelist]: + sitetype = 'wpsubdir' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wp', 'wpsubdomain') for x in typelist]: + sitetype = 'wpsubdomain' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wp', 'php72') for x in typelist]: + sitetype = 'wp' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wp', 'php73') for x in typelist]: + sitetype = 'wp' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wp', 'php74') for x in typelist]: + sitetype = 'wp' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wp', 'php80') for x in typelist]: + sitetype = 'wp' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wp', 'php81') for x in typelist]: + sitetype = 'wp' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wp', 'php82') for x in typelist]: + sitetype = 'wp' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdir', 'php72') for x in typelist]: + sitetype = 'wpsubdir' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdir', 'php73') for x in typelist]: + sitetype = 'wpsubdir' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdir', 'php74') for x in typelist]: + sitetype = 'wpsubdir' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdir', 'php80') for x in typelist]: + sitetype = 'wpsubdir' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdir', 'php81') for x in typelist]: + sitetype = 'wpsubdir' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdir', 'php82') for x in typelist]: + sitetype = 'wpsubdir' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdomain', 'php72') for x in typelist]: + sitetype = 'wpsubdomain' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdomain', 'php73') for x in typelist]: + sitetype = 'wpsubdomain' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdomain', 'php74') for x in typelist]: + sitetype = 'wpsubdomain' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdomain', 'php80') for x in typelist]: + sitetype = 'wpsubdomain' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdomain', 'php81') for x in typelist]: + sitetype = 'wpsubdomain' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + elif False not in [x in ('wpsubdomain', 'php82') for x in typelist]: + sitetype = 'wpsubdomain' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] + else: + raise RuntimeError("could not determine site and cache type") else: - # Use the first specified type or 'wp' if not specified - sitetype = typelist[0] if typelist else 'wp' - - # Use the first specified cache or 'basic' if not specified - cachetype = cachelist[0] if cachelist else 'basic' + if not typelist and not cachelist: + sitetype = None + cachetype = None + elif (not typelist or "php72" in typelist) and cachelist: + sitetype = 'wp' + cachetype = cachelist[0] + elif (not typelist or "php73" in typelist) and cachelist: + sitetype = 'wp' + cachetype = cachelist[0] + elif (not typelist or "php74" in typelist) and cachelist: + sitetype = 'wp' + cachetype = cachelist[0] + elif (not typelist or "php80" in typelist) and cachelist: + sitetype = 'wp' + cachetype = cachelist[0] + elif (not typelist or "php81" in typelist) and cachelist: + sitetype = 'wp' + cachetype = cachelist[0] + elif (not typelist or "php82" in typelist) and cachelist: + sitetype = 'wp' + cachetype = cachelist[0] + elif typelist and (not cachelist): + sitetype = typelist[0] + cachetype = 'basic' + else: + sitetype = typelist[0] + cachetype = cachelist[0] return (sitetype, cachetype) From 1487a8c8d440ee13681cd1c3a01eb7bf7dc8e884 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 26 Aug 2023 14:18:45 +0200 Subject: [PATCH 3/7] Fix php conf --- wo/cli/plugins/stack_pref.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index 3647fb4..af5871d 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -474,7 +474,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): # php conf php_list = [] for version in list(WOVar.wo_php_versions.values()): - package_name = 'php' + version.replace('.', '') + '-fpm' + package_name = 'php' + version + '-fpm' if package_name in apt_packages: php_list.append([version]) From 36d70b4ff9addf098437128efb71fd8d6b4313b3 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 26 Aug 2023 14:33:59 +0200 Subject: [PATCH 4/7] Fix wo stack install --- wo/cli/plugins/stack.py | 14 +++++++------- wo/cli/plugins/stack_pref.py | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 77fe1d3..6fd38b1 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -119,13 +119,6 @@ class WOStackController(CementBaseController): pargs.admin = True pargs.fail2ban = True - if pargs.php: - if self.app.config.has_section('php'): - config_php_ver = self.app.config.get( - 'php', 'version') - current_php = config_php_ver.replace(".", "") - setattr(self.app.pargs, 'php{0}'.format(current_php), True) - if pargs.mariadb: pargs.mysql = True @@ -165,6 +158,13 @@ class WOStackController(CementBaseController): pargs.clamav = True pargs.ngxblocker = True + if pargs.php: + if self.app.config.has_section('php'): + config_php_ver = self.app.config.get( + 'php', 'version') + current_php = config_php_ver.replace(".", "") + setattr(self.app.pargs, 'php{0}'.format(current_php), True) + # Nginx if pargs.nginx: Log.debug(self, "Setting apt_packages variable for Nginx") diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index af5871d..40c48bc 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -791,7 +791,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): if os.path.exists('/etc/fail2ban'): WOGit.add(self, ["/etc/fail2ban"], msg="Adding Fail2ban into Git") - Log.info(self, "Configuring Fail2Ban") + Log.wait(self, "Configuring Fail2Ban") nginxf2b = bool(os.path.exists('/var/log/nginx')) data = dict(release=WOVar.wo_version, nginx=nginxf2b) WOTemplate.deploy( @@ -815,6 +815,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): self, ['/etc/fail2ban'], msg="Rollback f2b config") WOService.restart_service(self, 'fail2ban') else: + Log.valide(self, "Configuring Fail2Ban") WOGit.add(self, ["/etc/fail2ban"], msg="Adding Fail2ban into Git") From 9c66cd751aac5b5702a00d5aa8cec095f7b36532 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 26 Aug 2023 15:27:02 +0200 Subject: [PATCH 5/7] Improve log display --- wo/cli/plugins/stack_pref.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index 40c48bc..531770f 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -154,7 +154,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): if (apt_packages): # Nginx configuration if set(WOVar.wo_nginx).issubset(set(apt_packages)): - Log.info(self, "Applying Nginx configuration templates") + Log.wait(self, "Configuring Nginx") # Nginx main configuration ngxcnf = '/etc/nginx/conf.d' ngxcom = '/etc/nginx/common' @@ -458,6 +458,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): "Use the command nginx -t to identify " "the cause of this issue", False) else: + Log.valide(self, "Configuring Nginx") WOGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git") if not os.path.isdir('/etc/systemd/system/nginx.service.d'): WOFileUtils.mkdir(self, @@ -480,7 +481,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): for php_version in php_list: WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") - Log.info(self, "Configuring php{0}-fpm".format(php_version[0])) + Log.wait(self, "Configuring php{0}-fpm".format(php_version[0])) ngxroot = '/var/www/' # Create log directories @@ -653,6 +654,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): .format(php_version[0])): WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP") else: + Log.valide(self, "Configuring php{0}-fpm".format(php_version[0])) WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") if os.path.exists('/etc/nginx/conf.d/upstream.conf'): From 80528ce26ac15e736a7d1107e1e9a0f01fb866ae Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 26 Aug 2023 15:32:07 +0200 Subject: [PATCH 6/7] Add proxy site and alias to CI --- tests/travis.sh | 56 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/tests/travis.sh b/tests/travis.sh index 24155f9..99902f5 100644 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -68,7 +68,41 @@ for site in $site_types; do fi done echo +echo echo -e "${CGREEN}#############################################${CEND}" +echo -e ' Proxy site create ' +echo -e "${CGREEN}#############################################${CEND}" +echo +if { + wo site create proxy.net --proxy=127.0.0.1:3000 +} >>/var/log/wo/test.log; then + echo -ne " Creating proxy.net [${CGREEN}OK${CEND}]\\r" + echo -ne '\n' +else + echo -e " Creating proxy.net [${CRED}FAIL${CEND}]" + echo -ne '\n' + exit_script +fi +echo +echo +echo +echo -e "${CGREEN}#############################################${CEND}" +echo -e ' Alias site create ' +echo -e "${CGREEN}#############################################${CEND}" +echo +if { + wo site create alias.net --alias anothersite.net +} >>/var/log/wo/test.log; then + echo -ne " Creating alias.net [${CGREEN}OK${CEND}]\\r" + echo -ne '\n' +else + echo -e " Creating alias.net [${CRED}FAIL${CEND}]" + echo -ne '\n' + exit_script +fi +echo +echo -e "${CGREEN}#############################################${CEND}" +echo echo wo site info php.net echo @@ -300,18 +334,18 @@ echo -e "${CGREEN}#############################################${CEND}" echo -e ' wo stack migrate --mariadb ' echo -e "${CGREEN}#############################################${CEND}" - echo -ne " Upgrading mariadb [..]\r" - if { - wo stack migrate --mariadb --force --ci - } >>/var/log/wo/test.log; then - echo -ne " Upgrading mariadb [${CGREEN}OK${CEND}]\\r" - echo -ne '\n' - else - echo -e " Upgrading mariadb [${CRED}FAIL${CEND}]" - echo -ne '\n' - exit_script +echo -ne " Upgrading mariadb [..]\r" +if { + wo stack migrate --mariadb --force --ci +} >>/var/log/wo/test.log; then + echo -ne " Upgrading mariadb [${CGREEN}OK${CEND}]\\r" + echo -ne '\n' +else + echo -e " Upgrading mariadb [${CRED}FAIL${CEND}]" + echo -ne '\n' + exit_script - fi +fi echo -e "${CGREEN}#############################################${CEND}" echo -e ' wo clean ' From 5fe5f55ea039451d3d900a25f45b688e6d9c3a5d Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 26 Aug 2023 15:38:49 +0200 Subject: [PATCH 7/7] Update proftpd umask to avoid permission issues --- wo/cli/templates/proftpd.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wo/cli/templates/proftpd.mustache b/wo/cli/templates/proftpd.mustache index d708a69..7c36b8b 100644 --- a/wo/cli/templates/proftpd.mustache +++ b/wo/cli/templates/proftpd.mustache @@ -73,7 +73,7 @@ Group nogroup # Umask 022 is a good standard umask to prevent new files and dirs # (second parm) from being group and world writable. -Umask 022 022 +Umask 002 002 # Normally, we want files to be overwriteable. AllowOverwrite on