Refactor all php stack

This commit is contained in:
VirtuBox
2023-08-12 14:44:56 +02:00
parent d1c158d42f
commit f751968fe7
4 changed files with 40 additions and 88 deletions

View File

@@ -9,6 +9,7 @@ from pynginxconfig import NginxConfig
from wo.core.aptget import WOAptGet from wo.core.aptget import WOAptGet
from wo.core.logging import Log from wo.core.logging import Log
from wo.core.shellexec import WOShellExec from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVar
def wo_info_hook(app): def wo_info_hook(app):
@@ -27,28 +28,17 @@ class WOInfoController(CementBaseController):
dict(help='Get MySQL configuration information', dict(help='Get MySQL configuration information',
action='store_true')), action='store_true')),
(['--php'], (['--php'],
dict(help='Get PHP 7.2 configuration information', dict(help='Get PHP 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',
action='store_true')), action='store_true')),
(['--nginx'], (['--nginx'],
dict(help='Get Nginx configuration information', dict(help='Get Nginx configuration information',
action='store_true')), action='store_true')),
] ]
usage = "wo info [options]" 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) @expose(hide=True)
def info_nginx(self): def info_nginx(self):

View File

@@ -32,19 +32,7 @@ class WOSiteCreateController(CementBaseController):
(['--html'], (['--html'],
dict(help="create html site", action='store_true')), dict(help="create html site", action='store_true')),
(['--php'], (['--php'],
dict(help="create php 7.2 site", action='store_true')), dict(help="create php 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')),
(['--mysql'], (['--mysql'],
dict(help="create mysql site", action='store_true')), dict(help="create mysql site", action='store_true')),
(['--wp'], (['--wp'],
@@ -110,6 +98,10 @@ class WOSiteCreateController(CementBaseController):
"without installing WordPress", "without installing WordPress",
action='store_true')), 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) @expose(hide=True)
def default(self): def default(self):

View File

@@ -41,18 +41,6 @@ class WOSiteUpdateController(CementBaseController):
dict(help="update to html site", action='store_true')), dict(help="update to html site", action='store_true')),
(['--php'], (['--php'],
dict(help="update to php site", action='store_true')), 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'], (['--mysql'],
dict(help="update to mysql site", action='store_true')), dict(help="update to mysql site", action='store_true')),
(['--wp'], (['--wp'],
@@ -104,6 +92,10 @@ class WOSiteUpdateController(CementBaseController):
(['--all'], (['--all'],
dict(help="update all sites", action='store_true')), 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") @expose(help="Update site type or cache")
def default(self): def default(self):

View File

@@ -33,18 +33,6 @@ class WOStackUpgradeController(CementBaseController):
dict(help='Upgrade Nginx stack', action='store_true')), dict(help='Upgrade Nginx stack', action='store_true')),
(['--php'], (['--php'],
dict(help='Upgrade PHP 7.2 stack', action='store_true')), 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'], (['--mysql'],
dict(help='Upgrade MySQL stack', action='store_true')), dict(help='Upgrade MySQL stack', action='store_true')),
(['--mariadb'], (['--mariadb'],
@@ -77,6 +65,10 @@ class WOStackUpgradeController(CementBaseController):
dict(help="Force Packages upgrade without any prompt", dict(help="Force Packages upgrade without any prompt",
action='store_true')), 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) @expose(hide=True)
def default(self, disp_msg=False): def default(self, disp_msg=False):
@@ -102,7 +94,11 @@ class WOStackUpgradeController(CementBaseController):
pargs.mysql = True pargs.mysql = True
if pargs.php: 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: if pargs.all:
pargs.web = True pargs.web = True
@@ -145,41 +141,23 @@ class WOStackUpgradeController(CementBaseController):
else: else:
Log.info(self, "Nginx Stable is not already installed") Log.info(self, "Nginx Stable is not already installed")
# php 7.2 wo_vars = {
if pargs.php72: '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,
WOVar.wo_php_extra 'php80': WOVar.wo_php80,
'php81': WOVar.wo_php81,
'php82': WOVar.wo_php82,
}
# php 7.3 for parg_version, version in WOVar.wo_php_versions.items():
if pargs.php73: if getattr(pargs, parg_version, False):
if WOAptGet.is_installed(self, 'php7.3-fpm'): Log.debug(self, f"Setting apt_packages variable for PHP {version}")
apt_packages = apt_packages + WOVar.wo_php73 + \ if WOAptGet.is_installed(self, f'php{version}-fpm'):
WOVar.wo_php_extra apt_packages = apt_packages + wo_vars[parg_version] + WOVar.wo_php_extra
else:
# php 7.4 Log.debug(self, f"PHP {version} not installed")
if pargs.php74: Log.info(self, f"PHP {version} not installed")
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
# mysql # mysql
if pargs.mysql: if pargs.mysql: