Fix extplorer & simplify stack_pref

This commit is contained in:
VirtuBox
2019-09-01 16:50:13 +02:00
parent cda05da286
commit f10bcc124d
2 changed files with 113 additions and 119 deletions

View File

@@ -403,7 +403,7 @@ class WOStackController(CementBaseController):
Log.info(self, "WordOps dashboard already installed") Log.info(self, "WordOps dashboard already installed")
# eXtplorer # eXtplorer
if pargs.explorer: if pargs.extplorer:
if not os.path.isdir('/var/www/22222/htdocs/files'): if not os.path.isdir('/var/www/22222/htdocs/files'):
Log.debug(self, "Setting packages variable for eXtplorer") Log.debug(self, "Setting packages variable for eXtplorer")
packages = packages + \ packages = packages + \

View File

@@ -217,98 +217,96 @@ def post_pref(self, apt_packages, packages, upgrade=False):
'/etc/nginx/common') '/etc/nginx/common')
os.makedirs('/etc/nginx/common') os.makedirs('/etc/nginx/common')
if os.path.exists('/etc/nginx/common'): data = dict()
data = dict()
# Common Configuration # Common Configuration
WOTemplate.render(self, WOTemplate.render(self,
'{0}/locations-wo.conf' '{0}/locations-wo.conf'
.format(ngxcom), .format(ngxcom),
'locations.mustache', data) 'locations.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wpsubdir.conf' '{0}/wpsubdir.conf'
.format(ngxcom), .format(ngxcom),
'wpsubdir.mustache', data) 'wpsubdir.mustache', data)
data = dict(upstream="php72") data = dict(upstream="php72")
# PHP 7.2 conf # PHP 7.2 conf
WOTemplate.render(self, WOTemplate.render(self,
'{0}/php72.conf' '{0}/php72.conf'
.format(ngxcom), .format(ngxcom),
'php.mustache', data) 'php.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/redis-php72.conf' '{0}/redis-php72.conf'
.format(ngxcom), .format(ngxcom),
'redis.mustache', data) 'redis.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wpcommon-php72.conf' '{0}/wpcommon-php72.conf'
.format(ngxcom), .format(ngxcom),
'wpcommon.mustache', data) 'wpcommon.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wpfc-php72.conf' '{0}/wpfc-php72.conf'
.format(ngxcom), .format(ngxcom),
'wpfc.mustache', data) 'wpfc.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wpsc-php72.conf' '{0}/wpsc-php72.conf'
.format(ngxcom), .format(ngxcom),
'wpsc.mustache', data) 'wpsc.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wprocket-php72.conf' '{0}/wprocket-php72.conf'
.format(ngxcom), .format(ngxcom),
'wprocket.mustache', data) 'wprocket.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wpce-php72.conf' '{0}/wpce-php72.conf'
.format(ngxcom), .format(ngxcom),
'wpce.mustache', data) 'wpce.mustache', data)
# PHP 7.3 conf # PHP 7.3 conf
if os.path.isdir("/etc/nginx/common"): data = dict(upstream="php73")
data = dict(upstream="php73")
WOTemplate.render(self, WOTemplate.render(self,
'{0}/php73.conf' '{0}/php73.conf'
.format(ngxcom), .format(ngxcom),
'php.mustache', data) 'php.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/redis-php73.conf' '{0}/redis-php73.conf'
.format(ngxcom), .format(ngxcom),
'redis.mustache', data) 'redis.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wpcommon-php73.conf' '{0}/wpcommon-php73.conf'
.format(ngxcom), .format(ngxcom),
'wpcommon.mustache', data) 'wpcommon.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wpfc-php73.conf' '{0}/wpfc-php73.conf'
.format(ngxcom), .format(ngxcom),
'wpfc.mustache', data) 'wpfc.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wpsc-php73.conf' '{0}/wpsc-php73.conf'
.format(ngxcom), .format(ngxcom),
'wpsc.mustache', data) 'wpsc.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wprocket-php73.conf' '{0}/wprocket-php73.conf'
.format(ngxcom), .format(ngxcom),
'wprocket.mustache', data) 'wprocket.mustache', data)
WOTemplate.render(self, WOTemplate.render(self,
'{0}/wpce-php73.conf' '{0}/wpce-php73.conf'
.format(ngxcom), .format(ngxcom),
'wpce.mustache', data) 'wpce.mustache', data)
with open("/etc/nginx/common/release", with open("/etc/nginx/common/release",
"w") as release_file: "w") as release_file:
release_file.write("v{0}" release_file.write("v{0}"
.format(WOVariables.wo_version)) .format(WOVariables.wo_version))
release_file.close() release_file.close()
# Following files should not be overwrited # Following files should not be overwrited
@@ -324,7 +322,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
WOTemplate.render(self, WOTemplate.render(self,
'{0}/fastcgi.conf' '{0}/fastcgi.conf'
.format(ngxcnf), .format(ngxcnf),
'fastcgi.mustache', data, overwrite=False) 'fastcgi.mustache', data, overwrite=True)
# add redis cache format if not already done # add redis cache format if not already done
if (os.path.isfile("/etc/nginx/nginx.conf") and if (os.path.isfile("/etc/nginx/nginx.conf") and
@@ -1364,49 +1362,24 @@ def post_pref(self, apt_packages, packages, upgrade=False):
# WordOps Dashboard # WordOps Dashboard
if any('/var/lib/wo/tmp/wo-dashboard.tar.gz' == x[1] if any('/var/lib/wo/tmp/wo-dashboard.tar.gz' == x[1]
for x in packages): for x in packages):
if not os.path.isfile('{0}22222/htdocs/index.php' Log.debug(self, "Extracting wo-dashboard.tar.gz "
.format(WOVariables.wo_webroot)): "to location {0}22222/htdocs/"
Log.debug(self, "Extracting wo-dashboard.tar.gz " .format(WOVariables.wo_webroot))
"to location {0}22222/htdocs/" WOExtract.extract(self, '/var/lib/wo/tmp/'
.format(WOVariables.wo_webroot)) 'wo-dashboard.tar.gz',
WOExtract.extract(self, '/var/lib/wo/tmp/' '{0}22222/htdocs'
'wo-dashboard.tar.gz',
'{0}22222/htdocs'
.format(WOVariables.wo_webroot))
wo_wan = os.popen("/sbin/ip -4 route get 8.8.8.8 | "
"grep -oP \"dev [^[:space:]]+ \" "
"| cut -d ' ' -f 2").read()
if (wo_wan != 'eth0' and wo_wan != ''):
WOFileUtils.searchreplace(self,
"{0}22222/htdocs/index.php"
.format(WOVariables.wo_webroot),
"eth0",
"{0}".format(wo_wan))
Log.debug(self, "Setting Privileges to "
"{0}22222/htdocs"
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
WOFileUtils.chown(self, '{0}22222/htdocs' wo_wan = os.popen("/sbin/ip -4 route get 8.8.8.8 | "
.format(WOVariables.wo_webroot), "grep -oP \"dev [^[:space:]]+ \" "
'www-data', "| cut -d ' ' -f 2").read()
'www-data', if (wo_wan != 'eth0' and wo_wan != ''):
recursive=True) WOFileUtils.searchreplace(self,
"{0}22222/htdocs/index.php"
# Extplorer FileManager .format(WOVariables.wo_webroot),
if any('/var/lib/wo/tmp/extplorer.tar.gz' == x[1] "eth0",
for x in packages): "{0}".format(wo_wan))
if not os.path.exists('{0}22222/htdocs/files'
.format(WOVariables.wo_webroot)):
Log.debug(self, "Extracting explorer.tar.gz "
"to location {0}22222/htdocs/files"
.format(WOVariables.wo_webroot))
WOExtract.extract(self, '/var/lib/wo/tmp/extplorer.tar.gz',
'/var/lib/wo/tmp/')
shutil.move('/var/lib/wo/tmp/extplorer-{0}'
.format(WOVariables.wo_extplorer),
'{0}22222/htdocs/files'
.format(WOVariables.wo_webroot))
Log.debug(self, "Setting Privileges to " Log.debug(self, "Setting Privileges to "
"{0}22222/htdocs/files" "{0}22222/htdocs"
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
WOFileUtils.chown(self, '{0}22222/htdocs' WOFileUtils.chown(self, '{0}22222/htdocs'
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
@@ -1414,6 +1387,27 @@ def post_pref(self, apt_packages, packages, upgrade=False):
'www-data', 'www-data',
recursive=True) recursive=True)
# Extplorer FileManager
if any('/var/lib/wo/tmp/extplorer.tar.gz' == x[1]
for x in packages):
Log.debug(self, "Extracting extplorer.tar.gz "
"to location {0}22222/htdocs/files"
.format(WOVariables.wo_webroot))
WOExtract.extract(self, '/var/lib/wo/tmp/extplorer.tar.gz',
'/var/lib/wo/tmp/')
shutil.move('/var/lib/wo/tmp/extplorer-{0}'
.format(WOVariables.wo_extplorer),
'{0}22222/htdocs/files'
.format(WOVariables.wo_webroot))
Log.debug(self, "Setting Privileges to "
"{0}22222/htdocs/files"
.format(WOVariables.wo_webroot))
WOFileUtils.chown(self, '{0}22222/htdocs'
.format(WOVariables.wo_webroot),
'www-data',
'www-data',
recursive=True)
# webgrind # webgrind
if any('/var/lib/wo/tmp/webgrind.tar.gz' == x[1] if any('/var/lib/wo/tmp/webgrind.tar.gz' == x[1]
for x in packages): for x in packages):