This commit is contained in:
Janio Sarmento
2022-01-23 15:14:24 -03:00
parent b4476d3aa7
commit 555269decf
11 changed files with 943 additions and 45 deletions

View File

@@ -47,6 +47,10 @@ class WOSiteUpdateController(CementBaseController):
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')),
(['--mysql'],
dict(help="update to mysql site", action='store_true')),
(['--wp'],
@@ -111,6 +115,7 @@ class WOSiteUpdateController(CementBaseController):
Log.error(self, "No site can be updated to html")
if not (pargs.php or pargs.php72 or pargs.php73 or pargs.php74 or
pargs.php80 or pargs.php81 or
pargs.mysql or pargs.wp or pargs.wpsubdir or
pargs.wpsubdomain or pargs.wpfc or pargs.wpsc or
pargs.wprocket or pargs.wpce or
@@ -143,6 +148,8 @@ class WOSiteUpdateController(CementBaseController):
php73 = False
php74 = False
php72 = False
php80 = False
php81 = False
data = dict()
try:
@@ -191,11 +198,13 @@ class WOSiteUpdateController(CementBaseController):
old_php72 = bool(check_php_version == "7.2")
old_php73 = bool(check_php_version == "7.3")
old_php74 = bool(check_php_version == "7.4")
old_php80 = bool(check_php_version == "8.0")
old_php81 = bool(check_php_version == "8.1")
if ((pargs.password or pargs.hsts or
pargs.ngxblocker or pargs.letsencrypt == 'renew') and not (
pargs.html or pargs.php or pargs.php72 or pargs.php73 or
pargs.php74 or
pargs.php74 or pargs.php80 or pargs.php81 or
pargs.mysql or pargs.wp or pargs.wpfc or pargs.wpsc or
pargs.wprocket or pargs.wpce or
pargs.wpsubdir or pargs.wpsubdomain)):
@@ -263,16 +272,18 @@ class WOSiteUpdateController(CementBaseController):
if (((stype == 'php' and
oldsitetype not in ['html', 'proxy', 'php', 'php72',
'php73', 'php74']) or
'php73', 'php74', 'php80', 'php81']) or
(stype == 'mysql' and oldsitetype not in [
'html', 'php', 'php72', 'php73', 'php74', 'proxy']) or
'html', 'php', 'php72', 'php73', 'php74','php80', 'php81',
'proxy']) or
(stype == 'wp' and oldsitetype not in [
'html', 'php', 'php72', 'php73', 'php74', 'mysql',
'proxy', 'wp']) or
'html', 'php', 'php72', 'php73', 'php74', 'php80', 'php81',
'mysql', 'proxy', 'wp']) or
(stype == 'wpsubdir' and oldsitetype in ['wpsubdomain']) or
(stype == 'wpsubdomain' and oldsitetype in ['wpsubdir']) or
(stype == oldsitetype and cache == oldcachetype)) and
not (pargs.php72 or pargs.php73 or pargs.php74)):
not (pargs.php72 or pargs.php73 or pargs.php74 or pargs.php80 or
pargs.php81)):
Log.info(self, Log.FAIL + "can not update {0} {1} to {2} {3}".
format(oldsitetype, oldcachetype, stype, cache))
return 1
@@ -291,7 +302,7 @@ class WOSiteUpdateController(CementBaseController):
data = dict(
site_name=wo_domain, www_domain=wo_www_domain,
static=False, basic=True, wp=False, wpfc=False,
php72=False, php73=False, php74=False,
php72=False, php73=False, php74=False, php80=False, php81=False,
wpsc=False, wpredis=False, wprocket=False, wpce=False,
multisite=False, wpsubdir=False, webroot=wo_site_webroot,
currsitetype=oldsitetype, currcachetype=oldcachetype)
@@ -316,9 +327,9 @@ class WOSiteUpdateController(CementBaseController):
data['wpsubdir'] = True
if ((pargs.php72 or pargs.php73 or
pargs.php74) and (not data)):
pargs.php74 or pargs.php80 or pargs.php81) and (not data)):
Log.debug(
self, "pargs php72, or php73, or php74 enabled")
self, "pargs php72, or php73, or php74, or php80, or php81 enabled")
data = dict(
site_name=wo_domain,
www_domain=wo_www_domain,
@@ -333,7 +344,8 @@ class WOSiteUpdateController(CementBaseController):
data['multisite'] = False
data['wpsubdir'] = False
elif (oldsitetype == 'php' or oldsitetype == 'mysql' or
oldsitetype == 'php73'or oldsitetype == 'php74'):
oldsitetype == 'php73' or oldsitetype == 'php74' or
oldsitetype == 'php80' or oldsitetype == 'php81'):
data['static'] = False
data['wp'] = False
data['multisite'] = False
@@ -409,6 +421,14 @@ class WOSiteUpdateController(CementBaseController):
Log.debug(self, "pargs.php74 detected")
data['php74'] = True
php74 = True
elif pargs.php80:
Log.debug(self, "pargs.php80 detected")
data['php80'] = True
php80 = True
elif pargs.php81:
Log.debug(self, "pargs.php81 detected")
data['php81'] = True
php81 = True
if pargs.php72:
if php72 is old_php72:
@@ -428,8 +448,21 @@ class WOSiteUpdateController(CementBaseController):
"site")
pargs.php74 = False
if pargs.php80:
if php80 is old_php80:
Log.info(self, "PHP 8.0 is already enabled for given "
"site")
pargs.php80 = False
if pargs.php81:
if php81 is old_php81:
Log.info(self, "PHP 8.1 is already enabled for given "
"site")
pargs.php81 = False
if (data and (not pargs.php73) and
(not pargs.php74) and (not pargs.php72)):
(not pargs.php74) and (not pargs.php72) and
(not pargs.php80) and (not pargs.php81)):
data['php72'] = bool(old_php72 is True)
Log.debug(self, "data php72 = {0}".format(data['php72']))
php72 = bool(old_php72 is True)
@@ -439,6 +472,12 @@ class WOSiteUpdateController(CementBaseController):
data['php74'] = bool(old_php74 is True)
Log.debug(self, "data php74 = {0}".format(data['php74']))
php74 = bool(old_php74 is True)
data['php80'] = bool(old_php80 is True)
Log.debug(self, "data php80 = {0}".format(data['php80']))
php80 = bool(old_php80 is True)
data['php80'] = bool(old_php80 is True)
Log.debug(self, "data php80 = {0}".format(data['php80']))
php80 = bool(old_php80 is True)
if pargs.letsencrypt:
acme_domains = []
@@ -516,7 +555,9 @@ class WOSiteUpdateController(CementBaseController):
cache = 'wpce'
if ((php73 is old_php73) and (php72 is old_php72) and
(php74 is old_php74) and (stype == oldsitetype and
(php74 is old_php74) and (php80 is old_php80) and
(php81 is old_php81) and
(stype == oldsitetype and
cache == oldcachetype)):
Log.debug(self, "Nothing to update")
return 1
@@ -530,6 +571,12 @@ class WOSiteUpdateController(CementBaseController):
elif php72 is True:
data['wo_php'] = 'php72'
check_php_version = '7.2'
elif php80 is True:
data['wo_php'] = 'php80'
check_php_version = '8.0'
elif php81 is True:
data['wo_php'] = 'php81'
check_php_version = '8.1'
else:
data['wo_php'] = 'php73'
check_php_version = '7.3'
@@ -830,7 +877,8 @@ class WOSiteUpdateController(CementBaseController):
# Setup WordPress if old sites are html/php/mysql sites
if data['wp'] and oldsitetype in ['html', 'proxy', 'php', 'php72',
'mysql', 'php73', 'php74']:
'mysql', 'php73', 'php74', 'php80',
'php81',]:
try:
wo_wp_creds = setupwordpress(self, data)
except SiteError as e: