Refactor php versions management
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -879,22 +879,13 @@ def site_package_check(self, stype):
|
|||||||
Log.error(self, "Error: two different PHP versions cannot be "
|
Log.error(self, "Error: two different PHP versions cannot be "
|
||||||
"combined within the same WordOps site")
|
"combined within the same WordOps site")
|
||||||
|
|
||||||
php_versions = {
|
|
||||||
'php72': '7.2',
|
|
||||||
'php73': '7.3',
|
|
||||||
'php74': '7.4',
|
|
||||||
'php80': '8.0',
|
|
||||||
'php81': '8.1',
|
|
||||||
'php82': '8.2',
|
|
||||||
}
|
|
||||||
|
|
||||||
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")
|
||||||
|
|
||||||
for version_key, version_number in php_versions.items():
|
for version_key, version_number in WOVar.wo_php_versions.items():
|
||||||
if (self.app.config.has_section('php') and
|
if (self.app.config.has_section('php') and
|
||||||
self.app.config.get('php', 'version') == version_number):
|
self.app.config.get('php', 'version') == version_number):
|
||||||
Log.debug(
|
Log.debug(
|
||||||
@@ -904,7 +895,7 @@ def site_package_check(self, stype):
|
|||||||
apt_packages += getattr(
|
apt_packages += getattr(
|
||||||
WOVar, f'wo_{version_key}') + WOVar.wo_php_extra
|
WOVar, f'wo_{version_key}') + WOVar.wo_php_extra
|
||||||
|
|
||||||
for version_key, version_number in php_versions.items():
|
for version_key, version_number in WOVar.wo_php_versions.items():
|
||||||
if getattr(pargs, version_key) and stype in [version_key, 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
|
if getattr(pargs, version_key) and stype in [version_key, 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
|
||||||
Log.debug(self, f"Setting apt_packages variable for PHP {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'):
|
if not WOAptGet.is_installed(self, f'php{version_number}-fpm'):
|
||||||
|
|||||||
@@ -670,15 +670,6 @@ class WOStackController(CementBaseController):
|
|||||||
apt_packages = apt_packages + WOVar.wo_nginx
|
apt_packages = apt_packages + WOVar.wo_nginx
|
||||||
|
|
||||||
# Create a dictionary that maps PHP versions to corresponding variables.
|
# Create a dictionary that maps PHP versions to corresponding variables.
|
||||||
php_versions = {
|
|
||||||
'php72': '7.2',
|
|
||||||
'php73': '7.3',
|
|
||||||
'php74': '7.4',
|
|
||||||
'php80': '8.0',
|
|
||||||
'php81': '8.1',
|
|
||||||
'php82': '8.2',
|
|
||||||
}
|
|
||||||
|
|
||||||
wo_vars = {
|
wo_vars = {
|
||||||
'php72': WOVar.wo_php72,
|
'php72': WOVar.wo_php72,
|
||||||
'php73': WOVar.wo_php73,
|
'php73': WOVar.wo_php73,
|
||||||
@@ -689,7 +680,7 @@ class WOStackController(CementBaseController):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Loop through all versions.
|
# Loop through all versions.
|
||||||
for parg_version, version in php_versions.items():
|
for parg_version, version in WOVar.wo_php_versions.items():
|
||||||
# Check if this version is present in pargs.
|
# Check if this version is present in pargs.
|
||||||
if getattr(pargs, parg_version):
|
if getattr(pargs, parg_version):
|
||||||
Log.debug(self, f"Setting apt_packages variable for PHP {version}")
|
Log.debug(self, f"Setting apt_packages variable for PHP {version}")
|
||||||
@@ -699,7 +690,7 @@ class WOStackController(CementBaseController):
|
|||||||
|
|
||||||
# Check if other versions are installed.
|
# Check if other versions are installed.
|
||||||
if not any(WOAptGet.is_installed(self, f'php{other_version}-fpm') for
|
if not any(WOAptGet.is_installed(self, f'php{other_version}-fpm') for
|
||||||
other_version in php_versions.values() if other_version != version):
|
other_version in WOVar.wo_php_versions.values() if other_version != version):
|
||||||
apt_packages += WOVar.wo_php_extra
|
apt_packages += WOVar.wo_php_extra
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -150,31 +150,32 @@ class WOVar():
|
|||||||
wo_nginx = ["nginx-custom", "nginx-wo"]
|
wo_nginx = ["nginx-custom", "nginx-wo"]
|
||||||
wo_nginx_key = 'FB898660'
|
wo_nginx_key = 'FB898660'
|
||||||
|
|
||||||
|
wo_php_versions = {
|
||||||
|
'php72': '7.2',
|
||||||
|
'php73': '7.3',
|
||||||
|
'php74': '7.4',
|
||||||
|
'php80': '8.0',
|
||||||
|
'php81': '8.1',
|
||||||
|
'php82': '8.2',
|
||||||
|
}
|
||||||
|
|
||||||
wo_module = ["bcmath", "cli", "common", "curl", "fpm", "gd", "igbinary",
|
wo_module = ["bcmath", "cli", "common", "curl", "fpm", "gd", "igbinary",
|
||||||
"imagick", "imap", "intl", "mbstring", "memcached", "msgpack",
|
"imagick", "imap", "intl", "mbstring", "memcached", "msgpack",
|
||||||
"mysql", "opcache", "readline", "redis", "soap", "xdebug",
|
"mysql", "opcache", "readline", "redis", "soap", "xdebug",
|
||||||
"xml", "zip"]
|
"xml", "zip"]
|
||||||
wo_php72 = []
|
|
||||||
for module in wo_module:
|
wo_php_modules = {}
|
||||||
wo_php72 = wo_php72 + ["php7.2-{0}".format(module)]
|
|
||||||
wo_php72 = wo_php72 + ["php7.2-recode"]
|
for version_key, version_number in wo_php_versions.items():
|
||||||
wo_php73 = []
|
wo_php_modules[version_key] = []
|
||||||
for module in wo_module:
|
for module in wo_module:
|
||||||
wo_php73 = wo_php73 + ["php7.3-{0}".format(module)]
|
wo_php_modules[version_key].append("{0}-{1}".format(version_key, module))
|
||||||
wo_php73 = wo_php73 + ["php7.3-recode"]
|
|
||||||
wo_php74 = []
|
# Add version-specific modules
|
||||||
for module in wo_module:
|
if version_key == 'php72' or version_key == 'php73':
|
||||||
wo_php74 = wo_php74 + ["php7.4-{0}".format(module)]
|
wo_php_modules[version_key].append("{0}-recode".format(version_key))
|
||||||
wo_php74 = wo_php74 + ["php7.4-geoip", "php7.4-json"]
|
elif version_key == 'php74':
|
||||||
wo_php80 = []
|
wo_php_modules[version_key].extend(["{0}-geoip".format(version_key), "{0}-json".format(version_key)])
|
||||||
for module in wo_module:
|
|
||||||
wo_php80 = wo_php80 + ["php8.0-{0}".format(module)]
|
|
||||||
wo_php81 = []
|
|
||||||
for module in wo_module:
|
|
||||||
wo_php81 = wo_php81 + ["php8.1-{0}".format(module)]
|
|
||||||
wo_php82 = []
|
|
||||||
for module in wo_module:
|
|
||||||
wo_php82 = wo_php82 + ["php8.2-{0}".format(module)]
|
|
||||||
|
|
||||||
wo_php_extra = ["graphviz"]
|
wo_php_extra = ["graphviz"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user