From 717cdf8542a5f2c43b8abb99a49d403d985d25eb Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 6 Aug 2023 08:38:10 +0200 Subject: [PATCH 1/9] Refactor site create --- wo/cli/plugins/site_create.py | 79 ++++++++--------------------------- wo/cli/plugins/sitedb.py | 2 +- 2 files changed, 19 insertions(+), 62 deletions(-) diff --git a/wo/cli/plugins/site_create.py b/wo/cli/plugins/site_create.py index 4be9bd2..836ff94 100644 --- a/wo/cli/plugins/site_create.py +++ b/wo/cli/plugins/site_create.py @@ -218,57 +218,27 @@ class WOSiteCreateController(CementBaseController): else: pass - data['php73'] = False - data['php74'] = False - data['php72'] = False - data['php80'] = False - data['php81'] = False - data['php82'] = False - - if data and pargs.php73: - data['php73'] = True - data['wo_php'] = 'php73' - elif data and pargs.php74: - data['php74'] = True - data['wo_php'] = 'php74' - elif data and pargs.php72: - data['php72'] = True - data['wo_php'] = 'php72' - elif data and pargs.php80: - data['php80'] = True - data['wo_php'] = 'php80' - elif data and pargs.php81: - data['php81'] = True - data['wo_php'] = 'php81' - elif data and pargs.php82: - data['php82'] = True - data['wo_php'] = 'php82' + # Initialize all PHP versions to False + for version in WOVar.wo_php_versions: + data[version] = False + # Check for PHP versions in pargs + for pargs_version, version in WOVar.wo_php_versions.items(): + if data and getattr(pargs, pargs_version, False): + data[pargs_version] = True + data['wo_php'] = pargs_version + php_version = version + break else: if self.app.config.has_section('php'): - config_php_ver = self.app.config.get( - 'php', 'version') - if config_php_ver == '7.2': - data['php72'] = True - data['wo_php'] = 'php72' - elif config_php_ver == '7.3': - data['php73'] = True - data['wo_php'] = 'php73' - elif config_php_ver == '7.4': - data['php74'] = True - data['wo_php'] = 'php74' - elif config_php_ver == '8.0': - data['php80'] = True - data['wo_php'] = 'php80' - elif config_php_ver == '8.1': - data['php81'] = True - data['wo_php'] = 'php81' - elif config_php_ver == '8.2': - data['php82'] = True - data['wo_php'] = 'php82' - else: - data['php73'] = True - data['wo_php'] = 'php73' + config_php_ver = self.app.config.get('php', 'version') + + for wo_key, php_ver in WOVar.wo_php_versions.items(): + if php_ver == config_php_ver: + data[wo_key] = True + data['wo_php'] = wo_key + php_version = php_ver + break if ((not pargs.wpfc) and (not pargs.wpsc) and (not pargs.wprocket) and @@ -331,19 +301,6 @@ class WOSiteCreateController(CementBaseController): " http://{0}".format(wo_domain)) return - if data['php72']: - php_version = "7.2" - elif data['php74']: - php_version = "7.4" - elif data['php80']: - php_version = "8.0" - elif data['php81']: - php_version = "8.1" - elif data['php82']: - php_version = "8.2" - else: - php_version = "7.3" - addNewSite(self, wo_domain, stype, cache, wo_site_webroot, php_version=php_version) diff --git a/wo/cli/plugins/sitedb.py b/wo/cli/plugins/sitedb.py index 2ed7aa2..4814f0d 100644 --- a/wo/cli/plugins/sitedb.py +++ b/wo/cli/plugins/sitedb.py @@ -11,7 +11,7 @@ from wo.core.logging import Log def addNewSite(self, site, stype, cache, path, enabled=True, ssl=False, fs='ext4', db='mysql', db_name=None, db_user=None, db_password=None, - db_host='localhost', hhvm=0, php_version='7.2'): + db_host='localhost', hhvm=0, php_version='8.1'): """ Add New Site record information into the wo database. """ From 7e48b1883741c063c9077cb8d00d2ef790fe27fc Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 6 Aug 2023 12:55:26 +0200 Subject: [PATCH 2/9] Add wo site create --alias --- wo/cli/plugins/site_create.py | 43 ++++++++++++++++++++++++++- wo/cli/templates/virtualconf.mustache | 10 +++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/wo/cli/plugins/site_create.py b/wo/cli/plugins/site_create.py index 836ff94..ffc990b 100644 --- a/wo/cli/plugins/site_create.py +++ b/wo/cli/plugins/site_create.py @@ -73,6 +73,9 @@ class WOSiteCreateController(CementBaseController): dict(help="create WordPress single/multi site " "with redis cache", action='store_true')), + (['--alias'], + dict(help="domain name to redirect to", + action='store', nargs='?')), (['-le', '--letsencrypt'], dict(help="configure letsencrypt ssl for the site", action='store' or 'store_const', @@ -129,10 +132,17 @@ class WOSiteCreateController(CementBaseController): proxyinfo = proxyinfo.split(':') host = proxyinfo[0].strip() port = '80' if len(proxyinfo) < 2 else proxyinfo[1].strip() - elif stype is None and not pargs.proxy: + elif stype is None and not pargs.proxy and not pargs.alias: stype, cache = 'html', 'basic' + elif stype is None and pargs.alias: + stype, cache = 'alias', '' + alias_name = pargs.alias.strip() + if not alias_name: + Log.error(self, "Please provide alias name") elif stype and pargs.proxy: Log.error(self, "proxy should not be used with other site types") + elif stype and pargs.alias: + Log.error(self, "alias should not be used with other site types") if not pargs.site_name: try: @@ -173,6 +183,16 @@ class WOSiteCreateController(CementBaseController): data['port'] = port data['basic'] = True + if stype == 'alias': + data = dict( + site_name=wo_domain, www_domain=wo_www_domain, + static=True, basic=False, wp=False, + wpfc=False, wpsc=False, wprocket=False, wpce=False, + multisite=False, wpsubdir=False, webroot=wo_site_webroot) + data['alias'] = True + data['alias_name'] = alias_name + data['basic'] = True + if (pargs.php72 or pargs.php73 or pargs.php74 or pargs.php80 or pargs.php81 or pargs.php82): data = dict( @@ -301,6 +321,27 @@ class WOSiteCreateController(CementBaseController): " http://{0}".format(wo_domain)) return + if 'alias' in data.keys() and data['alias']: + addNewSite(self, wo_domain, stype, cache, wo_site_webroot) + # Service Nginx Reload + if not WOService.reload_service(self, 'nginx'): + Log.info(self, Log.FAIL + + "There was a serious error encountered...") + Log.info(self, Log.FAIL + "Cleaning up afterwards...") + doCleanupAction(self, domain=wo_domain) + deleteSiteInfo(self, wo_domain) + Log.error(self, "service nginx reload failed. " + "check issues with `nginx -t` command") + Log.error(self, "Check the log for details: " + "`tail /var/log/wo/wordops.log` " + "and please try again") + if wo_auth and len(wo_auth): + for msg in wo_auth: + Log.info(self, Log.ENDC + msg, log=False) + Log.info(self, "Successfully created site" + " http://{0}".format(wo_domain)) + return + addNewSite(self, wo_domain, stype, cache, wo_site_webroot, php_version=php_version) diff --git a/wo/cli/templates/virtualconf.mustache b/wo/cli/templates/virtualconf.mustache index 396606f..3356ab8 100644 --- a/wo/cli/templates/virtualconf.mustache +++ b/wo/cli/templates/virtualconf.mustache @@ -16,6 +16,10 @@ server { access_log /var/log/nginx/{{site_name}}.access.log {{^wpredis}}{{^static}}rt_cache{{/static}}{{/wpredis}}{{#wpredis}}rt_cache_redis{{/wpredis}}; error_log /var/log/nginx/{{site_name}}.error.log; + {{#alias}} + location / { + return 301 https://{{alias_name}}$request_uri; + } {{#proxy}} add_header X-Proxy-Cache $upstream_cache_status; location / { @@ -23,7 +27,7 @@ server { proxy_redirect off; include proxy_params; } - + {{#alias}} # Security settings for better privacy # Deny hidden files location ~ /\.(?!well-known\/) { @@ -35,9 +39,11 @@ server { allow all; auth_basic off; } + {{/alias}} {{/proxy}} {{^proxy}} + {{^alias}} root {{webroot}}/htdocs; index {{^static}}index.php{{/static}} index.html index.htm; @@ -51,7 +57,7 @@ server { {{^static}}include {{#basic}}common/{{wo_php}}.conf;{{/basic}}{{#wpfc}}common/wpfc-{{wo_php}}.conf;{{/wpfc}}{{#wpsc}}common/wpsc-{{wo_php}}.conf;{{/wpsc}}{{#wpredis}}common/redis-{{wo_php}}.conf;{{/wpredis}}{{#wprocket}}common/wprocket-{{wo_php}}.conf;{{/wprocket}}{{#wpce}}common/wpce-{{wo_php}}.conf;{{/wpce}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}} {{#wp}}include common/wpcommon-{{wo_php}}.conf;{{/wp}} - include common/locations-wo.conf;{{/proxy}} + include common/locations-wo.conf;{{/proxy}}{{/alias}} include {{webroot}}/conf/nginx/*.conf; } From 01b0c174c9c84ca112086dc5286a21d8463fb666 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 6 Aug 2023 13:12:55 +0200 Subject: [PATCH 3/9] Fix virualconf --- wo/cli/templates/virtualconf.mustache | 1 + 1 file changed, 1 insertion(+) diff --git a/wo/cli/templates/virtualconf.mustache b/wo/cli/templates/virtualconf.mustache index 3356ab8..dd195b3 100644 --- a/wo/cli/templates/virtualconf.mustache +++ b/wo/cli/templates/virtualconf.mustache @@ -20,6 +20,7 @@ server { location / { return 301 https://{{alias_name}}$request_uri; } + {{/alias}} {{#proxy}} add_header X-Proxy-Cache $upstream_cache_status; location / { From 20ae2707362ac2e6c656b4d22b702235080b52a8 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 6 Aug 2023 13:29:05 +0200 Subject: [PATCH 4/9] Fix virtualconf template --- wo/cli/templates/virtualconf.mustache | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/wo/cli/templates/virtualconf.mustache b/wo/cli/templates/virtualconf.mustache index dd195b3..20670a1 100644 --- a/wo/cli/templates/virtualconf.mustache +++ b/wo/cli/templates/virtualconf.mustache @@ -20,15 +20,6 @@ server { location / { return 301 https://{{alias_name}}$request_uri; } - {{/alias}} - {{#proxy}} - add_header X-Proxy-Cache $upstream_cache_status; - location / { - proxy_pass http://{{host}}:{{port}}; - proxy_redirect off; - include proxy_params; - } - {{#alias}} # Security settings for better privacy # Deny hidden files location ~ /\.(?!well-known\/) { @@ -41,6 +32,25 @@ server { auth_basic off; } {{/alias}} + {{#proxy}} + add_header X-Proxy-Cache $upstream_cache_status; + location / { + proxy_pass http://{{host}}:{{port}}; + proxy_redirect off; + include proxy_params; + } + + # Security settings for better privacy + # Deny hidden files + location ~ /\.(?!well-known\/) { + deny all; + } + # letsencrypt validation + location /.well-known/acme-challenge/ { + alias /var/www/html/.well-known/acme-challenge/; + allow all; + auth_basic off; + } {{/proxy}} {{^proxy}} From e74fce77bed2faf3375685db3f8645b5134b9e6f Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 6 Aug 2023 13:49:41 +0200 Subject: [PATCH 5/9] Fix virtualconf template --- wo/cli/templates/virtualconf.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wo/cli/templates/virtualconf.mustache b/wo/cli/templates/virtualconf.mustache index 20670a1..19a0336 100644 --- a/wo/cli/templates/virtualconf.mustache +++ b/wo/cli/templates/virtualconf.mustache @@ -68,7 +68,7 @@ server { {{^static}}include {{#basic}}common/{{wo_php}}.conf;{{/basic}}{{#wpfc}}common/wpfc-{{wo_php}}.conf;{{/wpfc}}{{#wpsc}}common/wpsc-{{wo_php}}.conf;{{/wpsc}}{{#wpredis}}common/redis-{{wo_php}}.conf;{{/wpredis}}{{#wprocket}}common/wprocket-{{wo_php}}.conf;{{/wprocket}}{{#wpce}}common/wpce-{{wo_php}}.conf;{{/wpce}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}} {{#wp}}include common/wpcommon-{{wo_php}}.conf;{{/wp}} - include common/locations-wo.conf;{{/proxy}}{{/alias}} + include common/locations-wo.conf;{{/alias}}{{/proxy}} include {{webroot}}/conf/nginx/*.conf; } From e29c7e11c56ecd846eadcc5b32527a842a4fa316 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 6 Aug 2023 15:47:24 +0200 Subject: [PATCH 6/9] improve virtualconf template --- wo/cli/templates/virtualconf.mustache | 28 +++++++++------------------ 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/wo/cli/templates/virtualconf.mustache b/wo/cli/templates/virtualconf.mustache index 19a0336..de65b9d 100644 --- a/wo/cli/templates/virtualconf.mustache +++ b/wo/cli/templates/virtualconf.mustache @@ -20,6 +20,15 @@ server { location / { return 301 https://{{alias_name}}$request_uri; } + {{/alias}} + {{#proxy}} + add_header X-Proxy-Cache $upstream_cache_status; + location / { + proxy_pass http://{{host}}:{{port}}; + proxy_redirect off; + include proxy_params; + } + {{#alias}} # Security settings for better privacy # Deny hidden files location ~ /\.(?!well-known\/) { @@ -32,25 +41,6 @@ server { auth_basic off; } {{/alias}} - {{#proxy}} - add_header X-Proxy-Cache $upstream_cache_status; - location / { - proxy_pass http://{{host}}:{{port}}; - proxy_redirect off; - include proxy_params; - } - - # Security settings for better privacy - # Deny hidden files - location ~ /\.(?!well-known\/) { - deny all; - } - # letsencrypt validation - location /.well-known/acme-challenge/ { - alias /var/www/html/.well-known/acme-challenge/; - allow all; - auth_basic off; - } {{/proxy}} {{^proxy}} From 28650fb0fb45c8cdbc5e4dc5d74c01f124c2dc7a Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 12 Aug 2023 13:41:21 +0200 Subject: [PATCH 7/9] Test php stack refactor --- wo/cli/plugins/stack.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 15ba2f2..cbe59a6 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -41,18 +41,6 @@ class WOStackController(CementBaseController): dict(help='Install Nginx stack', action='store_true')), (['--php'], dict(help='Install PHP 7.2 stack', action='store_true')), - (['--php72'], - dict(help='Install PHP 7.2 stack', action='store_true')), - (['--php73'], - dict(help='Install PHP 7.3 stack', action='store_true')), - (['--php74'], - dict(help='Install PHP 7.4 stack', action='store_true')), - (['--php80'], - dict(help='Install PHP 8.0 stack', action='store_true')), - (['--php81'], - dict(help='Install PHP 8.1 stack', action='store_true')), - (['--php82'], - dict(help='Install PHP 8.2 stack', action='store_true')), (['--mysql'], dict(help='Install MySQL stack', action='store_true')), (['--mariadb'], @@ -106,6 +94,10 @@ class WOStackController(CementBaseController): dict(help='Force install/remove/purge without prompt', action='store_true')), ] + for php_version, php_number in WOVar.wo_php_versions: + php_args = arguments + [([f'--{php_version}'], + dict(help=f'Install PHP {php_number} stack', + action='store_true'))] usage = "wo stack (command) [options]" @expose(hide=True) From d1c158d42f08049353d29ffbf38b49f143b5ea18 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 12 Aug 2023 14:08:05 +0200 Subject: [PATCH 8/9] Fix php refactor --- wo/cli/plugins/stack.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index cbe59a6..df10676 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -94,10 +94,11 @@ class WOStackController(CementBaseController): dict(help='Force install/remove/purge without prompt', action='store_true')), ] - for php_version, php_number in WOVar.wo_php_versions: - php_args = arguments + [([f'--{php_version}'], - dict(help=f'Install PHP {php_number} stack', - action='store_true'))] + for php_version, php_number in WOVar.wo_php_versions.items(): + arguments.append(([f'--{php_version}'], + dict(help=f'Install PHP {php_number} stack', + action='store_true'))) + usage = "wo stack (command) [options]" @expose(hide=True) From f751968fe748af95ba45628690735844bff62cf5 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 12 Aug 2023 14:44:56 +0200 Subject: [PATCH 9/9] Refactor all php stack --- wo/cli/plugins/info.py | 22 +++------- wo/cli/plugins/site_create.py | 18 +++------ wo/cli/plugins/site_update.py | 16 ++------ wo/cli/plugins/stack_upgrade.py | 72 ++++++++++++--------------------- 4 files changed, 40 insertions(+), 88 deletions(-) diff --git a/wo/cli/plugins/info.py b/wo/cli/plugins/info.py index 85fb5b8..705e9f3 100644 --- a/wo/cli/plugins/info.py +++ b/wo/cli/plugins/info.py @@ -9,6 +9,7 @@ from pynginxconfig import NginxConfig from wo.core.aptget import WOAptGet from wo.core.logging import Log from wo.core.shellexec import WOShellExec +from wo.core.variables import WOVar def wo_info_hook(app): @@ -27,28 +28,17 @@ class WOInfoController(CementBaseController): dict(help='Get MySQL configuration information', action='store_true')), (['--php'], - dict(help='Get PHP 7.2 configuration information', - action='store_true')), - (['--php73'], - dict(help='Get PHP 7.3 configuration information', - action='store_true')), - (['--php74'], - dict(help='Get PHP 7.4 configuration information', - action='store_true')), - (['--php80'], - dict(help='Get PHP 8.0 configuration information', - action='store_true')), - (['--php81'], - dict(help='Get PHP 8.1 configuration information', - action='store_true')), - (['--php82'], - dict(help='Get PHP 8.2 configuration information', + dict(help='Get PHP configuration information', action='store_true')), (['--nginx'], dict(help='Get Nginx configuration information', action='store_true')), ] usage = "wo info [options]" + for php_version, php_number in WOVar.wo_php_versions.items(): + arguments.append(([f'--{php_version}'], + dict(help=f'Get PHP {php_number} configuration information', + action='store_true'))) @expose(hide=True) def info_nginx(self): diff --git a/wo/cli/plugins/site_create.py b/wo/cli/plugins/site_create.py index ffc990b..c4a5344 100644 --- a/wo/cli/plugins/site_create.py +++ b/wo/cli/plugins/site_create.py @@ -32,19 +32,7 @@ class WOSiteCreateController(CementBaseController): (['--html'], dict(help="create html site", action='store_true')), (['--php'], - dict(help="create php 7.2 site", action='store_true')), - (['--php72'], - dict(help="create php 7.2 site", action='store_true')), - (['--php73'], - dict(help="create php 7.3 site", action='store_true')), - (['--php74'], - dict(help="create php 7.4 site", action='store_true')), - (['--php80'], - dict(help="create php 8.0 site", action='store_true')), - (['--php81'], - dict(help="create php 8.1 site", action='store_true')), - (['--php82'], - dict(help="create php 8.2 site", action='store_true')), + dict(help="create php site", action='store_true')), (['--mysql'], dict(help="create mysql site", action='store_true')), (['--wp'], @@ -110,6 +98,10 @@ class WOSiteCreateController(CementBaseController): "without installing WordPress", action='store_true')), ] + for php_version, php_number in WOVar.wo_php_versions.items(): + arguments.append(([f'--{php_version}'], + dict(help=f'Create PHP {php_number} site', + action='store_true'))) @expose(hide=True) def default(self): diff --git a/wo/cli/plugins/site_update.py b/wo/cli/plugins/site_update.py index 9c29896..052d16f 100644 --- a/wo/cli/plugins/site_update.py +++ b/wo/cli/plugins/site_update.py @@ -41,18 +41,6 @@ class WOSiteUpdateController(CementBaseController): dict(help="update to html site", action='store_true')), (['--php'], dict(help="update to php site", action='store_true')), - (['--php72'], - dict(help="update to php72 site", action='store_true')), - (['--php73'], - dict(help="update to php73 site", action='store_true')), - (['--php74'], - dict(help="update to php74 site", action='store_true')), - (['--php80'], - dict(help="update to php80 site", action='store_true')), - (['--php81'], - dict(help="update to php81 site", action='store_true')), - (['--php82'], - dict(help="update to php82 site", action='store_true')), (['--mysql'], dict(help="update to mysql site", action='store_true')), (['--wp'], @@ -104,6 +92,10 @@ class WOSiteUpdateController(CementBaseController): (['--all'], dict(help="update all sites", action='store_true')), ] + for php_version, php_number in WOVar.wo_php_versions.items(): + arguments.append(([f'--{php_version}'], + dict(help=f'Update site to PHP {php_number}', + action='store_true'))) @expose(help="Update site type or cache") def default(self): diff --git a/wo/cli/plugins/stack_upgrade.py b/wo/cli/plugins/stack_upgrade.py index a859d78..964f4c9 100644 --- a/wo/cli/plugins/stack_upgrade.py +++ b/wo/cli/plugins/stack_upgrade.py @@ -33,18 +33,6 @@ class WOStackUpgradeController(CementBaseController): dict(help='Upgrade Nginx stack', action='store_true')), (['--php'], dict(help='Upgrade PHP 7.2 stack', action='store_true')), - (['--php72'], - dict(help='Upgrade PHP 7.2 stack', action='store_true')), - (['--php73'], - dict(help='Upgrade PHP 7.3 stack', action='store_true')), - (['--php74'], - dict(help='Upgrade PHP 7.4 stack', action='store_true')), - (['--php80'], - dict(help='Upgrade PHP 8.0 stack', action='store_true')), - (['--php81'], - dict(help='Upgrade PHP 8.1 stack', action='store_true')), - (['--php82'], - dict(help='Upgrade PHP 8.2 stack', action='store_true')), (['--mysql'], dict(help='Upgrade MySQL stack', action='store_true')), (['--mariadb'], @@ -77,6 +65,10 @@ class WOStackUpgradeController(CementBaseController): dict(help="Force Packages upgrade without any prompt", action='store_true')), ] + for php_version, php_number in WOVar.wo_php_versions.items(): + arguments.append(([f'--{php_version}'], + dict(help=f'Upgrade PHP {php_number} stack', + action='store_true'))) @expose(hide=True) def default(self, disp_msg=False): @@ -102,7 +94,11 @@ class WOStackUpgradeController(CementBaseController): pargs.mysql = True if pargs.php: - pargs.php81 = True + 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.all: pargs.web = True @@ -145,41 +141,23 @@ class WOStackUpgradeController(CementBaseController): else: Log.info(self, "Nginx Stable is not already installed") - # php 7.2 - if pargs.php72: - if WOAptGet.is_installed(self, 'php7.2-fpm'): - apt_packages = apt_packages + WOVar.wo_php72 + \ - WOVar.wo_php_extra + wo_vars = { + 'php72': WOVar.wo_php72, + 'php73': WOVar.wo_php73, + 'php74': WOVar.wo_php74, + 'php80': WOVar.wo_php80, + 'php81': WOVar.wo_php81, + 'php82': WOVar.wo_php82, + } - # php 7.3 - if pargs.php73: - if WOAptGet.is_installed(self, 'php7.3-fpm'): - apt_packages = apt_packages + WOVar.wo_php73 + \ - WOVar.wo_php_extra - - # php 7.4 - if pargs.php74: - if WOAptGet.is_installed(self, 'php7.4-fpm'): - apt_packages = apt_packages + WOVar.wo_php74 + \ - WOVar.wo_php_extra - - # php 8.0 - if pargs.php80: - if WOAptGet.is_installed(self, 'php8.0-fpm'): - apt_packages = apt_packages + WOVar.wo_php80 + \ - WOVar.wo_php_extra - - # php 8.1 - if pargs.php81: - if WOAptGet.is_installed(self, 'php8.1-fpm'): - apt_packages = apt_packages + WOVar.wo_php81 + \ - WOVar.wo_php_extra - - # php 8.2 - if pargs.php82: - if WOAptGet.is_installed(self, 'php8.2-fpm'): - apt_packages = apt_packages + WOVar.wo_php82 + \ - WOVar.wo_php_extra + for parg_version, version in WOVar.wo_php_versions.items(): + if getattr(pargs, parg_version, False): + Log.debug(self, f"Setting apt_packages variable for PHP {version}") + if WOAptGet.is_installed(self, f'php{version}-fpm'): + apt_packages = apt_packages + wo_vars[parg_version] + WOVar.wo_php_extra + else: + Log.debug(self, f"PHP {version} not installed") + Log.info(self, f"PHP {version} not installed") # mysql if pargs.mysql: