Merge pull request #554 from WordOps/updating-configuration

Refactor php installation and site detection
This commit is contained in:
VirtuBox
2023-08-05 23:16:45 +02:00
committed by GitHub
6 changed files with 122 additions and 518 deletions

View File

@@ -16,6 +16,7 @@ license-file = LICENSE
[flake8] [flake8]
ignore = F405,W504,S322,S404,S603,s607,s602,C901 ignore = F405,W504,S322,S404,S603,s607,s602,C901
max-line-length = 120
exclude = exclude =
# No need to traverse our git directory # No need to traverse our git directory
.git, .git,

View File

@@ -9,6 +9,7 @@ from wo.core.aptget import WOAptGet
from wo.core.logging import Log from wo.core.logging import Log
from wo.core.services import WOService from wo.core.services import WOService
from wo.core.shellexec import WOShellExec from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVar
def wo_clean_hook(app): def wo_clean_hook(app):
@@ -54,7 +55,7 @@ class WOCleanController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def clean_redis(self): def clean_redis(self):
"""This function clears Redis cache""" """This function clears Redis cache"""
if(WOAptGet.is_installed(self, "redis-server")): if (WOAptGet.is_installed(self, "redis-server")):
Log.info(self, "Cleaning Redis cache") Log.info(self, "Cleaning Redis cache")
WOShellExec.cmd_exec(self, "redis-cli flushall") WOShellExec.cmd_exec(self, "redis-cli flushall")
else: else:
@@ -62,7 +63,7 @@ class WOCleanController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def clean_fastcgi(self): def clean_fastcgi(self):
if(os.path.isdir("/var/run/nginx-cache") and if (os.path.isdir("/var/run/nginx-cache") and
os.path.exists('/usr/sbin/nginx')): os.path.exists('/usr/sbin/nginx')):
Log.info(self, "Cleaning NGINX FastCGI cache") Log.info(self, "Cleaning NGINX FastCGI cache")
WOShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") WOShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*")
@@ -78,15 +79,12 @@ class WOCleanController(CementBaseController):
'/var/www/22222/htdocs/cache/opcache')): '/var/www/22222/htdocs/cache/opcache')):
try: try:
Log.info(self, "Cleaning opcache") Log.info(self, "Cleaning opcache")
if os.path.exists('{0}php72.php'.format(opcache_dir)): wo_php_version = list(WOVar.wo_php_versions.keys())
requests.get( for wo_php in wo_php_version:
"http://127.0.0.1/cache/opcache/php72.php") if os.path.exists('{0}{1}.php'.format(opcache_dir, wo_php)):
if os.path.exists('{0}php73.php'.format(opcache_dir)): requests.get(
requests.get( "http://127.0.0.1/cache/opcache/{0}.php".format(wo_php))
"http://127.0.0.1/cache/opcache/php73.php")
if os.path.exists('{0}php74.php'.format(opcache_dir)):
requests.get(
"http://127.0.0.1/cache/opcache/php74.php")
except requests.HTTPError as e: except requests.HTTPError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
Log.debug(self, "Unable hit url, " Log.debug(self, "Unable hit url, "

View File

@@ -872,95 +872,34 @@ def site_package_check(self, stype):
wo_nginx.write('fastcgi_param \tSCRIPT_FILENAME ' wo_nginx.write('fastcgi_param \tSCRIPT_FILENAME '
'\t$request_filename;\n') '\t$request_filename;\n')
if ((pargs.php and pargs.php73) or (pargs.php and pargs.php74) or php_versions = ['php72', 'php73', 'php74', 'php80', 'php81', 'php82']
(pargs.php and pargs.php72) or (pargs.php and pargs.php80) or
(pargs.php and pargs.php81) or (pargs.php and pargs.php82) or selected_versions = [version for version in php_versions if getattr(pargs, version)]
(pargs.php72 and pargs.php73) or (pargs.php72 and pargs.php74) or if len(selected_versions) > 1:
(pargs.php72 and pargs.php80) or (pargs.php72 and pargs.php81) or Log.error(self, "Error: two different PHP versions cannot be "
(pargs.php72 and pargs.php82) or "combined within the same WordOps site")
(pargs.php73 and pargs.php74) or (pargs.php73 and pargs.php80) or
(pargs.php73 and pargs.php81) or (pargs.php73 and pargs.php82) or
(pargs.php74 and pargs.php80) or (pargs.php74 and pargs.php81) or
(pargs.php74 and pargs.php82) or
(pargs.php80 and pargs.php81) or (pargs.php80 and pargs.php82) or
(pargs.php81 and pargs.php82)):
Log.error(
self, "Error: two different PHP versions cannot be "
"combined within the same WordOps site")
if ((not pargs.php72) and (not pargs.php73) and (not pargs.php74) and if ((not pargs.php72) and (not pargs.php73) and (not pargs.php74) and
(not pargs.php80) and (not pargs.php81) and (not pargs.php82) and (not pargs.php80) and (not pargs.php81) and (not pargs.php82) and
stype in ['php', 'mysql', 'wp', 'wpsubdir', stype in ['php', 'mysql', 'wp', 'wpsubdir',
'wpsubdomain']): 'wpsubdomain']):
Log.debug(self, "Setting apt_packages variable for PHP") Log.debug(self, "Setting apt_packages variable for PHP")
php_check = 'php8.0-fpm'
php_to_setup = WOVar.wo_php80
if self.app.config.has_section('php'):
config_php_ver = self.app.config.get(
'php', 'version')
if config_php_ver == '7.2':
php_check = 'php7.2-fpm'
php_to_setup = WOVar.wo_php72
elif config_php_ver == '7.3':
php_check = 'php7.3-fpm'
php_to_setup = WOVar.wo_php73
elif config_php_ver == '7.4':
php_check = 'php7.4-fpm'
php_to_setup = WOVar.wo_php74
elif config_php_ver == '8.0':
php_check = 'php8.0-fpm'
php_to_setup = WOVar.wo_php80
elif config_php_ver == '8.1':
php_check = 'php8.1-fpm'
php_to_setup = WOVar.wo_php81
elif config_php_ver == '8.2':
php_check = 'php8.2-fpm'
php_to_setup = WOVar.wo_php82
else:
php_check = 'php8.1-fpm'
php_to_setup = WOVar.wo_php81
else:
php_check = 'php8.1-fpm'
php_to_setup = WOVar.wo_php81
if not (WOAptGet.is_installed(self, php_check)): for version_key, version_number in WOVar.wo_php_versions.items():
apt_packages = apt_packages + php_to_setup + WOVar.wo_php_extra if (self.app.config.has_section('php') and
self.app.config.get('php', 'version') == version_number):
Log.debug(
self,
f"Setting apt_packages variable for PHP {version_number}")
if not WOAptGet.is_installed(self, f'php{version_number}-fpm'):
apt_packages += getattr(
WOVar, f'wo_{version_key}') + WOVar.wo_php_extra
if pargs.php72 and stype in ['php72', 'mysql', 'wp', for version_key, version_number in WOVar.wo_php_versions.items():
'wpsubdir', 'wpsubdomain']: if getattr(pargs, version_key) and stype in [version_key, 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 7.2") Log.debug(self, f"Setting apt_packages variable for PHP {version_number}")
if not WOAptGet.is_installed(self, 'php7.2-fpm'): if not WOAptGet.is_installed(self, f'php{version_number}-fpm'):
apt_packages = apt_packages + WOVar.wo_php72 + WOVar.wo_php_extra apt_packages += getattr(WOVar, f'wo_{version_key}') + WOVar.wo_php_extra
if pargs.php73 and stype in ['php73', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 7.3")
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
apt_packages = apt_packages + WOVar.wo_php73 + WOVar.wo_php_extra
if pargs.php74 and stype in ['php74', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 7.4")
if not WOAptGet.is_installed(self, 'php7.4-fpm'):
apt_packages = apt_packages + WOVar.wo_php74 + WOVar.wo_php_extra
if pargs.php80 and stype in ['php80', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 8.0")
if not WOAptGet.is_installed(self, 'php8.0-fpm'):
apt_packages = apt_packages + WOVar.wo_php80 + WOVar.wo_php_extra
if pargs.php81 and stype in ['php81', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 8.1")
if not WOAptGet.is_installed(self, 'php8.1-fpm'):
apt_packages = apt_packages + WOVar.wo_php81 + WOVar.wo_php_extra
if pargs.php82 and stype in ['php82', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 8.2")
if not WOAptGet.is_installed(self, 'php8.2-fpm'):
apt_packages = apt_packages + WOVar.wo_php82 + WOVar.wo_php_extra
if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']: if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for MySQL") Log.debug(self, "Setting apt_packages variable for MySQL")
@@ -1137,268 +1076,39 @@ def detSitePar(opts):
2. raises RuntimeError when wrong combination is used like 2. raises RuntimeError when wrong combination is used like
"--wp --wpsubdir" or "--html --wp" "--wp --wpsubdir" or "--html --wp"
""" """
# Initialize sitetype and cachetype
sitetype, cachetype = '', '' sitetype, cachetype = '', ''
# Initialize type and cache lists
typelist = list() typelist = list()
cachelist = list() cachelist = list()
# Populate type and cache lists based on opts
for key, val in opts.items(): for key, val in opts.items():
if val and key in ['html', 'php', 'mysql', 'wp', if val and key in ['html', 'php', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain', 'php72', 'wpsubdir', 'wpsubdomain',
'php73', 'php74', 'php80', 'php81', 'php82', ]: 'php72', 'php73', 'php74',
'php80', 'php81', 'php82']:
typelist.append(key) typelist.append(key)
elif val and key in ['wpfc', 'wpsc', 'wpredis', 'wprocket', 'wpce']: elif val and key in ['wpfc', 'wpsc', 'wpredis', 'wprocket', 'wpce']:
cachelist.append(key) cachelist.append(key)
# Determine sitetype and cachetype
if len(typelist) > 1 or len(cachelist) > 1: if len(typelist) > 1 or len(cachelist) > 1:
if len(cachelist) > 1: raise RuntimeError(
raise RuntimeError( "Could not determine site or cache type. "
"Could not determine cache type." "Multiple types or caches entered.")
"Multiple cache parameter entered")
elif False not in [x in ('php', 'mysql', 'html') for x in typelist]: # If no type or cache specified, set to None
sitetype = 'mysql' if not typelist and not cachelist:
if not cachelist: sitetype = None
cachetype = 'basic' cachetype = None
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: else:
if not typelist and not cachelist: # Use the first specified type or 'wp' if not specified
sitetype = None sitetype = typelist[0] if typelist else 'wp'
cachetype = None
elif (not typelist or "php72" in typelist) and cachelist: # Use the first specified cache or 'basic' if not specified
sitetype = 'wp' cachetype = cachelist[0] if cachelist else 'basic'
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) return (sitetype, cachetype)

View File

@@ -200,65 +200,23 @@ class WOStackController(CementBaseController):
else: else:
Log.debug(self, "Redis already installed") Log.debug(self, "Redis already installed")
# PHP 7.2 wo_vars = {
if pargs.php72: 'php72': WOVar.wo_php72,
Log.debug(self, "Setting apt_packages variable for PHP 7.2") 'php73': WOVar.wo_php73,
if not (WOAptGet.is_installed(self, 'php7.2-fpm')): 'php74': WOVar.wo_php74,
apt_packages = (apt_packages + WOVar.wo_php72 + 'php80': WOVar.wo_php80,
WOVar.wo_php_extra) 'php81': WOVar.wo_php81,
else: 'php82': WOVar.wo_php82,
Log.debug(self, "PHP 7.2 already installed") }
Log.info(self, "PHP 7.2 already installed")
# PHP 7.3 for parg_version, version in WOVar.wo_php_versions.items():
if pargs.php73: if getattr(pargs, parg_version, False):
Log.debug(self, "Setting apt_packages variable for PHP 7.3") Log.debug(self, f"Setting apt_packages variable for PHP {version}")
if not WOAptGet.is_installed(self, 'php7.3-fpm'): if not WOAptGet.is_installed(self, f'php{version}-fpm'):
apt_packages = (apt_packages + WOVar.wo_php73 + apt_packages = apt_packages + wo_vars[parg_version] + WOVar.wo_php_extra
WOVar.wo_php_extra) else:
else: Log.debug(self, f"PHP {version} already installed")
Log.debug(self, "PHP 7.3 already installed") Log.info(self, f"PHP {version} already installed")
Log.info(self, "PHP 7.3 already installed")
# PHP 7.4
if pargs.php74:
Log.debug(self, "Setting apt_packages variable for PHP 7.4")
if not WOAptGet.is_installed(self, 'php7.4-fpm'):
apt_packages = (apt_packages + WOVar.wo_php74 +
WOVar.wo_php_extra)
else:
Log.debug(self, "PHP 7.4 already installed")
Log.info(self, "PHP 7.4 already installed")
# PHP 8.0
if pargs.php80:
Log.debug(self, "Setting apt_packages variable for PHP 8.0")
if not WOAptGet.is_installed(self, 'php8.0-fpm'):
apt_packages = (apt_packages + WOVar.wo_php80 +
WOVar.wo_php_extra)
else:
Log.debug(self, "PHP 8.0 already installed")
Log.info(self, "PHP 8.0 already installed")
# PHP 8.1
if pargs.php81:
Log.debug(self, "Setting apt_packages variable for PHP 8.1")
if not WOAptGet.is_installed(self, 'php8.1-fpm'):
apt_packages = (apt_packages + WOVar.wo_php81 +
WOVar.wo_php_extra)
else:
Log.debug(self, "PHP 8.1 already installed")
Log.info(self, "PHP 8.1 already installed")
# PHP 8.2
if pargs.php82:
Log.debug(self, "Setting apt_packages variable for PHP 8.2")
if not WOAptGet.is_installed(self, 'php8.2-fpm'):
apt_packages = (apt_packages + WOVar.wo_php82 +
WOVar.wo_php_extra)
else:
Log.debug(self, "PHP 8.2 already installed")
Log.info(self, "PHP 8.2 already installed")
# MariaDB # MariaDB
if pargs.mysql: if pargs.mysql:
@@ -669,97 +627,33 @@ class WOStackController(CementBaseController):
Log.debug(self, "Removing apt_packages variable of Nginx") Log.debug(self, "Removing apt_packages variable of Nginx")
apt_packages = apt_packages + WOVar.wo_nginx apt_packages = apt_packages + WOVar.wo_nginx
# PHP 7.2 # Create a dictionary that maps PHP versions to corresponding variables.
if pargs.php72: wo_vars = {
Log.debug(self, "Setting apt_packages variable for PHP 7.2") 'php72': WOVar.wo_php72,
if (WOAptGet.is_installed(self, 'php7.2-fpm')): 'php73': WOVar.wo_php73,
apt_packages = apt_packages + WOVar.wo_php72 'php74': WOVar.wo_php74,
if not (WOAptGet.is_installed(self, 'php7.3-fpm') or 'php80': WOVar.wo_php80,
WOAptGet.is_installed(self, 'php7.4-fpm') or 'php81': WOVar.wo_php81,
WOAptGet.is_installed(self, 'php8.0-fpm') or 'php82': WOVar.wo_php82,
WOAptGet.is_installed(self, 'php8.1-fpm') or }
WOAptGet.is_installed(self, 'php8.2-fpm')):
apt_packages = apt_packages + WOVar.wo_php_extra
else:
Log.debug(self, "PHP 7.2 is not installed")
Log.info(self, "PHP 7.2 is not installed")
# PHP 7.3 # Loop through all versions.
if pargs.php73: for parg_version, version in WOVar.wo_php_versions.items():
Log.debug(self, "Setting apt_packages variable for PHP 7.3") # Check if this version is present in pargs.
if WOAptGet.is_installed(self, 'php7.3-fpm'): if getattr(pargs, parg_version):
apt_packages = apt_packages + WOVar.wo_php73 Log.debug(self, f"Setting apt_packages variable for PHP {version}")
if not (WOAptGet.is_installed(self, 'php7.2-fpm') or
WOAptGet.is_installed(self, 'php7.4-fpm') or
WOAptGet.is_installed(self, 'php8.0-fpm') or
WOAptGet.is_installed(self, 'php8.1-fpm') or
WOAptGet.is_installed(self, 'php8.2-fpm')):
apt_packages = apt_packages + WOVar.wo_php_extra
else:
Log.debug(self, "PHP 7.3 is not installed")
Log.info(self, "PHP 7.3 is not installed")
# PHP 7.4 if WOAptGet.is_installed(self, f'php{version}-fpm'):
if pargs.php74: apt_packages += wo_vars[parg_version]
Log.debug(self, "Setting apt_packages variable for PHP 7.4")
if WOAptGet.is_installed(self, 'php7.4-fpm'):
apt_packages = apt_packages + WOVar.wo_php74
if not (WOAptGet.is_installed(self, 'php7.3-fpm') or
WOAptGet.is_installed(self, 'php7.2-fpm') or
WOAptGet.is_installed(self, 'php8.0-fpm') or
WOAptGet.is_installed(self, 'php8.1-fpm') or
WOAptGet.is_installed(self, 'php8.2-fpm')):
apt_packages = apt_packages + WOVar.wo_php_extra
else:
Log.debug(self, "PHP 7.4 is not installed")
Log.info(self, "PHP 7.4 is not installed")
# PHP 8.0 # Check if other versions are installed.
if pargs.php80: if not any(WOAptGet.is_installed(self, f'php{other_version}-fpm') for
Log.debug(self, "Setting apt_packages variable for PHP 8.0") other_version in WOVar.wo_php_versions.values() if other_version != version):
if WOAptGet.is_installed(self, 'php8.0-fpm'): apt_packages += WOVar.wo_php_extra
apt_packages = apt_packages + WOVar.wo_php80
if not (WOAptGet.is_installed(self, 'php7.3-fpm') or
WOAptGet.is_installed(self, 'php7.2-fpm') or
WOAptGet.is_installed(self, 'php7.4-fpm') or
WOAptGet.is_installed(self, 'php8.1-fpm') or
WOAptGet.is_installed(self, 'php8.2-fpm')):
apt_packages = apt_packages + WOVar.wo_php_extra
else:
Log.debug(self, "PHP 8.0 is not installed")
Log.info(self, "PHP 8.0 is not installed")
# PHP 8.1 else:
if pargs.php81: Log.debug(self, f"PHP {version} is not installed")
Log.debug(self, "Setting apt_packages variable for PHP 8.1") Log.info(self, f"PHP {version} is not installed")
if WOAptGet.is_installed(self, 'php8.1-fpm'):
apt_packages = apt_packages + WOVar.wo_php81
if not (WOAptGet.is_installed(self, 'php7.3-fpm') or
WOAptGet.is_installed(self, 'php7.2-fpm') or
WOAptGet.is_installed(self, 'php7.4-fpm') or
WOAptGet.is_installed(self, 'php8.0-fpm') or
WOAptGet.is_installed(self, 'php8.1-fpm') or
WOAptGet.is_installed(self, 'php8.2-fpm')):
apt_packages = apt_packages + WOVar.wo_php_extra
else:
Log.debug(self, "PHP 8.1 is not installed")
Log.info(self, "PHP 8.1 is not installed")
# PHP 8.2
if pargs.php82:
Log.debug(self, "Setting apt_packages variable for PHP 8.2")
if WOAptGet.is_installed(self, 'php8.2-fpm'):
apt_packages = apt_packages + WOVar.wo_php82
if not (WOAptGet.is_installed(self, 'php7.3-fpm') or
WOAptGet.is_installed(self, 'php7.2-fpm') or
WOAptGet.is_installed(self, 'php7.4-fpm') or
WOAptGet.is_installed(self, 'php8.0-fpm') or
WOAptGet.is_installed(self, 'php8.1-fpm') or
WOAptGet.is_installed(self, 'php8.2-fpm')):
apt_packages = apt_packages + WOVar.wo_php_extra
else:
Log.debug(self, "PHP 8.2 is not installed")
Log.info(self, "PHP 8.2 is not installed")
# REDIS # REDIS
if pargs.redis: if pargs.redis:

View File

@@ -12,7 +12,7 @@ class WOConf():
def nginxcommon(self): def nginxcommon(self):
"""nginx common configuration deployment""" """nginx common configuration deployment"""
wo_php_version = ["php72", "php73", "php74", "php80", "php81", "php82"] wo_php_version = list(WOVar.wo_php_versions.keys())
ngxcom = '/etc/nginx/common' ngxcom = '/etc/nginx/common'
if not os.path.exists(ngxcom): if not os.path.exists(ngxcom):
os.mkdir(ngxcom) os.mkdir(ngxcom)

View File

@@ -150,31 +150,35 @@ class WOVar():
wo_nginx = ["nginx-custom", "nginx-wo"] wo_nginx = ["nginx-custom", "nginx-wo"]
wo_nginx_key = 'FB898660' wo_nginx_key = 'FB898660'
wo_module = ["bcmath", "cli", "common", "curl", "fpm", "gd", "igbinary", wo_php_versions = {
"imagick", "imap", "intl", "mbstring", "memcached", "msgpack", 'php72': '7.2',
"mysql", "opcache", "readline", "redis", "soap", "xdebug", 'php73': '7.3',
"xml", "zip"] 'php74': '7.4',
wo_php72 = [] 'php80': '8.0',
for module in wo_module: 'php81': '8.1',
wo_php72 = wo_php72 + ["php7.2-{0}".format(module)] 'php82': '8.2',
wo_php72 = wo_php72 + ["php7.2-recode"] }
wo_php73 = []
for module in wo_module: def generate_php_modules(version_prefix, version_number):
wo_php73 = wo_php73 + ["php7.3-{0}".format(module)] wo_module = ["bcmath", "cli", "common", "curl", "fpm", "gd", "igbinary",
wo_php73 = wo_php73 + ["php7.3-recode"] "imagick", "imap", "intl", "mbstring", "memcached", "msgpack",
wo_php74 = [] "mysql", "opcache", "readline", "redis", "soap", "xdebug",
for module in wo_module: "xml", "zip"]
wo_php74 = wo_php74 + ["php7.4-{0}".format(module)] php_modules = ["php{0}-{1}".format(version_number, module) for module in wo_module]
wo_php74 = wo_php74 + ["php7.4-geoip", "php7.4-json"]
wo_php80 = [] if version_prefix == 'php72' or version_prefix == 'php73':
for module in wo_module: php_modules.append("php{0}-recode".format(version_number))
wo_php80 = wo_php80 + ["php8.0-{0}".format(module)] elif version_prefix == 'php74':
wo_php81 = [] php_modules.extend(["php{0}-geoip".format(version_number), "php{0}-json".format(version_number)])
for module in wo_module:
wo_php81 = wo_php81 + ["php8.1-{0}".format(module)] return php_modules
wo_php82 = []
for module in wo_module: wo_php72 = generate_php_modules('php72', '7.2')
wo_php82 = wo_php82 + ["php8.2-{0}".format(module)] wo_php73 = generate_php_modules('php73', '7.3')
wo_php74 = generate_php_modules('php74', '7.4')
wo_php80 = generate_php_modules('php80', '8.0')
wo_php81 = generate_php_modules('php81', '8.1')
wo_php82 = generate_php_modules('php82', '8.2')
wo_php_extra = ["graphviz"] wo_php_extra = ["graphviz"]
@@ -182,10 +186,7 @@ class WOVar():
"mariadb-server", "percona-toolkit", "mariadb-server", "percona-toolkit",
"mariadb-common", "python3-mysqldb"] "mariadb-common", "python3-mysqldb"]
if wo_distro == 'raspbian': if wo_distro == 'raspbian':
if wo_platform_codename == 'stretch': mariadb_ver = '10.3'
mariadb_ver = '10.1'
else:
mariadb_ver = '10.3'
else: else:
mariadb_ver = '10.11' mariadb_ver = '10.11'
wo_mysql = wo_mysql + ["mariadb-backup"] wo_mysql = wo_mysql + ["mariadb-backup"]