Browse Source

Merged backlog into master

bugfixes
gau1991 10 years ago
parent
commit
50c6338296
  1. 6
      config/bash_completion.d/ee_auto.rc
  2. 16
      ee/cli/plugins/clean.py
  3. 8
      ee/cli/plugins/debug.py
  4. 395
      ee/cli/plugins/log.py
  5. 160
      ee/cli/plugins/site.py
  6. 39
      ee/cli/plugins/site_functions.py
  7. 14
      ee/cli/plugins/sitedb.py
  8. 179
      ee/cli/plugins/stack.py
  9. 52
      ee/cli/plugins/stack_services.py
  10. 1
      ee/cli/templates/fastcgi.mustache
  11. 39
      ee/cli/templates/pagespeed-common.mustache
  12. 21
      ee/cli/templates/pagespeed-global.mustache
  13. 10
      ee/cli/templates/php-hhvm.mustache
  14. 5
      ee/cli/templates/upstream.mustache
  15. 3
      ee/cli/templates/virtualconf.mustache
  16. 31
      ee/cli/templates/w3tc-hhvm.mustache
  17. 36
      ee/cli/templates/wpfc-hhvm.mustache
  18. 31
      ee/cli/templates/wpsc-hhvm.mustache
  19. 1
      ee/core/fileutils.py
  20. 33
      ee/core/sendmail.py
  21. 16
      ee/core/variables.py
  22. 5
      install

6
config/bash_completion.d/ee_auto.rc

@ -22,7 +22,7 @@ _ee_complete()
# HANDLE EVERYTHING AFTER THE SECOND LEVEL NAMESPACE
"clean")
COMPREPLY=( $(compgen \
-W "--memcache --opcache --fastcgi --all" \
-W "--memcache --opcache --fastcgi --pagespeed --all" \
-- $cur) )
;;
@ -132,13 +132,13 @@ _ee_complete()
"create")
COMPREPLY=( $(compgen \
-W "--html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc" \
-W "--html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed" \
-- $cur) )
;;
"update")
COMPREPLY=( $(compgen \
-W "--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc" \
-W "--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off" \
-- $cur) )
;;
"delete")

16
ee/cli/plugins/clean.py

@ -29,7 +29,9 @@ class EECleanController(CementBaseController):
(['--memcache'],
dict(help='Clean MemCache', action='store_true')),
(['--opcache'],
dict(help='Clean OpCache', action='store_true'))
dict(help='Clean OpCache', action='store_true')),
(['--pagespeed'],
dict(help='Clean Pagespeed Cache', action='store_true')),
]
usage = "ee clean [options]"
@ -42,12 +44,15 @@ class EECleanController(CementBaseController):
self.clean_memcache()
self.clean_fastcgi()
self.clean_opcache()
self.clean_pagespeed()
if self.app.pargs.fastcgi:
self.clean_fastcgi()
if self.app.pargs.memcache:
self.clean_memcache()
if self.app.pargs.opcache:
self.clean_opcache()
if self.app.pargs.pagespeed:
self.clean_pagespeed()
@expose(hide=True)
def clean_memcache(self):
@ -82,6 +87,15 @@ class EECleanController(CementBaseController):
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to clean OpCache")
@expose(hide=True)
def clean_pagespeed(self):
"""This function clears Pagespeed cache"""
if(os.path.isdir("/var/ngx_pagespeed_cache")):
Log.info(self, "Cleaning PageSpeed cache")
EEShellExec.cmd_exec(self, "rm -rf /var/ngx_pagespeed_cache/*")
else:
Log.error(self, "Unable to clean Pagespeed cache")
def load(app):
# register the plugin class.. this only happens if the plugin is enabled

8
ee/cli/plugins/debug.py

@ -164,9 +164,9 @@ class EEDebugController(CementBaseController):
"conf.d/upstream.conf "
"| grep 9001")):
Log.info(self, "Enabling PHP debug")
data = dict(php="9001", debug="9001")
Log.info(self, 'Writting the Nginx debug configration to file '
'/etc/nginx/conf.d/upstream.conf ')
data = dict(php="9001", debug="9001", hhvm="9001")
Log.debug(self, 'Writting the Nginx debug configration to file'
' /etc/nginx/conf.d/upstream.conf ')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'upstream.mustache', out=ee_nginx)
@ -190,7 +190,7 @@ class EEDebugController(CementBaseController):
"/etc/nginx/conf.d/upstream.conf "
"| grep 9001"):
Log.info(self, "Disabling PHP debug")
data = dict(php="9000", debug="9001")
data = dict(php="9000", debug="9001", hhvm="8000")
Log.debug(self, 'Writting the Nginx debug configration to file'
' /etc/nginx/conf.d/upstream.conf ')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf',

395
ee/cli/plugins/log.py

@ -7,8 +7,11 @@ from ee.cli.plugins.site_functions import logwatch
from ee.core.variables import EEVariables
from ee.core.fileutils import EEFileUtils
from ee.core.shellexec import EEShellExec
from ee.core.sendmail import EESendMail
from ee.core.mysql import EEMysql
import os
import glob
import gzip
def ee_log_hook(app):
@ -134,8 +137,400 @@ class EELogController(CementBaseController):
logwatch(self, watch_list)
class EELogResetController(CementBaseController):
class Meta:
label = 'reset'
description = 'Reset Nginx, PHP, MySQL log file'
stacked_on = 'log'
stacked_type = 'nested'
arguments = [
(['--all'],
dict(help='Reset All logs file', action='store_true')),
(['--nginx'],
dict(help='Reset Nginx Error logs file', action='store_true')),
(['--php'],
dict(help='Reset PHP Error logs file', action='store_true')),
(['--fpm'],
dict(help='Reset PHP5-fpm slow logs file',
action='store_true')),
(['--mysql'],
dict(help='Reset MySQL logs file', action='store_true')),
(['--wp'],
dict(help='Reset Site specific WordPress logs file',
action='store_true')),
(['--access'],
dict(help='Reset Nginx access log file',
action='store_true')),
(['--slow-log-db'],
dict(help='Drop all rows from slowlog table in database',
action='store_true')),
(['site_name'],
dict(help='Website Name', nargs='?', default=None))
]
usage = "ee log reset [<site_name>] [options]"
@expose(hide=True)
def default(self):
"""Default function of debug"""
self.msg = []
if self.app.pargs.php:
self.app.pargs.nginx = True
if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm)
and (not self.app.pargs.mysql) and (not self.app.pargs.access)
and (not self.app.pargs.wp) and (not self.app.pargs.site_name)
and (not self.app.pargs.slow_log_db)):
self.app.pargs.nginx = True
self.app.pargs.fpm = True
self.app.pargs.mysql = True
self.app.pargs.access = True
self.app.pargs.slow_log_db = True
if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm)
and (not self.app.pargs.mysql) and (not self.app.pargs.access)
and (not self.app.pargs.wp) and (self.app.pargs.site_name)
and (not self.app.pargs.slow-log-db)):
self.app.pargs.nginx = True
self.app.pargs.wp = True
self.app.pargs.access = True
self.app.pargs.mysql = True
if self.app.pargs.slow_log_db:
if os.path.isdir("/var/www/22222/htdocs/db/anemometer"):
Log.info(self, "Resetting MySQL slow_query_log database table")
EEMysql.execute(self, "TRUNCATE TABLE "
"slow_query_log.global_query_review_history")
EEMysql.execute(self, "TRUNCATE TABLE "
"slow_query_log.global_query_review")
if self.app.pargs.nginx and (not self.app.pargs.site_name):
self.msg = self.msg + ["/var/log/nginx/*error.log"]
if self.app.pargs.access and (not self.app.pargs.site_name):
self.msg = self.msg + ["/var/log/nginx/*access.log"]
if self.app.pargs.fpm:
open('/var/log/php5/slow.log', 'a').close()
open('/var/log/php5/fpm.log', 'a').close()
self.msg = self.msg + ['/var/log/php5/slow.log',
'/var/log/php5/fpm.log']
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if EEVariables.ee_mysql_host is "localhost":
if os.path.isfile('/var/log/mysql/mysql-slow.log'):
self.msg = self.msg + ['/var/log/mysql/mysql-slow.log']
else:
Log.error(self, "Unable to find MySQL slow log file,"
"Please generate it using commnad ee debug "
"--mysql")
else:
Log.warn(self, "Remote MySQL found, EasyEngine is not able to"
"show MySQL log file")
if self.app.pargs.site_name:
if self.app.pargs.access:
self.msg = self.msg + ["{0}/{1}/logs/access.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
if self.app.pargs.nginx:
self.msg = self.msg + ["{0}/{1}/logs/error.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
if self.app.pargs.wp:
webroot = "{0}{1}".format(EEVariables.ee_webroot,
self.app.pargs.site_name)
if not os.path.isfile('{0}/logs/debug.log'
.format(webroot)):
if not os.path.isfile('{0}/htdocs/wp-content/debug.log'
.format(webroot)):
open("{0}/htdocs/wp-content/debug.log".format(webroot),
encoding='utf-8', mode='a').close()
EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-"
"content/debug.log"
"".format(webroot,
EEVariables.ee_php_user)
)
# create symbolic link for debug log
EEFileUtils.create_symlink(self, ["{0}/htdocs/wp-content/"
"debug.log"
.format(webroot),
'{0}/logs/debug.log'
.format(webroot)])
self.msg = self.msg + ["{0}/{1}/logs/debug.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
reset_list = []
for r_list in self.msg:
reset_list = reset_list + glob.glob(r_list)
# Clearing content of file
for r_list in reset_list:
Log.info(self, "Resetting file {file}".format(file=r_list))
open(r_list, 'w').close()
class EELogGzipController(CementBaseController):
class Meta:
label = 'gzip'
description = 'GZip Nginx, PHP, MySQL log file'
stacked_on = 'log'
stacked_type = 'nested'
arguments = [
(['--all'],
dict(help='GZip All logs file', action='store_true')),
(['--nginx'],
dict(help='GZip Nginx Error logs file', action='store_true')),
(['--php'],
dict(help='GZip PHP Error logs file', action='store_true')),
(['--fpm'],
dict(help='GZip PHP5-fpm slow logs file',
action='store_true')),
(['--mysql'],
dict(help='GZip MySQL logs file', action='store_true')),
(['--wp'],
dict(help='GZip Site specific WordPress logs file',
action='store_true')),
(['--access'],
dict(help='GZip Nginx access log file',
action='store_true')),
(['site_name'],
dict(help='Website Name', nargs='?', default=None))
]
usage = "ee log gzip [<site_name>] [options]"
@expose(hide=True)
def default(self):
"""Default function of log GZip"""
self.msg = []
if self.app.pargs.php:
self.app.pargs.nginx = True
if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm)
and (not self.app.pargs.mysql) and (not self.app.pargs.access)
and (not self.app.pargs.wp) and (not self.app.pargs.site_name)):
self.app.pargs.nginx = True
self.app.pargs.fpm = True
self.app.pargs.mysql = True
self.app.pargs.access = True
if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm)
and (not self.app.pargs.mysql) and (not self.app.pargs.access)
and (not self.app.pargs.wp) and (self.app.pargs.site_name)):
self.app.pargs.nginx = True
self.app.pargs.wp = True
self.app.pargs.access = True
self.app.pargs.mysql = True
if self.app.pargs.nginx and (not self.app.pargs.site_name):
self.msg = self.msg + ["/var/log/nginx/*error.log"]
if self.app.pargs.access and (not self.app.pargs.site_name):
self.msg = self.msg + ["/var/log/nginx/*access.log"]
if self.app.pargs.fpm:
open('/var/log/php5/slow.log', 'a').close()
open('/var/log/php5/fpm.log', 'a').close()
self.msg = self.msg + ['/var/log/php5/slow.log',
'/var/log/php5/fpm.log']
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if EEVariables.ee_mysql_host is "localhost":
if os.path.isfile('/var/log/mysql/mysql-slow.log'):
self.msg = self.msg + ['/var/log/mysql/mysql-slow.log']
else:
Log.error(self, "Unable to find MySQL slow log file,"
"Please generate it using commnad ee debug "
"--mysql")
else:
Log.warn(self, "Remote MySQL found, EasyEngine is not able to"
"show MySQL log file")
if self.app.pargs.site_name:
if self.app.pargs.access:
self.msg = self.msg + ["{0}/{1}/logs/access.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
if self.app.pargs.nginx:
self.msg = self.msg + ["{0}/{1}/logs/error.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
if self.app.pargs.wp:
webroot = "{0}{1}".format(EEVariables.ee_webroot,
self.app.pargs.site_name)
if not os.path.isfile('{0}/logs/debug.log'
.format(webroot)):
if not os.path.isfile('{0}/htdocs/wp-content/debug.log'
.format(webroot)):
open("{0}/htdocs/wp-content/debug.log".format(webroot),
encoding='utf-8', mode='a').close()
EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-"
"content/debug.log"
"".format(webroot,
EEVariables.ee_php_user)
)
# create symbolic link for debug log
EEFileUtils.create_symlink(self, ["{0}/htdocs/wp-content/"
"debug.log"
.format(webroot),
'{0}/logs/debug.log'
.format(webroot)])
self.msg = self.msg + ["{0}/{1}/logs/debug.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
gzip_list = []
for g_list in self.msg:
gzip_list = gzip_list + glob.glob(g_list)
# Gzip content of file
for g_list in gzip_list:
Log.info(self, "Gzipping file {file}".format(file=g_list))
in_file = g_list
in_data = open(in_file, "rb").read()
out_gz = g_list + ".gz"
gzf = gzip.open(out_gz, "wb")
gzf.write(in_data)
gzf.close()
class EELogMailController(CementBaseController):
class Meta:
label = 'mail'
description = 'Mail Nginx, PHP, MySQL log file'
stacked_on = 'log'
stacked_type = 'nested'
arguments = [
(['--all'],
dict(help='Mail All logs file', action='store_true')),
(['--nginx'],
dict(help='Mail Nginx Error logs file', action='store_true')),
(['--php'],
dict(help='Mail PHP Error logs file', action='store_true')),
(['--fpm'],
dict(help='Mail PHP5-fpm slow logs file',
action='store_true')),
(['--mysql'],
dict(help='Mail MySQL logs file', action='store_true')),
(['--wp'],
dict(help='Mail Site specific WordPress logs file',
action='store_true')),
(['--access'],
dict(help='Mail Nginx access log file',
action='store_true')),
(['site_name'],
dict(help='Website Name', nargs='?', default=None)),
(['--to'],
dict(help='EMail addresses to send log files', action='append',
dest='to', nargs=1, required=True)),
]
usage = "ee log mail [<site_name>] [options]"
@expose(hide=True)
def default(self):
"""Default function of log Mail"""
self.msg = []
if self.app.pargs.php:
self.app.pargs.nginx = True
if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm)
and (not self.app.pargs.mysql) and (not self.app.pargs.access)
and (not self.app.pargs.wp) and (not self.app.pargs.site_name)):
self.app.pargs.nginx = True
self.app.pargs.fpm = True
self.app.pargs.mysql = True
self.app.pargs.access = True
if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm)
and (not self.app.pargs.mysql) and (not self.app.pargs.access)
and (not self.app.pargs.wp) and (self.app.pargs.site_name)):
self.app.pargs.nginx = True
self.app.pargs.wp = True
self.app.pargs.access = True
self.app.pargs.mysql = True
if self.app.pargs.nginx and (not self.app.pargs.site_name):
self.msg = self.msg + ["/var/log/nginx/*error.log"]
if self.app.pargs.access and (not self.app.pargs.site_name):
self.msg = self.msg + ["/var/log/nginx/*access.log"]
if self.app.pargs.fpm:
open('/var/log/php5/slow.log', 'a').close()
open('/var/log/php5/fpm.log', 'a').close()
self.msg = self.msg + ['/var/log/php5/slow.log',
'/var/log/php5/fpm.log']
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if EEVariables.ee_mysql_host is "localhost":
if os.path.isfile('/var/log/mysql/mysql-slow.log'):
self.msg = self.msg + ['/var/log/mysql/mysql-slow.log']
else:
Log.error(self, "Unable to find MySQL slow log file,"
"Please generate it using commnad ee debug "
"--mysql")
else:
Log.warn(self, "Remote MySQL found, EasyEngine is not able to"
"show MySQL log file")
if self.app.pargs.site_name:
if self.app.pargs.access:
self.msg = self.msg + ["{0}/{1}/logs/access.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
if self.app.pargs.nginx:
self.msg = self.msg + ["{0}/{1}/logs/error.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
if self.app.pargs.wp:
webroot = "{0}{1}".format(EEVariables.ee_webroot,
self.app.pargs.site_name)
if not os.path.isfile('{0}/logs/debug.log'
.format(webroot)):
if not os.path.isfile('{0}/htdocs/wp-content/debug.log'
.format(webroot)):
open("{0}/htdocs/wp-content/debug.log".format(webroot),
encoding='utf-8', mode='a').close()
EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-"
"content/debug.log"
"".format(webroot,
EEVariables.ee_php_user)
)
# create symbolic link for debug log
EEFileUtils.create_symlink(self, ["{0}/htdocs/wp-content/"
"debug.log"
.format(webroot),
'{0}/logs/debug.log'
.format(webroot)])
self.msg = self.msg + ["{0}/{1}/logs/debug.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
mail_list = []
for m_list in self.msg:
mail_list = mail_list + glob.glob(m_list)
print(mail_list)
for tomail in self.app.pargs.to:
Log.info(self, "Sending mail to {0}".format(tomail[0]))
EESendMail("easyengine", tomail[0], "{0} Log Files"
.format(EEVariables.ee_fqdn),
"Hey Hi,\n Please find attached server log files"
"\n\n\nYour's faithfully,\nEasyEngine",
files=mail_list, port=25, isTls=False)
def load(app):
# register the plugin class.. this only happens if the plugin is enabled
handler.register(EELogController)
handler.register(EELogResetController)
handler.register(EELogGzipController)
handler.register(EELogMailController)
# register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', ee_log_hook)

160
ee/cli/plugins/site.py

@ -267,6 +267,10 @@ class EESiteCreateController(CementBaseController):
(['--wpsc'],
dict(help="create wordpress single/multi site with wpsc cache",
action='store_true')),
(['--hhvm'],
dict(help="create HHVM site", action='store_true')),
(['--pagespeed'],
dict(help="create pagespeed site", action='store_true')),
]
@expose(hide=True)
@ -324,6 +328,23 @@ class EESiteCreateController(CementBaseController):
if stype == 'wpsubdir':
data['wpsubdir'] = True
if stype == "html" and self.app.pargs.hhvm:
Log.error(self, "Can not create HTML site with HHVM")
if data and self.app.pargs.hhvm:
data['hhvm'] = True
hhvm = 1
elif data:
data['hhvm'] = False
hhvm = 0
if data and self.app.pargs.pagespeed:
data['pagespeed'] = True
pagespeed = 1
elif data:
data['pagespeed'] = False
pagespeed = 0
if not data:
self.app.args.print_help()
self.app.close(1)
@ -345,7 +366,8 @@ class EESiteCreateController(CementBaseController):
Log.error(self, "Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!")
addNewSite(self, ee_domain, stype, cache, ee_site_webroot)
addNewSite(self, ee_domain, stype, cache, ee_site_webroot,
hhvm=hhvm, pagespeed=pagespeed)
# Setup database for MySQL site
if 'ee_db_name' in data.keys() and not data['wp']:
try:
@ -495,11 +517,22 @@ class EESiteUpdateController(CementBaseController):
dict(help="update to wpfc cache", action='store_true')),
(['--wpsc'],
dict(help="update to wpsc cache", action='store_true')),
(['--hhvm'],
dict(help='Use HHVM for site',
action='store' or 'store_const',
choices=('on', 'off'), const='on', nargs='?')),
(['--pagespeed'],
dict(help='Use PageSpeed for site',
action='store' or 'store_const',
choices=('on', 'off'), const='on', nargs='?'))
]
@expose(help="Update site type or cache")
def default(self):
hhvm = None
pagespeed = None
data = dict()
try:
stype, cache = detSitePar(vars(self.app.pargs))
@ -525,6 +558,8 @@ class EESiteUpdateController(CementBaseController):
else:
oldsitetype = check_site.site_type
oldcachetype = check_site.cache_type
old_hhvm = check_site.is_hhvm
old_pagespeed = check_site.is_pagespeed
if (self.app.pargs.password and not (self.app.pargs.html or
self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or
@ -573,6 +608,111 @@ class EESiteUpdateController(CementBaseController):
if stype == 'wpsubdir':
data['wpsubdir'] = True
if self.app.pargs.pagespeed or self.app.pargs.hhvm:
if not data:
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
currsitetype=oldsitetype,
currcachetype=oldcachetype,
webroot=ee_site_webroot)
stype = oldsitetype
cache = oldcachetype
if oldsitetype == 'html':
data['static'] = True
data['wp'] = False
data['multisite'] = False
data['wpsubdir'] = False
elif oldsitetype == 'php' or oldsitetype == 'mysql':
data['static'] = False
data['wp'] = False
data['multisite'] = False
data['wpsubdir'] = False
elif oldsitetype == 'wp':
data['static'] = False
data['wp'] = True
data['multisite'] = False
data['wpsubdir'] = False
elif oldsitetype == 'wpsubdir':
data['static'] = False
data['wp'] = True
data['multisite'] = True
data['wpsubdir'] = True
elif oldsitetype == 'wpsubdomain':
data['static'] = False
data['wp'] = True
data['multisite'] = True
data['wpsubdir'] = False
if oldcachetype == 'basic':
data['basic'] = True
data['w3tc'] = False
data['wpfc'] = False
data['wpsc'] = False
elif oldcachetype == 'w3tc':
data['basic'] = False
data['w3tc'] = True
data['wpfc'] = False
data['wpsc'] = False
elif oldcachetype == 'wpfc':
data['basic'] = False
data['w3tc'] = False
data['wpfc'] = True
data['wpsc'] = False
elif oldcachetype == 'wpsc':
data['basic'] = False
data['w3tc'] = False
data['wpfc'] = False
data['wpsc'] = True
if self.app.pargs.hhvm != 'off':
data['hhvm'] = True
hhvm = True
elif self.app.pargs.hhvm == 'off':
data['hhvm'] = False
hhvm = False
if self.app.pargs.pagespeed != 'off':
data['pagespeed'] = True
pagespeed = True
elif self.app.pargs.pagespeed == 'off':
data['pagespeed'] = False
pagespeed = False
if self.app.pargs.pagespeed:
if pagespeed == old_pagespeed:
if pagespeed is False:
Log.error(self, "Pagespeed is allready disabled for given "
"site")
elif pagespeed is True:
Log.error(self, "Pagespeed is allready enabled for given "
"site")
if self.app.pargs.hhvm:
if hhvm == old_hhvm:
if hhvm is False:
Log.error(self, "HHVM is allready disabled for given "
"site")
elif hhvm is True:
Log.error(self, "HHVM is allready enabled for given "
"site")
if data and (not self.app.pargs.hhvm):
if old_hhvm is True:
data['hhvm'] = True
hhvm = True
else:
data['hhvm'] = False
hhvm = False
if data and (not self.app.pargs.pagespeed):
if old_pagespeed is True:
data['pagespeed'] = True
pagespeed = True
else:
data['pagespeed'] = False
pagespeed = False
if not data:
Log.error(self, " Cannot update {0}, Invalid Options"
.format(ee_domain))
@ -594,6 +734,18 @@ class EESiteUpdateController(CementBaseController):
Log.error(self, "Update site failed. Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!")
if stype == oldsitetype and cache == oldcachetype:
# Service Nginx Reload
EEService.reload_service(self, 'nginx')
updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
hhvm=hhvm, pagespeed=pagespeed)
Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain))
self.app.close(0)
if 'ee_db_name' in data.keys() and not data['wp']:
try:
data = setupdatabase(self, data)
@ -723,9 +875,11 @@ class EESiteUpdateController(CementBaseController):
db_name=data['ee_db_name'],
db_user=data['ee_db_user'],
db_password=data['ee_db_pass'],
db_host=data['ee_db_host'])
db_host=data['ee_db_host'], hhvm=hhvm,
pagespeed=pagespeed)
else:
updateSiteInfo(self, ee_domain, stype=stype, cache=cache)
updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
hhvm=hhvm, pagespeed=pagespeed)
Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain))

39
ee/cli/plugins/site_functions.py

@ -529,7 +529,13 @@ def site_package_check(self, stype):
stack.app = self.app
if stype in ['html', 'php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for Nginx")
if not EEAptGet.is_installed(self, 'nginx-common'):
if EEVariables.ee_platform_distro == 'Debian':
check_nginx = 'nginx-extras'
else:
check_nginx = 'nginx-custom'
if not EEAptGet.is_installed(self, check_nginx):
apt_packages = apt_packages + EEVariables.ee_nginx
if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
@ -555,6 +561,37 @@ def site_package_check(self, stype):
"wp-cli-{0}.phar"
.format(EEVariables.ee_wp_cli),
"/usr/bin/wp", "WP-CLI"]]
if self.app.pargs.hhvm:
Log.debug(self, "Setting apt_packages variable for HHVM")
if not EEAptGet.is_installed(self, 'hhvm'):
apt_packages = apt_packages + EEVariables.ee_hhvm
# Check if Nginx is allready installed and Pagespeed config there or not
# If not then copy pagespeed config
if self.app.pargs.pagespeed:
if (os.path.isdir('/etc/nginx') and
(not os.path.isfile('/etc/nginx/conf.d/pagespeed.conf'))):
# Pagespeed configuration
data = dict()
Log.debug(self, 'Writting the Pagespeed Global '
'configuration to file /etc/nginx/conf.d/'
'pagespeed.conf')
ee_nginx = open('/etc/nginx/conf.d/pagespeed.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'pagespeed-global.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the Pagespeed common '
'configuration to file /etc/nginx/common/'
'pagespeed.conf')
ee_nginx = open('/etc/nginx/common/pagespeed.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'pagespeed-common.mustache',
out=ee_nginx)
ee_nginx.close()
return(stack.install(apt_packages=apt_packages, packages=packages,
disp_msg=False))

14
ee/cli/plugins/sitedb.py

@ -12,13 +12,14 @@ import glob
def addNewSite(self, site, stype, cache, path,
enabled=True, ssl=False, fs='ext4', db='mysql',
db_name=None, db_user=None, db_password=None,
db_host='localhost'):
db_host='localhost', hhvm=0, pagespeed=0):
"""
Add New Site record information into ee database.
"""
try:
newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db,
db_name, db_user, db_password, db_host)
db_name, db_user, db_password, db_host, hhvm,
pagespeed)
db_session.add(newRec)
db_session.commit()
except Exception as e:
@ -40,7 +41,8 @@ def getSiteInfo(self, site):
def updateSiteInfo(self, site, stype='', cache='', webroot='',
enabled=True, ssl=False, fs='', db='', db_name=None,
db_user=None, db_password=None, db_host=None):
db_user=None, db_password=None, db_host=None, hhvm=None,
pagespeed=None):
"""updates site record in database"""
try:
q = SiteDB.query.filter(SiteDB.sitename == site).first()
@ -79,6 +81,12 @@ def updateSiteInfo(self, site, stype='', cache='', webroot='',
if webroot and q.site_path != webroot:
q.site_path = webroot
if (hhvm is not None) and (q.is_hhvm is not hhvm):
q.is_hhvm = hhvm
if (pagespeed is not None) and (q.is_pagespeed is not pagespeed):
q.is_pagespeed = pagespeed
try:
q.created_on = func.now()
db_session.commit()

179
ee/cli/plugins/stack.py

@ -58,6 +58,8 @@ class EEStackController(CementBaseController):
dict(help='Install PHP stack', action='store_true')),
(['--mysql'],
dict(help='Install MySQL stack', action='store_true')),
(['--hhvm'],
dict(help='Install HHVM stack', action='store_true')),
(['--postfix'],
dict(help='Install Postfix stack', action='store_true')),
(['--wpcli'],
@ -166,6 +168,16 @@ class EEStackController(CementBaseController):
Log.debug(self, 'Adding ppa for PHP')
EERepo.add(self, ppa=EEVariables.ee_php_repo)
if set(EEVariables.ee_hhvm).issubset(set(apt_packages)):
Log.info(self, "Adding repository for HHVM, please wait ...")
if EEVariables.ee_platform_codename == 'precise':
Log.debug(self, 'Adding PPA for Boost')
EERepo.add(self, ppa=EEVariables.ee_boost_repo)
Log.debug(self, 'Adding ppa repo for HHVM')
EERepo.add(self, repo_url=EEVariables.ee_hhvm_repo)
Log.debug(self, 'Adding HHVM GPG Key')
EERepo.add_key(self, '0x5a16e7281be7a449')
if set(EEVariables.ee_mail).issubset(set(apt_packages)):
Log.debug(self, 'Executing the command debconf-set-selections.')
try:
@ -229,7 +241,7 @@ class EEStackController(CementBaseController):
self.app.render((data), 'fastcgi.mustache', out=ee_nginx)
ee_nginx.close()
data = dict(php="9000", debug="9001")
data = dict(php="9000", debug="9001", hhvm="8000")
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/upstream.conf ')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf',
@ -261,7 +273,39 @@ class EEStackController(CementBaseController):
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/ php.conf')
'file /etc/nginx/common/php-hhvm.conf')
ee_nginx = open('/etc/nginx/common/php-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/w3tc-hhvm.conf')
ee_nginx = open('/etc/nginx/common/w3tc-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'w3tc-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpfc-hhvm.conf')
ee_nginx = open('/etc/nginx/common/wpfc-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpfc-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsc-hhvm.conf')
ee_nginx = open('/etc/nginx/common/wpsc-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpsc-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/php.conf')
ee_nginx = open('/etc/nginx/common/php.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php.mustache',
@ -308,6 +352,25 @@ class EEStackController(CementBaseController):
out=ee_nginx)
ee_nginx.close()
# Pagespeed configuration
Log.debug(self, 'Writting the Pagespeed Global '
'configuration to file /etc/nginx/conf.d/'
'pagespeed.conf')
ee_nginx = open('/etc/nginx/conf.d/pagespeed.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'pagespeed-global.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the Pagespeed common '
'configuration to file /etc/nginx/common/'
'pagespeed.conf')
ee_nginx = open('/etc/nginx/common/pagespeed.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'pagespeed-common.mustache',
out=ee_nginx)
ee_nginx.close()
# 22222 port settings
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/sites-available/'
@ -533,6 +596,81 @@ class EEStackController(CementBaseController):
EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git")
EEService.reload_service(self, 'php5-fpm')
if set(EEVariables.ee_hhvm).issubset(set(apt_packages)):
EEFileUtils.searchreplace(self, "/etc/hhvm/server.ini",
"9000", "8000")
EEFileUtils.searchreplace(self, "/etc/nginx/hhvm.conf",
"9000", "8000")
with open("/etc/hhvm/php.ini", "a") as hhvm_file:
hhvm_file.write("hhvm.log.header = true\n"
"hhvm.log.natives_stack_trace = true\n"
"hhvm.mysql.socket = "
"/var/run/mysqld/mysqld.sock\n"
"hhvm.pdo_mysql.socket = "
"/var/run/mysqld/mysqld.sock\n"
"hhvm.mysqli.socket = "
"/var/run/mysqld/mysqld.sock\n")
if os.path.isfile("/etc/nginx/conf.d/fastcgi.conf"):
if not EEFileUtils.grep(self, "/etc/nginx/conf.d/"
"fastcgi.conf",
"fastcgi_keep_conn"):
with open("/etc/nginx/conf.d/fastcgi.conf",
"a") as hhvm_file:
hhvm_file.write("fastcgi_keep_conn on;\n")
if os.path.isfile("/etc/nginx/conf.d/upstream.conf"):
if not EEFileUtils.grep(self, "/etc/nginx/conf.d/"
"upstream.conf",
"hhvm"):
with open("/etc/nginx/conf.d/upstream.conf",
"a") as hhvm_file:
hhvm_file.write("upstream hhvm {\nserver "
"127.0.0.1:8000;\n"
"server 127.0.0.1:9000 backup;\n}"
"\n")
EEGit.add(self, ["/etc/hhvm"], msg="Adding HHVM into Git")
EEService.restart_service(self, 'hhvm')
EEService.reload_service(self, 'nginx')
if os.path.isdir("/etc/nginx") and (not
os.path.isfile("/etc/nginx/common/php-hhvm.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/php-hhvm.conf')
ee_nginx = open('/etc/nginx/common/php-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/w3tc-hhvm.conf')
ee_nginx = open('/etc/nginx/common/w3tc-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'w3tc-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpfc-hhvm.conf')
ee_nginx = open('/etc/nginx/common/wpfc-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpfc-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsc-hhvm.conf')
ee_nginx = open('/etc/nginx/common/wpsc-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpsc-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
if set(EEVariables.ee_mysql).issubset(set(apt_packages)):
# TODO: Currently we are using, we need to remove it in future
# config = configparser.ConfigParser()
@ -1223,7 +1361,8 @@ class EEStackController(CementBaseController):
(not self.app.pargs.mail) and (not self.app.pargs.nginx) and
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm)
and
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and
(not self.app.pargs.mailscanner) and (not self.app.pargs.all)):
self.app.pargs.web = True
@ -1235,13 +1374,12 @@ class EEStackController(CementBaseController):
self.app.pargs.mail = True
if self.app.pargs.web:
Log.debug(self, "Setting apt_packages variable for Nginx ,PHP"
" ,MySQL ")
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.mysql = True
self.app.pargs.wpcli = True
self.app.pargs.postfix = True
self.app.pargs.hhvm = True
if self.app.pargs.admin:
self.app.pargs.nginx = True
@ -1285,7 +1423,13 @@ class EEStackController(CementBaseController):
if self.app.pargs.nginx:
Log.debug(self, "Setting apt_packages variable for Nginx")
if not EEAptGet.is_installed(self, 'nginx-common'):
if EEVariables.ee_platform_distro == 'Debian':
check_nginx = 'nginx-extras'
else:
check_nginx = 'nginx-custom'
if not EEAptGet.is_installed(self, check_nginx):
apt_packages = apt_packages + EEVariables.ee_nginx
else:
Log.debug(self, "Nginx already installed")
@ -1297,6 +1441,15 @@ class EEStackController(CementBaseController):
else:
Log.debug(self, "PHP already installed")
Log.info(self, "PHP already installed")
if self.app.pargs.hhvm:
Log.debug(self, "Setting apt packages variable for HHVM")
if not EEAptGet.is_installed(self, 'hhvm'):
apt_packages = apt_packages + EEVariables.ee_hhvm
else:
Log.debug(self, "HHVM already installed")
Log.info(self, "HHVM already installed")
if self.app.pargs.mysql:
Log.debug(self, "Setting apt_packages variable for MySQL")
if not EEShellExec.cmd_exec(self, "mysqladmin ping"):
@ -1432,7 +1585,7 @@ class EEStackController(CementBaseController):
(not self.app.pargs.mail) and (not self.app.pargs.nginx) and
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and
(not self.app.pargs.mailscanner) and (not self.app.pargs.all)):
self.app.pargs.web = True
@ -1446,6 +1599,7 @@ class EEStackController(CementBaseController):
if self.app.pargs.web:
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.hhvm = True
self.app.pargs.mysql = True
self.app.pargs.wpcli = True
self.app.pargs.postfix = True
@ -1476,6 +1630,11 @@ class EEStackController(CementBaseController):
if self.app.pargs.php:
Log.debug(self, "Removing apt_packages variable of PHP")
apt_packages = apt_packages + EEVariables.ee_php
if self.app.pargs.hhvm:
Log.debug(self, "Removing apt_packages varible of HHVM")
apt_packages = apt_packages + EEVariables.ee_hhvm
if self.app.pargs.mysql:
Log.debug(self, "Removing apt_packages variable of MySQL")
apt_packages = apt_packages + EEVariables.ee_mysql
@ -1528,7 +1687,7 @@ class EEStackController(CementBaseController):
(not self.app.pargs.mail) and (not self.app.pargs.nginx) and
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and
(not self.app.pargs.mailscanner) and (not self.app.pargs.all)):
self.app.pargs.web = True
@ -1545,6 +1704,7 @@ class EEStackController(CementBaseController):
self.app.pargs.mysql = True
self.app.pargs.wpcli = True
self.app.pargs.postfix = True
self.app.pargs.hhvm = True
if self.app.pargs.admin:
self.app.pargs.adminer = True
@ -1572,6 +1732,9 @@ class EEStackController(CementBaseController):
if self.app.pargs.php:
Log.debug(self, "Purge apt_packages variable PHP")
apt_packages = apt_packages + EEVariables.ee_php
if self.app.pargs.hhvm:
Log.debug(self, "Removing apt_packages varible of HHVM")
apt_packages = apt_packages + EEVariables.ee_hhvm
if self.app.pargs.mysql:
Log.debug(self, "Purge apt_packages variable MySQL")
apt_packages = apt_packages + EEVariables.ee_mysql

52
ee/cli/plugins/stack_services.py

@ -38,6 +38,9 @@ class EEStackStatusController(CementBaseController):
if self.app.pargs.postfix:
Log.debug(self, "postfix service start")
services = services + ['postfix']
if self.app.pargs.hhvm:
services = services + ['hhvm']
Log.debug(self, "hhvm service start")
if self.app.pargs.memcache:
Log.debug(self, "memcached service start")
services = services + ['memcached']
@ -45,11 +48,12 @@ class EEStackStatusController(CementBaseController):
Log.debug(self, "dovecot service start")
services = services + ['dovecot']
if not services and EEVariables.ee_mysql_host is "localhost":
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
Log.debug(self, "nginx,php5-fpm,mysql,postfix services start")
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix',
'hhvm']
Log.debug(self, "nginx,php5-fpm,mysql,postfix,hhvm services start")
elif not services:
services = services + ['nginx', 'php5-fpm', 'postfix']
Log.debug(self, "nginx,php5-fpm,postfix services start")
services = services + ['nginx', 'php5-fpm', 'postfix', 'hhvm']
Log.debug(self, "nginx,php5-fpm,postfix,hhvm services start")
for service in services:
EEService.start_service(self, service)
@ -74,6 +78,9 @@ class EEStackStatusController(CementBaseController):
if self.app.pargs.postfix:
Log.debug(self, "postfix service stop")
services = services + ['postfix']
if self.app.pargs.hhvm:
services = services + ['hhvm']
Log.debug(self, "hhvm service stop")
if self.app.pargs.memcache:
Log.debug(self, "memcached service stop")
services = services + ['memcached']
@ -81,11 +88,12 @@ class EEStackStatusController(CementBaseController):
Log.debug(self, "dovecot service stop")
services = services + ['dovecot']
if not services and EEVariables.ee_mysql_host is "localhost":
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
Log.debug(self, "nginx,php5-fpm,mysql,postfix services stop")
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix',
'hhvm']
Log.debug(self, "nginx,php5-fpm,mysql,postfix,hhvm services stop")
elif not services:
services = services + ['nginx', 'php5-fpm', 'postfix']
Log.debug(self, "nginx,php5-fpm,postfix services stop")
services = services + ['nginx', 'php5-fpm', 'postfix', 'hhvm']
Log.debug(self, "nginx,php5-fpm,postfix,hhvm services stop")
for service in services:
EEService.stop_service(self, service)
@ -109,6 +117,9 @@ class EEStackStatusController(CementBaseController):
if self.app.pargs.postfix:
Log.debug(self, "postfix service restart")
services = services + ['postfix']
if self.app.pargs.hhvm:
services = services + ['hhvm']
Log.debug(self, "hhvm service restart")
if self.app.pargs.memcache:
Log.debug(self, "memcached service restart")
services = services + ['memcached']
@ -116,11 +127,13 @@ class EEStackStatusController(CementBaseController):
Log.debug(self, "dovecot service restart")
services = services + ['dovecot']
if not services and EEVariables.ee_mysql_host is "localhost":
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart")
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix',
'hhvm']
Log.debug(self, "nginx,php5-fpm,mysql,postfix,hhvm services"
"restart")
elif not services:
services = services + ['nginx', 'php5-fpm', 'postfix']
Log.debug(self, "nginx,php5-fpm,postfix services restart")
services = services + ['nginx', 'php5-fpm', 'postfix', 'hhvm']
Log.debug(self, "nginx,php5-fpm,postfix,hhvm services restart")
for service in services:
EEService.restart_service(self, service)
@ -144,6 +157,9 @@ class EEStackStatusController(CementBaseController):
if self.app.pargs.postfix:
services = services + ['postfix']
Log.debug(self, "postfix service status")
if self.app.pargs.hhvm:
services = services + ['hhvm']
Log.debug(self, "hhvm service status")
if self.app.pargs.memcache:
Log.debug(self, "memcached service status")
services = services + ['memcached']
@ -151,11 +167,13 @@ class EEStackStatusController(CementBaseController):
Log.debug(self, "dovecot service status")
services = services + ['dovecot']
if not services and EEVariables.ee_mysql_host is "localhost":
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
Log.debug(self, "nginx,php5-fpm,mysql,postfix services status")
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix',
'hhvm']
Log.debug(self, "nginx,php5-fpm,mysql,postfix,hhvm services"
" status")
elif not services:
services = services + ['nginx', 'php5-fpm', 'postfix']
Log.debug(self, "nginx,php5-fpm,postfix services status")
services = services + ['nginx', 'php5-fpm', 'postfix', 'hhvm']
Log.debug(self, "nginx,php5-fpm,postfix,hhvm services status")
for service in services:
if EEService.get_service_status(self, service):
Log.info(self, "{0:10}: {1}".format(service, "Running"))
@ -180,6 +198,8 @@ class EEStackStatusController(CementBaseController):
if self.app.pargs.postfix:
Log.debug(self, "postfix service reload")
services = services + ['postfix']
if self.app.pargs.hhvm:
Log.warn(self, "hhvm does not support to reload")
if self.app.pargs.memcache:
Log.debug(self, "memcached service reload")
services = services + ['memcached']

1
ee/cli/templates/fastcgi.mustache

@ -7,3 +7,4 @@ fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SERVER_NAME $http_host;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_keep_conn on;

39
ee/cli/templates/pagespeed-common.mustache

@ -0,0 +1,39 @@
# PageSpeed Admin
location /ngx_pagespeed_statistics { include common/acl.conf; }
location /ngx_pagespeed_global_statistics { include common/acl.conf; }
location /ngx_pagespeed_message { include common/acl.conf; }
location /pagespeed_console { include common/acl.conf; }
location ~ ^/pagespeed_admin { include common/acl.conf; }
location ~ ^/pagespeed_global_admin { include common/acl.conf; }
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
# HTTPS Support
# pagespeed FetchHttps enable;
# PageSpeed Filters
# CSS Minification
# pagespeed EnableFilters combine_css,rewrite_css;
# JS Minification
# pagespeed EnableFilters combine_javascript,rewrite_javascript;
# Images Optimization
#pagespeed EnableFilters lazyload_images;
#pagespeed EnableFilters rewrite_images;
#pagespeed EnableFilters convert_jpeg_to_progressive,convert_png_to_jpeg,convert_jpeg_to_webp,convert_to_webp_lossless;
# Remove comments from HTML
#pagespeed EnableFilters remove_comments;
# Remove WHITESPACE from HTML
#pagespeed EnableFilters collapse_whitespace;
# CDN Support
#pagespeed MapRewriteDomain cdn.example.com www.example.com;

21
ee/cli/templates/pagespeed-global.mustache

@ -0,0 +1,21 @@
# Turning the module on and off
pagespeed on;
# Configuring PageSpeed Filters
pagespeed RewriteLevel PassThrough;
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed MemcachedServers "127.0.0.1:11211";
pagespeed FileCachePath /var/ngx_pagespeed_cache;
# PageSpeed Admin
pagespeed StatisticsPath /ngx_pagespeed_statistics;
pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
pagespeed MessagesPath /ngx_pagespeed_message;
pagespeed ConsolePath /pagespeed_console;
pagespeed AdminPath /pagespeed_admin;
pagespeed GlobalAdminPath /pagespeed_global_admin;
# PageSpeed Cache Purge
pagespeed EnableCachePurge on;
pagespeed PurgeMethod PURGE;

10
ee/cli/templates/php-hhvm.mustache

@ -0,0 +1,10 @@
# PHP NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee)
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass hhvm;
}

5
ee/cli/templates/upstream.mustache

@ -7,3 +7,8 @@ upstream debug {
# Debug Pool
server 127.0.0.1:{{debug}};
}
upstream hhvm {
# HHVM Pool
server 127.0.0.1:{{hhvm}};
server 127.0.0.1:{{php}} backup;
}

3
ee/cli/templates/virtualconf.mustache

@ -27,8 +27,9 @@ server {
}
{{/static}}
{{^static}}include{{/static}} {{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}}
{{^static}}include{{/static}} {{^hhvm}}{{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}} {{/hhvm}}{{#hhvm}}{{#basic}}common/php-hhvm.conf;{{/basic}}{{#w3tc}}common/w3tc-hhvm.conf;{{/w3tc}}{{#wpfc}}common/wpfc-hhvm.conf;{{/wpfc}} {{#wpsc}}common/wpsc-hhvm.conf;{{/wpsc}} {{/hhvm}}
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}
{{#wp}}include common/wpcommon.conf;{{/wp}}
{{#pagespeed}}include common/pagespeed.conf;{{/pagespeed}}
include common/locations.conf;
}

31
ee/cli/templates/w3tc-hhvm.mustache

@ -0,0 +1,31 @@
# W3TC NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee)
set $cache_uri $request_uri;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args;
}
location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ {
try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass hhvm;
}

36
ee/cli/templates/wpfc-hhvm.mustache

@ -0,0 +1,36 @@
# WPFC NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee)
set $skip_cache 0;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ {
try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass hhvm;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
}
location ~ /purge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}

31
ee/cli/templates/wpsc-hhvm.mustache

@ -0,0 +1,31 @@
# WPSC NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee)
set $cache_uri $request_uri;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
# If we add index.php?$args its break WooCommerce like plugins
# Ref: #330
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass hhvm;
# Following line is needed by WP Super Cache plugin
fastcgi_param SERVER_NAME $http_host;
}

1
ee/core/fileutils.py

@ -218,6 +218,7 @@ class EEFileUtils():
for line in open(fnm, encoding='utf-8'):
if sstr in line:
return line
return False
except OSError as e:
Log.debug(self, "{0}".format(e.strerror))
Log.error(self, "Unable to Search string {0} in {1}"

33
ee/core/sendmail.py

@ -0,0 +1,33 @@
import smtplib
import os
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
from email import encoders
def EESendMail(send_from, send_to, subject, text, files, server="localhost",
port=587, username='', password='', isTls=True):
msg = MIMEMultipart()
msg['From'] = send_from
msg['To'] = send_to
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = subject
msg.attach(MIMEText(text))
for f in files:
part = MIMEBase('application', "octet-stream")
part.set_payload(open(f, "rb").read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="{0}"'
.format(os.path.basename(f)))
msg.attach(part)
smtp = smtplib.SMTP(server, port)
if isTls:
smtp.starttls()
smtp.sendmail(send_from, send_to, msg.as_string())
smtp.quit()

16
ee/core/variables.py

@ -73,7 +73,7 @@ class EEVariables():
elif ee_platform_distro == 'debian':
ee_nginx_repo = ("deb http://packages.dotdeb.org {codename} all"
.format(codename=ee_platform_codename))
ee_nginx = ["nginx-full", "nginx-common"]
ee_nginx = ["nginx-extras", "nginx-common"]
# PHP repo and packages
if ee_platform_distro == 'Ubuntu':
@ -116,6 +116,20 @@ class EEVariables():
"arj", "zoo", "nomarch", "lzop", "cabextract", "p7zip",
"rpm", "unrar-free"]
# HHVM repo details
# 12.04 requires boot repository
if ee_platform_distro == 'Ubuntu':
if ee_platform_codename == "precise":
ee_boost_repo = ("ppa:mapnik/boost")
ee_hhvm_repo = ("deb http://dl.hhvm.com/ubuntu {codename} main"
.format(codename=ee_platform_codename))
else:
ee_hhvm_repo = ("deb http://dl.hhvm.com/debian {codename} main"
.format(codename=ee_platform_codename))
ee_hhvm = ["hhvm"]
# Repo path
ee_repo_file = "ee-repo.list"
ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file)

5
install

@ -89,9 +89,9 @@ function ee_install_dep()
{
ee_lib_echo "Installing required packages, please wait..."
if [ "$ee_linux_distro" == "Ubuntu" ]; then
apt-get -y install gcc gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar python-software-properties software-properties-common || ee_lib_error "Unable to install pre depedencies, exit status " 1
apt-get -y install gcc curl gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar python-software-properties software-properties-common || ee_lib_error "Unable to install pre depedencies, exit status " 1
elif [ "$ee_linux_distro" == "Debian" ]; then
apt-get -y install gcc gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar python-software-properties || ee_lib_error "Unable to pre depedencies, exit status " 1
apt-get -y install gcc curl gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar python-software-properties || ee_lib_error "Unable to pre depedencies, exit status " 1
fi
# Generating Locale
@ -222,7 +222,6 @@ function secure_ee_db()
chmod -R 600 /var/lib/ee/
}
# Install EasyEngine 3.x
function ee_install()
{

Loading…
Cancel
Save