Almost there, don't use this yet

This commit is contained in:
jeroenlaylo
2018-11-30 19:33:29 +01:00
parent 56fe3433db
commit 6aab6373b5
7 changed files with 122 additions and 129 deletions

View File

@@ -29,7 +29,7 @@ class WOInfoController(CementBaseController):
(['--php'],
dict(help='Get PHP configuration information',
action='store_true')),
(['--php7'],
(['--php72'],
dict(help='Get PHP 7.2 configuration information',
action='store_true')),
(['--nginx'],
@@ -138,7 +138,7 @@ class WOInfoController(CementBaseController):
self.app.render((data), 'info_php.mustache')
@expose(hide=True)
def info_php7(self):
def info_php72(self):
"""Display PHP information"""
version = os.popen("php7.2 -v 2>/dev/null | head -n1 | cut -d' ' -f2 |"
" cut -d'+' -f1 | tr -d '\n'").read
@@ -243,7 +243,7 @@ class WOInfoController(CementBaseController):
def default(self):
"""default function for info"""
if (not self.app.pargs.nginx and not self.app.pargs.php
and not self.app.pargs.mysql and not self.app.pargs.php7):
and not self.app.pargs.mysql and not self.app.pargs.php72):
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.mysql = True
@@ -268,9 +268,9 @@ class WOInfoController(CementBaseController):
else:
Log.error(self, "PHP5.6 is not installed")
if self.app.pargs.php7:
if self.app.pargs.php72:
if WOAptGet.is_installed(self, 'php7.2-fpm'):
self.info_php7()
self.info_php72()
else:
Log.error(self, "PHP 7.2 is not installed")

View File

@@ -309,8 +309,8 @@ class WOSiteCreateController(CementBaseController):
dict(help="create html site", action='store_true')),
(['--php'],
dict(help="create php site", action='store_true')),
(['--php7'],
dict(help="create php 7.0 site", action='store_true')),
(['--php72'],
dict(help="create php 7.2 site", action='store_true')),
(['--mysql'],
dict(help="create mysql site", action='store_true')),
(['--wp'],
@@ -410,16 +410,16 @@ class WOSiteCreateController(CementBaseController):
data['port'] = port
wo_site_webroot = ""
if self.app.pargs.php7:
if self.app.pargs.php72:
data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=False, basic=False, php7=True, wp=False,
static=False, basic=False, php72=True, wp=False,
wpfc=False, wpsc=False, multisite=False,
wpsubdir=False, webroot=wo_site_webroot)
data['basic'] = True
if stype in ['html', 'php' ]:
data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=True, basic=False, php7=False, wp=False,
static=True, basic=False, php72=False, wp=False,
wpfc=False, wpsc=False, multisite=False,
wpsubdir=False, webroot=wo_site_webroot)
@@ -453,27 +453,27 @@ class WOSiteCreateController(CementBaseController):
if stype == "html" and self.app.pargs.hhvm:
Log.error(self, "Can not create HTML site with HHVM")
if data and self.app.pargs.php7:
if data and self.app.pargs.php72:
if (not self.app.pargs.experimental):
Log.info(self, "Do you wish to install PHP 7.2 now for {0}?".format(wo_domain))
# Check prompt
check_prompt = input("Type \"y\" to continue [n]:")
if check_prompt != "Y" and check_prompt != "y":
Log.info(self, "Not using PHP 7.0 for site.")
data['php7'] = False
Log.info(self, "Not using PHP 7.2 for site.")
data['php72'] = False
data['basic'] = True
php7 = 0
self.app.pargs.php7 = False
php72 = 0
self.app.pargs.php72 = False
else:
data['php7'] = True
php7 = 1
data['php72'] = True
php72 = 1
else:
data['php7'] = True
php7 = 1
data['php72'] = True
php72 = 1
elif data:
data['php7'] = False
php7 = 0
data['php72'] = False
php72 = 0
if (not self.app.pargs.wpfc) and (not self.app.pargs.wpsc) and (not self.app.pargs.wpredis) and (not self.app.pargs.hhvm):
data['basic'] = True
@@ -563,7 +563,7 @@ class WOSiteCreateController(CementBaseController):
" http://{0}".format(wo_domain))
return
if data['php7']:
if data['php72']:
php_version = "7.2"
else:
php_version = "7.2"
@@ -775,7 +775,7 @@ class WOSiteUpdateController(CementBaseController):
dict(help="update to html site", action='store_true')),
(['--php'],
dict(help="update to php site", action='store_true')),
(['--php7'],
(['--php72'],
dict(help="update to php7 site",
action='store' or 'store_const',
choices=('on', 'off'), const='on', nargs='?')),
@@ -822,7 +822,7 @@ class WOSiteUpdateController(CementBaseController):
if pargs.html:
Log.error(self, "No site can be updated to html")
if not (pargs.php or pargs.php7 or
if not (pargs.php or pargs.php72 or
pargs.mysql or pargs.wp or pargs.wpsubdir or
pargs.wpsubdomain or pargs.wpfc or pargs.wpsc or
pargs.hhvm or pargs.wpredis or pargs.letsencrypt):
@@ -850,7 +850,7 @@ class WOSiteUpdateController(CementBaseController):
def doupdatesite(self, pargs):
hhvm = None
letsencrypt = False
php7 = None
php72 = None
data = dict()
@@ -899,13 +899,13 @@ class WOSiteUpdateController(CementBaseController):
check_ssl = check_site.is_ssl
check_php_version = check_site.php_version
if check_php_version == "7.0":
old_php7 = True
if check_php_version == "7.2":
old_php72 = True
else:
old_php7 = False
old_php72 = False
if (pargs.password and not (pargs.html or
pargs.php or pargs.php7 or pargs.mysql or
pargs.php or pargs.php72 or pargs.mysql or
pargs.wp or pargs.wpfc or pargs.wpsc or
pargs.wpsubdir or pargs.wpsubdomain)):
try:
@@ -925,16 +925,16 @@ class WOSiteUpdateController(CementBaseController):
Log.info(self, Log.FAIL + "Can not update HTML site to HHVM")
return 1
if ((stype == 'php' and oldsitetype not in ['html', 'proxy', 'php7']) or
# (stype == 'php7' and oldsitetype not in ['html', 'mysql', 'php', 'php7', 'wp', 'wpsubdir', 'wpsubdomain', ]) or
if ((stype == 'php' and oldsitetype not in ['html', 'proxy', 'php72']) or
# (stype == 'php72' and oldsitetype not in ['html', 'mysql', 'php', 'php72', 'wp', 'wpsubdir', 'wpsubdomain', ]) or
(stype == 'mysql' and oldsitetype not in ['html', 'php',
'proxy','php7']) or
'proxy','php72']) or
(stype == 'wp' and oldsitetype not in ['html', 'php', 'mysql',
'proxy', 'wp', 'php7']) or
'proxy', 'wp', 'php72']) or
(stype == 'wpsubdir' and oldsitetype in ['wpsubdomain']) or
(stype == 'wpsubdomain' and oldsitetype in ['wpsubdir']) or
(stype == oldsitetype and cache == oldcachetype) and
not pargs.php7):
not pargs.php72):
Log.info(self, Log.FAIL + "can not update {0} {1} to {2} {3}".
format(oldsitetype, oldcachetype, stype, cache))
return 1
@@ -976,7 +976,7 @@ class WOSiteUpdateController(CementBaseController):
if stype == 'wpsubdir':
data['wpsubdir'] = True
if pargs.hhvm or pargs.php7:
if pargs.hhvm or pargs.php72:
if not data:
data = dict(site_name=wo_domain, www_domain=wo_www_domain,
currsitetype=oldsitetype,
@@ -1038,24 +1038,24 @@ class WOSiteUpdateController(CementBaseController):
data['hhvm'] = False
hhvm = False
if pargs.php7 == 'on' :
data['php7'] = True
php7 = True
check_php_version= '7.0'
elif pargs.php7 == 'off':
data['php7'] = False
php7 = False
if pargs.php72 == 'on' :
data['php72'] = True
php72 = True
check_php_version= '7.2'
elif pargs.php72 == 'off':
data['php72'] = False
php72 = False
check_php_version = '5.6'
if pargs.php7:
if php7 is old_php7:
if php7 is False:
Log.info(self, "PHP 7.0 is already disabled for given "
if pargs.php72:
if php72 is old_php72:
if php72 is False:
Log.info(self, "PHP 7.2 is already disabled for given "
"site")
elif php7 is True:
Log.info(self, "PHP 7.0 is already enabled for given "
elif php72 is True:
Log.info(self, "PHP 7.2 is already enabled for given "
"site")
pargs.php7 = False
pargs.php72 = False
#--letsencrypt=renew code goes here
if pargs.letsencrypt == "renew" and not pargs.all:
@@ -1154,33 +1154,30 @@ class WOSiteUpdateController(CementBaseController):
data['hhvm'] = False
hhvm = False
if data and (not pargs.php7):
if old_php7 is True:
data['php7'] = True
php7 = True
if data and (not pargs.php72):
if old_php72 is True:
data['php72'] = True
php72 = True
else:
data['php7'] = False
php7 = False
data['php72'] = False
php72 = False
if pargs.hhvm=="on" or pargs.letsencrypt=="on" or pargs.php7=="on":
if pargs.php7 == "on":
if pargs.hhvm=="on" or pargs.letsencrypt=="on" or pargs.php72=="on":
if pargs.php72 == "on":
if (not pargs.experimental):
Log.info(self, "PHP7.0 is experimental feature and it may not"
" work with all plugins of your site.\nYou can "
"disable it by passing --php7=off later.\nDo you wish"
" to enable PHP now for {0}?".format(wo_domain))
Log.info(self, "Do you wish to enable PHP 7.2 now for {0}?".format(wo_domain))
check_prompt = input("Type \"y\" to continue [n]:")
if check_prompt != "Y" and check_prompt != "y":
Log.info(self, "Not using PHP 7.0 for site")
data['php7'] = False
php7 = False
Log.info(self, "Not using PHP 7.2 for site")
data['php72'] = False
php72 = False
else:
data['php7'] = True
php7 = True
data['php72'] = True
php72 = True
else:
data['php7'] = True
php7 = True
data['php72'] = True
php72 = True
if pargs.hhvm == "on":
if (not pargs.experimental):
@@ -1242,7 +1239,7 @@ class WOSiteUpdateController(CementBaseController):
data['basic'] = True
cache = 'basic'
if ((hhvm is old_hhvm) and (php7 is old_php7) and
if ((hhvm is old_hhvm) and (php72 is old_php72) and
(stype == oldsitetype and cache == oldcachetype)):
return 1

View File

@@ -72,7 +72,7 @@ def setupdomain(self, data):
wo_site_nginx_conf = open('/etc/nginx/sites-available/{0}'
.format(wo_domain_name), encoding='utf-8',
mode='w')
if not data['php7']:
if not data['php72']:
self.app.render((data), 'virtualconf.mustache',
out=wo_site_nginx_conf)
else:
@@ -623,7 +623,7 @@ def sitebackup(self, data):
.format(data['site_name']), backup_path)
if data['currsitetype'] in ['html', 'php', 'proxy', 'mysql']:
if data['php7'] is True and not data['wp']:
if data['php72'] is True and not data['wp']:
Log.info(self, "Backing up Webroot \t\t", end='')
WOFileUtils.copyfiles(self, wo_site_webroot + '/htdocs', backup_path + '/htdocs')
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
@@ -663,7 +663,7 @@ def sitebackup(self, data):
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
# move wp-config.php/wo-config.php to backup
if data['currsitetype'] in ['mysql', 'proxy']:
if data['php7'] is True and not data['wp']:
if data['php72'] is True and not data['wp']:
WOFileUtils.copyfile(self, configfiles[0], backup_path)
else:
WOFileUtils.mvfile(self, configfiles[0], backup_path)
@@ -677,7 +677,7 @@ def site_package_check(self, stype):
stack = WOStackController()
stack.app = self.app
if stype in ['html', 'proxy', 'php', 'mysql', 'wp', 'wpsubdir',
'wpsubdomain', 'php7']:
'wpsubdomain', 'php72']:
Log.debug(self, "Setting apt_packages variable for Nginx")
# Check if server has nginx-custom package
@@ -708,14 +708,14 @@ def site_package_check(self, stype):
wo_nginx.write('fastcgi_param \tSCRIPT_FILENAME '
'\t$request_filename;\n')
if self.app.pargs.php and self.app.pargs.php7:
if self.app.pargs.php and self.app.pargs.php72:
Log.error(self,"Error: two different PHP versions cannot be combined within the same WordOps site")
if not self.app.pargs.php7 and stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
if not self.app.pargs.php72 and stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP")
apt_packages = apt_packages + WOVariables.wo_php72 + WOVariables.wo_php_extra
if self.app.pargs.php7 and stype in [ 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
if self.app.pargs.php72 and stype in [ 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
if (WOVariables.wo_platform_codename == 'trusty' or WOVariables.wo_platform_codename == 'xenial' or WOVariables.wo_platform_codename == 'bionic'):
Log.debug(self, "Setting apt_packages variable for PHP 7.2")
if not WOAptGet.is_installed(self, 'php7.2-fpm'):
@@ -830,7 +830,7 @@ def site_package_check(self, stype):
hhvm_file.write("upstream hhvm {\nserver 127.0.0.1:8000;\n"
"server 127.0.0.1:9000 backup;\n}\n")
if self.app.pargs.php7:
if self.app.pargs.php72:
if (WOVariables.wo_platform_codename == 'wheezy' or WOVariables.wo_platform_codename == 'precise'):
Log.error(self,"PHP 7.0 is not supported in your Platform")
@@ -894,7 +894,7 @@ def site_package_check(self, stype):
if os.path.isfile("/etc/nginx/conf.d/upstream.conf"):
if not WOFileUtils.grep(self, "/etc/nginx/conf.d/upstream.conf",
"php7"):
"php72"):
with open("/etc/nginx/conf.d/upstream.conf", "a") as php_file:
php_file.write("upstream php7 {\nserver 127.0.0.1:9070;\n}\n"
"upstream debug7 {\nserver 127.0.0.1:9170;\n}\n")
@@ -1032,7 +1032,7 @@ def detSitePar(opts):
cachelist = list()
for key, val in opts.items():
if val and key in ['html', 'php', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain','php7']:
'wpsubdir', 'wpsubdomain','php72']:
typelist.append(key)
elif val and key in ['wpfc', 'wpsc', 'wpredis']:
cachelist.append(key)
@@ -1046,7 +1046,7 @@ def detSitePar(opts):
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php7','mysql','html') for x in typelist]:
elif False not in [x in ('php72','mysql','html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
@@ -1058,7 +1058,7 @@ def detSitePar(opts):
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php7','mysql') for x in typelist]:
elif False not in [x in ('php72','mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
@@ -1076,8 +1076,8 @@ def detSitePar(opts):
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php7','html') for x in typelist]:
sitetype = 'php7'
elif False not in [x in ('php72','html') for x in typelist]:
sitetype = 'php72'
if not cachelist:
cachetype = 'basic'
else:
@@ -1094,19 +1094,19 @@ def detSitePar(opts):
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp','php7') for x in typelist]:
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 ('wpsubdir','php7') for x in typelist]:
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 ('wpsubdomain','php7') for x in typelist]:
elif False not in [x in ('wpsubdomain','php72') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
@@ -1118,7 +1118,7 @@ def detSitePar(opts):
if not typelist and not cachelist:
sitetype = None
cachetype = None
elif (not typelist or "php7" in typelist) and cachelist:
elif (not typelist or "php72" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
elif typelist and (not cachelist):

View File

@@ -57,10 +57,6 @@ class WOStackController(CementBaseController):
# dict(help='Install Nginx mainline stack', action='store_true')),
(['--php'],
dict(help='Install PHP stack', action='store_true')),
(['--php7'],
dict(help='Install PHP 7.0 stack', action='store_true')),
(['--php71'],
dict(help='Install PHP 7.1 stack', action='store_true')),
(['--php72'],
dict(help='Install PHP 7.2 stack', action='store_true')),
(['--mysql'],
@@ -247,7 +243,7 @@ class WOStackController(CementBaseController):
self.app.render((data), 'fastcgi.mustache', out=wo_nginx)
wo_nginx.close()
data = dict(php="9000", debug="9001", hhvm="8000",php7="9070",debug7="9170",
data = dict(php="9000", debug="9001", hhvm="8000",php72="9072",debug7="9170",
hhvmconf=False, php7conf= True if WOAptGet.is_installed(self,'php7.2-fpm') else False )
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/upstream.conf')
@@ -629,7 +625,7 @@ class WOStackController(CementBaseController):
if os.path.isfile("/etc/nginx/conf.d/upstream.conf"):
if not WOFileUtils.grep(self, "/etc/nginx/conf.d/upstream.conf",
"php7"):
"php72"):
with open("/etc/nginx/conf.d/upstream.conf", "a") as php_file:
php_file.write("upstream php7 {\nserver 127.0.0.1:9070;\n}\n"
"upstream debug7 {\nserver 127.0.0.1:9170;\n}\n")
@@ -892,7 +888,7 @@ class WOStackController(CementBaseController):
WOService.restart_service(self, 'php5-fpm')
if (WOVariables.wo_platform_codename == 'trusty' or WOVariables.wo_platform_codename == 'xenial' or WOVariables.wo_platform_codename == 'bionic') and set(WOVariables.wo_php5_6).issubset(set(apt_packages)):
if (WOVariables.wo_platform_codename == 'trusty' or WOVariables.wo_platform_codename == 'xenial' or WOVariables.wo_platform_codename == 'bionic'):
# Create log directories
if not os.path.exists('/var/log/php/5.6/'):
Log.debug(self, 'Creating directory /var/log/php/5.6/')

View File

@@ -80,9 +80,9 @@ class WOStackMigrateController(CementBaseController):
# Install MariaDB
apt_packages = WOVariables.wo_mysql
# If PHP is installed then install php5-mysql
if WOAptGet.is_installed(self, "php5-fpm"):
apt_packages = apt_packages + ["php5-mysql"]
# If PHP is installed then install php7.2-mysql
if WOAptGet.is_installed(self, "php7.2-fpm"):
apt_packages = apt_packages + ["php7.2-mysql"]
Log.info(self, "Updating apt-cache, hang on...")
WOAptGet.update(self)