Browse Source

Merge branch 'master' into stable

stable v3.1.1
gau1991 10 years ago
parent
commit
89a76b60a9
  1. 9
      CHANGELOG.txt
  2. 22
      config/bash_completion.d/ee_auto.rc
  3. 143
      ee/cli/plugins/debug.py
  4. 45
      ee/cli/plugins/import_slow_log.py
  5. 172
      ee/cli/plugins/site.py
  6. 56
      ee/cli/plugins/site_functions.py
  7. 8
      ee/cli/plugins/stack.py
  8. 4
      ee/cli/templates/virtualconf.mustache
  9. 4
      ee/core/variables.py
  10. 8
      install
  11. 2
      setup.py

9
CHANGELOG.txt

@ -1,3 +1,12 @@
v 3.1.1 - April 21, 2015
- Feature: update all site at once #491
- Tweaked import-slow-log command #322
- Fixed HHVM installation without Nginx #492
- Fixed HHVM not running after reboot #498
- Fixed Nginx config on Debian causing failure in site creation #499
- Now support for existing HHVM on server
- Minor fixes and improvements
v 3.1.0 - April 16, 2015 v 3.1.0 - April 16, 2015
- Added HHVM support #199 - Added HHVM support #199
- Added Pagespeed support #473 - Added Pagespeed support #473

22
config/bash_completion.d/ee_auto.rc

@ -29,7 +29,7 @@ _ee_complete()
# IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE # IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE
"debug") "debug")
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql -i --interactive --all --nginx=off --php=off --fpm=off --mysql=off --all=off " \ -W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql -i --interactive --all --import-slow-log --import-slow-log-interval= --nginx=off --php=off --fpm=off --mysql=off --all=off " \
-- $cur) ) -- $cur) )
;; ;;
@ -93,7 +93,7 @@ _ee_complete()
-- $cur) ) -- $cur) )
;; ;;
"edit" | "enable" | "info" | "log" | "show" | "cd" | "update" | "delete") "edit" | "enable" | "info" | "log" | "show" | "cd" | "delete")
if [ ${COMP_WORDS[1]} == "log" ]; then if [ ${COMP_WORDS[1]} == "log" ]; then
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql --access" \ -W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql --access" \
@ -104,7 +104,11 @@ _ee_complete()
-- $cur) ) -- $cur) )
fi fi
;; ;;
"update")
COMPREPLY=( $(compgen \
-W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null) --all" \
-- $cur) )
;;
"gzip") "gzip")
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql --access" \ -W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql --access" \
@ -133,7 +137,7 @@ _ee_complete()
;; ;;
esac esac
if [ ${COMP_WORDS[1]} == "debug" ] && ([ "$prev" != "--start" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]); then if [ ${COMP_WORDS[1]} == "debug" ] && ([ "$prev" != "--start" ] && [ "$prev" != "--nginx" ] && [ "$prev" != "--php" ] && [ "$prev" != "--fpm" ] && [ "$prev" != "--mysql" ] && [ "$prev" != "-i" ] && [ "$prev" != "--interactive" ] && [ "$prev" != "--import-slow-log" ] && [ "$prev" != "--stop" ]); then
retlist="--all --wp --rewrite -i --all=off --wp=off --rewrite=off" retlist="--all --wp --rewrite -i --all=off --wp=off --rewrite=off"
ret="${retlist[@]/$prev}" ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
@ -224,7 +228,7 @@ _ee_complete()
elif [[ ${COMP_WORDS[2]} == "start" || ${COMP_WORDS[2]} == "reload" || ${COMP_WORDS[2]} == "restart" || ${COMP_WORDS[2]} == "stop" ]]; then elif [[ ${COMP_WORDS[2]} == "start" || ${COMP_WORDS[2]} == "reload" || ${COMP_WORDS[2]} == "restart" || ${COMP_WORDS[2]} == "stop" ]]; then
retlist="--nginx --php --mysql --postfix --memcache --dovecot" retlist="--nginx --php --mysql --postfix --memcache --dovecot"
elif [[ ${COMP_WORDS[1]} == "debug" ]]; then elif [[ ${COMP_WORDS[1]} == "debug" ]]; then
retlist="--start --nginx --php --fpm --mysql -i --interactive --stop" retlist="--start --nginx --php --fpm --mysql -i --interactive -stop --import-slow-log --import-slow-log-interval= -"
if [[ $prev == '--mysql' ]]; then if [[ $prev == '--mysql' ]]; then
retlist="--start --nginx --php --fpm --mysql -i --interactive --stop --import-slow-log" retlist="--start --nginx --php --fpm --mysql -i --interactive --stop --import-slow-log"
fi fi
@ -235,7 +239,6 @@ _ee_complete()
elif [ ${COMP_WORDS[2]} == "reset" ]; then elif [ ${COMP_WORDS[2]} == "reset" ]; then
retlist="--access --nginx --php --mysql --fpm --wp --slow-log-db" retlist="--access --nginx --php --mysql --fpm --wp --slow-log-db"
elif [ ${COMP_WORDS[2]} == "mail" ]; then elif [ ${COMP_WORDS[2]} == "mail" ]; then
retlist="--access --nginx --php --mysql --fpm --wp --to=" retlist="--access --nginx --php --mysql --fpm --wp --to="
@ -258,9 +261,12 @@ _ee_complete()
"--all") "--all")
if [ ${COMP_WORDS[1]} == "clean" ]; then if [ ${COMP_WORDS[1]} == "clean" ]; then
retlist="--memcache --opcache --fastcgi" retlist="--memcache --opcache --fastcgi"
else elif [ ${COMP_WORDS[2]} == "delete" ]; then
retlist="--db --files" retlist="--db --files"
elif [ ${COMP_WORDS[2]} == "update" ]; then
retlist="--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off"
else
retlist=""
fi fi
ret="${retlist[@]/$prev}" ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \

143
ee/cli/plugins/debug.py

@ -2,7 +2,7 @@
from cement.core.controller import CementBaseController, expose from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook from cement.core import handler, hook
from ee.core.shellexec import EEShellExec from ee.core.shellexec import *
from ee.core.mysql import EEMysql from ee.core.mysql import EEMysql
from ee.core.services import EEService from ee.core.services import EEService
from ee.core.logging import Log from ee.core.logging import Log
@ -32,6 +32,9 @@ class EEDebugController(CementBaseController):
dict(help='Stop debug', action='store_true')), dict(help='Stop debug', action='store_true')),
(['--start'], (['--start'],
dict(help='Start debug', action='store_true')), dict(help='Start debug', action='store_true')),
(['--import-slow-log'],
dict(help='Import MySQL slow log to Anemometer database',
action='store_true')),
(['--nginx'], (['--nginx'],
dict(help='start/stop debugging nginx server ' dict(help='start/stop debugging nginx server '
'configuration for site', 'configuration for site',
@ -268,21 +271,6 @@ class EEDebugController(CementBaseController):
EEMysql.execute(self, "set global long_query_time = 2;") EEMysql.execute(self, "set global long_query_time = 2;")
EEMysql.execute(self, "set global log_queries_not_using" EEMysql.execute(self, "set global log_queries_not_using"
"_indexes = \'ON\';") "_indexes = \'ON\';")
if self.app.pargs.interval:
try:
cron_time = int(self.app.pargs.interval)
except Exception as e:
cron_time = 5
EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
"2> /dev/null | {{ cat; echo -e"
" \\\"#EasyEngine start MySQL "
"slow log \\n*/{0} * * * * "
"/usr/local/bin/ee "
"import-slow-log\\n"
"#EasyEngine end MySQL slow log"
"\\\"; }} | crontab -\""
.format(cron_time))
else: else:
Log.info(self, "MySQL slow log is already enabled") Log.info(self, "MySQL slow log is already enabled")
@ -313,6 +301,11 @@ class EEDebugController(CementBaseController):
self.app.pargs.site_name)) self.app.pargs.site_name))
webroot = "{0}{1}".format(EEVariables.ee_webroot, webroot = "{0}{1}".format(EEVariables.ee_webroot,
self.app.pargs.site_name) self.app.pargs.site_name)
# Check wp-config.php file into htdocs folder
if not os.path.isfile(wp_config):
wp_config = ("{0}/{1}/htdocs/wp-config.php"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name))
if os.path.isfile(wp_config): if os.path.isfile(wp_config):
if not EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} |" if not EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} |"
" grep true".format(wp_config)): " grep true".format(wp_config)):
@ -344,7 +337,7 @@ class EEDebugController(CementBaseController):
self.app.pargs.site_name)] self.app.pargs.site_name)]
else: else:
Log.info(self, "{0} domain not valid" Log.info(self, "Unable to find wp-config.php for site: {0}"
.format(self.app.pargs.site_name)) .format(self.app.pargs.site_name))
elif (self.app.pargs.wp == 'off' and self.app.pargs.site_name): elif (self.app.pargs.wp == 'off' and self.app.pargs.site_name):
@ -353,6 +346,11 @@ class EEDebugController(CementBaseController):
self.app.pargs.site_name)) self.app.pargs.site_name))
webroot = "{0}{1}".format(EEVariables.ee_webroot, webroot = "{0}{1}".format(EEVariables.ee_webroot,
self.app.pargs.site_name) self.app.pargs.site_name)
# Check wp-config.php file into htdocs folder
if not os.path.isfile(wp_config):
wp_config = ("{0}/{1}/htdocs/wp-config.php"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name))
if os.path.isfile(wp_config): if os.path.isfile(wp_config):
if EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} | " if EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} | "
"grep true".format(wp_config)): "grep true".format(wp_config)):
@ -484,13 +482,69 @@ class EEDebugController(CementBaseController):
and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql)
and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite)
and (not self.app.pargs.all) and (not self.app.pargs.all)
and (not self.app.pargs.site_name)): and (not self.app.pargs.site_name)
and (not self.app.pargs.import_slow_log)
and (not self.app.pargs.interval)):
if self.app.pargs.stop or self.app.pargs.start: if self.app.pargs.stop or self.app.pargs.start:
print("--start/stop option is deprecated since ee3.0.5") print("--start/stop option is deprecated since ee3.0.5")
self.app.args.print_help() self.app.args.print_help()
else: else:
self.app.args.print_help() self.app.args.print_help()
if self.app.pargs.import_slow_log:
self.import_slow_log()
if self.app.pargs.interval:
try:
cron_time = int(self.app.pargs.interval)
except Exception as e:
cron_time = 5
try:
if not EEShellExec.cmd_exec(self, "crontab -l | grep "
"'ee debug --import-slow-log'"):
if not cron_time == 0:
Log.info(self, "setting up crontab entry,"
" please wait ...")
EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
"2> /dev/null | {{ cat; echo -e"
" \\\"#EasyEngine start MySQL "
"slow log \\n*/{0} * * * * "
"/usr/local/bin/ee debug"
" --import-slow-log\\n"
"#EasyEngine end MySQL slow log"
"\\\"; }} | crontab -\""
.format(cron_time))
else:
if not cron_time == 0:
Log.info(self, "updating crontab entry,"
" please wait ...")
if not EEShellExec.cmd_exec(self, "/bin/bash -c "
"\"crontab "
"-l | sed '/EasyEngine "
"start MySQL slow "
"log/!b;n;c\*\/{0} "
"\* \* \* "
"\* \/usr"
"\/local\/bin\/ee debug "
"--import\-slow\-log' "
"| crontab -\""
.format(cron_time)):
Log.error(self, "failed to update crontab entry")
else:
Log.info(self, "removing crontab entry,"
" please wait ...")
if not EEShellExec.cmd_exec(self, "/bin/bash -c "
"\"crontab "
"-l | sed '/EasyEngine "
"start MySQL slow "
"log/,+2d'"
"| crontab -\""
.format(cron_time)):
Log.error(self, "failed to remove crontab entry")
except CommandExecutionError as e:
Log.debug(self, str(e))
if self.app.pargs.all == 'on': if self.app.pargs.all == 'on':
if self.app.pargs.site_name: if self.app.pargs.site_name:
self.app.pargs.wp = 'on' self.app.pargs.wp = 'on'
@ -559,6 +613,59 @@ class EEDebugController(CementBaseController):
logwatch(self, watch_list) logwatch(self, watch_list)
@expose(hide=True)
def import_slow_log(self):
"""Default function for import slow log"""
if os.path.isdir("{0}22222/htdocs/db/anemometer"
.format(EEVariables.ee_webroot)):
if os.path.isfile("/var/log/mysql/mysql-slow.log"):
# Get Anemometer user name and password
Log.info(self, "Importing MySQL slow log to Anemometer")
host = os.popen("grep -e \"\'host\'\" {0}22222/htdocs/"
.format(EEVariables.ee_webroot)
+ "db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
user = os.popen("grep -e \"\'user\'\" {0}22222/htdocs/"
.format(EEVariables.ee_webroot)
+ "db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
password = os.popen("grep -e \"\'password\'\" {0}22222/"
.format(EEVariables.ee_webroot)
+ "htdocs/db/anemometer/conf"
"/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
# Import slow log Anemometer using pt-query-digest
try:
EEShellExec.cmd_exec(self, "pt-query-digest --user={0} "
"--password={1} "
"--review D=slow_query_log,"
"t=global_query_review "
"--history D=slow_query_log,t="
"global_query_review_history "
"--no-report --limit=0% "
"--filter=\" \\$event->{{Bytes}} = "
"length(\\$event->{{arg}}) "
"and \\$event->{{hostname}}=\\\""
"{2}\\\"\" "
"/var/log/mysql/mysql-slow.log"
.format(user, password, host))
except CommandExecutionError as e:
Log.debug(self, str(e))
Log.error(self, "MySQL slow log import failed.")
else:
Log.error(self, "MySQL slow log file not found,"
" so not imported slow logs")
else:
Log.error(self, "Anemometer is not installed." +
Log.ENDC + "\nYou can install Anemometer with "
"this command "
+ Log.BOLD + "\n `ee stack install --utils`"
+ Log.ENDC)
def load(app): def load(app):
# register the plugin class.. this only happens if the plugin is enabled # register the plugin class.. this only happens if the plugin is enabled

45
ee/cli/plugins/import_slow_log.py

@ -20,47 +20,10 @@ class EEImportslowlogController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def default(self): def default(self):
"""Default function for import slow log""" Log.info(self, "This command is deprecated."
if os.path.isdir("{0}22222/htdocs/db/anemometer" " You can use this command instead, " +
.format(EEVariables.ee_webroot)): Log.ENDC + Log.BOLD + "\n`ee debug --import-slow-log`" +
if os.path.isfile("/var/log/mysql/mysql-slow.log"): Log.ENDC)
# Get Anemometer user name and password
Log.info(self, "Importing MySQL slow log to Anemometer")
host = os.popen("grep -e \"\'host\'\" {0}22222/htdocs/"
.format(EEVariables.ee_webroot)
+ "db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
user = os.popen("grep -e \"\'user\'\" {0}22222/htdocs/"
.format(EEVariables.ee_webroot)
+ "db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
password = os.popen("grep -e \"\'password\'\" {0}22222/"
.format(EEVariables.ee_webroot)
+ "htdocs/db/anemometer/conf"
"/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
# Import slow log Anemometer using pt-query-digest
EEShellExec.cmd_exec(self, "pt-query-digest --user={0} "
"--password={1} "
"--review D=slow_query_log,"
"t=global_query_review "
"--history D=slow_query_log,t="
"global_query_review_history "
"--no-report --limit=0% "
"--filter=\" \\$event->{{Bytes}} = "
"length(\\$event->{{arg}}) "
"and \\$event->{{hostname}}=\\\""
"{2}\\\"\" "
"/var/log/mysql/mysql-slow.log"
.format(user, password, host))
else:
Log.error(self, "Unable to find MySQL slow log file")
else:
Log.error(self, "Anemometer is not installed")
def load(app): def load(app):

172
ee/cli/plugins/site.py

@ -604,34 +604,64 @@ class EESiteUpdateController(CementBaseController):
(['--pagespeed'], (['--pagespeed'],
dict(help='Use PageSpeed for site', dict(help='Use PageSpeed for site',
action='store' or 'store_const', action='store' or 'store_const',
choices=('on', 'off'), const='on', nargs='?')) choices=('on', 'off'), const='on', nargs='?')),
(['--all'],
dict(help="update all sites", action='store_true')),
] ]
@expose(help="Update site type or cache") @expose(help="Update site type or cache")
def default(self): def default(self):
pargs = self.app.pargs
if pargs.all:
if pargs.site_name:
Log.error(self, "`--all` option cannot be used with site name"
" provided")
if pargs.html:
Log.error(self, "No site can be updated to html")
if not (pargs.php or
pargs.mysql or pargs.wp or pargs.wpsubdir or
pargs.wpsubdomain or pargs.w3tc or pargs.wpfc or
pargs.wpsc or pargs.hhvm or pargs.pagespeed):
Log.error(self, "Please provide options to update sites.")
if pargs.all:
sites = getAllsites(self)
if not sites:
pass
else:
for site in sites:
pargs.site_name = site.sitename
Log.info(self, Log.ENDC + Log.BOLD + "Updating site {0},"
" please wait ..."
.format(pargs.site_name))
self.doupdatesite(pargs)
print("\n")
else:
self.doupdatesite(pargs)
def doupdatesite(self, pargs):
hhvm = None hhvm = None
pagespeed = None pagespeed = None
data = dict() data = dict()
try: try:
stype, cache = detSitePar(vars(self.app.pargs)) stype, cache = detSitePar(vars(pargs))
except RuntimeError as e: except RuntimeError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Please provide valid options combination for" Log.error(self, "Please provide valid options combination for"
" site update") " site update")
if not self.app.pargs.site_name: if not pargs.site_name:
try: try:
while not self.app.pargs.site_name: while not pargs.site_name:
self.app.pargs.site_name = (input('Enter site name : ') pargs.site_name = (input('Enter site name : ').strip())
.strip())
except IOError as e: except IOError as e:
Log.error(self, 'Unable to input site name, Please try again!') Log.error(self, 'Unable to input site name, Please try again!')
self.app.pargs.site_name = self.app.pargs.site_name.strip() pargs.site_name = pargs.site_name.strip()
(ee_domain, (ee_domain,
ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) ee_www_domain, ) = ValidateDomain(pargs.site_name)
ee_site_webroot = EEVariables.ee_webroot + ee_domain ee_site_webroot = EEVariables.ee_webroot + ee_domain
check_site = getSiteInfo(self, ee_domain) check_site = getSiteInfo(self, ee_domain)
@ -644,16 +674,20 @@ class EESiteUpdateController(CementBaseController):
old_hhvm = check_site.is_hhvm old_hhvm = check_site.is_hhvm
old_pagespeed = check_site.is_pagespeed old_pagespeed = check_site.is_pagespeed
if (self.app.pargs.password and not (self.app.pargs.html or if (pargs.password and not (pargs.html or
self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or pargs.php or pargs.mysql or pargs.wp or
self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc pargs.w3tc or pargs.wpfc or pargs.wpsc
or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): or pargs.wpsubdir or pargs.wpsubdomain)):
try: try:
updatewpuserpassword(self, ee_domain, ee_site_webroot) updatewpuserpassword(self, ee_domain, ee_site_webroot)
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Password Unchanged.") Log.info(self, "Password Unchanged.")
self.app.close(0) return 0
if stype == "html" and stype == oldsitetype and self.app.pargs.hhvm:
Log.info(self, Log.FAIL + "Can not update HTML site to HHVM")
return 1
if ((stype == 'php' and oldsitetype != 'html') or if ((stype == 'php' and oldsitetype != 'html') or
(stype == 'mysql' and oldsitetype not in ['html', 'php']) or (stype == 'mysql' and oldsitetype not in ['html', 'php']) or
@ -661,9 +695,11 @@ class EESiteUpdateController(CementBaseController):
'wp']) or 'wp']) or
(stype == 'wpsubdir' and oldsitetype in ['wpsubdomain']) or (stype == 'wpsubdir' and oldsitetype in ['wpsubdomain']) or
(stype == 'wpsubdomain' and oldsitetype in ['wpsubdir']) or (stype == 'wpsubdomain' and oldsitetype in ['wpsubdir']) or
(stype == oldsitetype and cache == oldcachetype)): (stype == oldsitetype and cache == oldcachetype) and
Log.error(self, "can not update {0} {1} to {2} {3}". not pargs.pagespeed):
Log.info(self, Log.FAIL + "can not update {0} {1} to {2} {3}".
format(oldsitetype, oldcachetype, stype, cache)) format(oldsitetype, oldcachetype, stype, cache))
return 1
if stype == 'php': if stype == 'php':
data = dict(site_name=ee_domain, www_domain=ee_www_domain, data = dict(site_name=ee_domain, www_domain=ee_www_domain,
@ -691,7 +727,7 @@ class EESiteUpdateController(CementBaseController):
if stype == 'wpsubdir': if stype == 'wpsubdir':
data['wpsubdir'] = True data['wpsubdir'] = True
if self.app.pargs.pagespeed or self.app.pargs.hhvm: if pargs.pagespeed or pargs.hhvm:
if not data: if not data:
data = dict(site_name=ee_domain, www_domain=ee_www_domain, data = dict(site_name=ee_domain, www_domain=ee_www_domain,
currsitetype=oldsitetype, currsitetype=oldsitetype,
@ -748,30 +784,30 @@ class EESiteUpdateController(CementBaseController):
data['wpfc'] = False data['wpfc'] = False
data['wpsc'] = True data['wpsc'] = True
if self.app.pargs.hhvm != 'off': if pargs.hhvm != 'off':
data['hhvm'] = True data['hhvm'] = True
hhvm = True hhvm = True
elif self.app.pargs.hhvm == 'off': elif pargs.hhvm == 'off':
data['hhvm'] = False data['hhvm'] = False
hhvm = False hhvm = False
if self.app.pargs.pagespeed != 'off': if pargs.pagespeed != 'off':
data['pagespeed'] = True data['pagespeed'] = True
pagespeed = True pagespeed = True
elif self.app.pargs.pagespeed == 'off': elif pargs.pagespeed == 'off':
data['pagespeed'] = False data['pagespeed'] = False
pagespeed = False pagespeed = False
if self.app.pargs.pagespeed: if pargs.pagespeed:
if pagespeed is old_pagespeed: if pagespeed is old_pagespeed:
if pagespeed is False: if pagespeed is False:
Log.info(self, "Pagespeed is allready disabled for given " Log.info(self, "Pagespeed is already disabled for given "
"site") "site")
elif pagespeed is True: elif pagespeed is True:
Log.info(self, "Pagespeed is allready enabled for given " Log.info(self, "Pagespeed is allready enabled for given "
"site") "site")
if self.app.pargs.hhvm: if pargs.hhvm:
if hhvm is old_hhvm: if hhvm is old_hhvm:
if hhvm is False: if hhvm is False:
Log.info(self, "HHVM is allready disabled for given " Log.info(self, "HHVM is allready disabled for given "
@ -780,7 +816,7 @@ class EESiteUpdateController(CementBaseController):
Log.info(self, "HHVM is allready enabled for given " Log.info(self, "HHVM is allready enabled for given "
"site") "site")
if data and (not self.app.pargs.hhvm): if data and (not pargs.hhvm):
if old_hhvm is True: if old_hhvm is True:
data['hhvm'] = True data['hhvm'] = True
hhvm = True hhvm = True
@ -788,7 +824,7 @@ class EESiteUpdateController(CementBaseController):
data['hhvm'] = False data['hhvm'] = False
hhvm = False hhvm = False
if data and (not self.app.pargs.pagespeed): if data and (not pargs.pagespeed):
if old_pagespeed is True: if old_pagespeed is True:
data['pagespeed'] = True data['pagespeed'] = True
pagespeed = True pagespeed = True
@ -796,13 +832,13 @@ class EESiteUpdateController(CementBaseController):
data['pagespeed'] = False data['pagespeed'] = False
pagespeed = False pagespeed = False
if self.app.pargs.pagespeed or self.app.pargs.hhvm: if pargs.pagespeed or pargs.hhvm:
if ((hhvm is old_hhvm) and (pagespeed is old_pagespeed) and if ((hhvm is old_hhvm) and (pagespeed is old_pagespeed) and
(stype == oldsitetype and cache == oldcachetype)): (stype == oldsitetype and cache == oldcachetype)):
self.app.close(0) return 1
if not data: if not data:
Log.error(self, " Cannot update {0}, Invalid Options" Log.error(self, "Cannot update {0}, Invalid Options"
.format(ee_domain)) .format(ee_domain))
ee_auth = site_package_check(self, stype) ee_auth = site_package_check(self, stype)
@ -810,23 +846,33 @@ class EESiteUpdateController(CementBaseController):
data['ee_db_user'] = check_site.db_user data['ee_db_user'] = check_site.db_user
data['ee_db_pass'] = check_site.db_password data['ee_db_pass'] = check_site.db_password
data['ee_db_host'] = check_site.db_host data['ee_db_host'] = check_site.db_host
try:
pre_run_checks(self)
except SiteError as e:
Log.debug(self, str(e))
Log.error(self, "NGINX configuration check failed.")
try: try:
sitebackup(self, data) sitebackup(self, data)
except Exception as e: except Exception as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Check logs for reason " Log.info(self, Log.FAIL + "Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
# setup NGINX configuration, and webroot # setup NGINX configuration, and webroot
try: try:
setupdomain(self, data) setupdomain(self, data)
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Update site failed. Check logs for reason " Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason"
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
# Update pagespeed config # Update pagespeed config
if self.app.pargs.pagespeed: if pargs.pagespeed:
operateOnPagespeed(self, data) operateOnPagespeed(self, data)
if stype == oldsitetype and cache == oldcachetype: if stype == oldsitetype and cache == oldcachetype:
@ -839,15 +885,17 @@ class EESiteUpdateController(CementBaseController):
Log.info(self, "Successfully updated site" Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain)) " http://{0}".format(ee_domain))
self.app.close(0) return 0
if 'ee_db_name' in data.keys() and not data['wp']: if data['ee_db_name'] and not data['wp']:
try: try:
data = setupdatabase(self, data) data = setupdatabase(self, data)
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Update site failed. Check logs for reason " Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason"
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
try: try:
eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot), eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot),
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
@ -863,28 +911,10 @@ class EESiteUpdateController(CementBaseController):
except IOError as e: except IOError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.debug(self, "creating ee-config.php failed.") Log.debug(self, "creating ee-config.php failed.")
Log.error(self, "Update site failed. Check logs for reason " Log.info(self, Log.FAIL + "Update site failed. "
"Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
# if oldsitetype == 'mysql':
# # config_file = (ee_site_webroot + '/backup/{0}/ee-config.php'
# # .format(EEVariables.ee_date))
# # data['ee_db_name'] = (EEFileUtils.grep(self, config_file,
# # 'DB_NAME')
# # .split(',')[1]
# # .split(')')[0].strip())
# # data['ee_db_user'] = (EEFileUtils.grep(self, config_file,
# # 'DB_USER')
# # .split(',')[1]
# # .split(')')[0].strip())
# # data['ee_db_pass'] = (EEFileUtils.grep(self, config_file,
# # 'DB_PASSWORD')
# # .split(',')[1]
# # .split(')')[0].strip())
# # data['ee_db_host'] = (EEFileUtils.grep(self, config_file,
# # 'DB_HOST')
# # .split(',')[1]
# # .split(')')[0].strip())
# Setup WordPress if old sites are html/php/mysql sites # Setup WordPress if old sites are html/php/mysql sites
if data['wp'] and oldsitetype in ['html', 'php', 'mysql']: if data['wp'] and oldsitetype in ['html', 'php', 'mysql']:
@ -892,8 +922,10 @@ class EESiteUpdateController(CementBaseController):
ee_wp_creds = setupwordpress(self, data) ee_wp_creds = setupwordpress(self, data)
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Update site failed. Check logs for reason " Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
# Uninstall unnecessary plugins # Uninstall unnecessary plugins
if oldsitetype in ['wp', 'wpsubdir', 'wpsubdomain']: if oldsitetype in ['wp', 'wpsubdir', 'wpsubdomain']:
@ -904,8 +936,10 @@ class EESiteUpdateController(CementBaseController):
setupwordpressnetwork(self, data) setupwordpressnetwork(self, data)
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Update site failed. Check logs for reason" Log.info(self, Log.FAIL + "Update site failed. "
"Check logs for reason"
" `tail /var/log/ee/ee.log` & Try Again!!!") " `tail /var/log/ee/ee.log` & Try Again!!!")
return 1
if (oldcachetype == 'w3tc' or oldcachetype == 'wpfc' and if (oldcachetype == 'w3tc' or oldcachetype == 'wpfc' and
not (data['w3tc'] or data['wpfc'])): not (data['w3tc'] or data['wpfc'])):
@ -913,16 +947,20 @@ class EESiteUpdateController(CementBaseController):
uninstallwp_plugin(self, 'w3-total-cache', data) uninstallwp_plugin(self, 'w3-total-cache', data)
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Update site failed. Check logs for reason" Log.info(self, Log.FAIL + "Update site failed. "
"Check logs for reason"
" `tail /var/log/ee/ee.log` & Try Again!!!") " `tail /var/log/ee/ee.log` & Try Again!!!")
return 1
if oldcachetype == 'wpsc' and not data['wpsc']: if oldcachetype == 'wpsc' and not data['wpsc']:
try: try:
uninstallwp_plugin(self, 'wp-super-cache', data) uninstallwp_plugin(self, 'wp-super-cache', data)
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Update site failed. Check logs for reason" Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason"
" `tail /var/log/ee/ee.log` & Try Again!!!") " `tail /var/log/ee/ee.log` & Try Again!!!")
return 1
if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and (data['w3tc'] if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and (data['w3tc']
or data['wpfc']): or data['wpfc']):
@ -930,17 +968,20 @@ class EESiteUpdateController(CementBaseController):
installwp_plugin(self, 'w3-total-cache', data) installwp_plugin(self, 'w3-total-cache', data)
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Update site failed. Check logs for reason" Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason"
" `tail /var/log/ee/ee.log` & Try Again!!!") " `tail /var/log/ee/ee.log` & Try Again!!!")
return 1
if oldcachetype != 'wpsc' and data['wpsc']: if oldcachetype != 'wpsc' and data['wpsc']:
try: try:
installwp_plugin(self, 'wp-super-cache', data) installwp_plugin(self, 'wp-super-cache', data)
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Update site failed. Check logs for reason " Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
# Service Nginx Reload # Service Nginx Reload
EEService.reload_service(self, 'nginx') EEService.reload_service(self, 'nginx')
@ -952,8 +993,10 @@ class EESiteUpdateController(CementBaseController):
setwebrootpermissions(self, data['webroot']) setwebrootpermissions(self, data['webroot'])
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Update site failed. Check logs for reason " Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
if ee_auth and len(ee_auth): if ee_auth and len(ee_auth):
for msg in ee_auth: for msg in ee_auth:
@ -977,6 +1020,7 @@ class EESiteUpdateController(CementBaseController):
hhvm=hhvm, pagespeed=pagespeed) hhvm=hhvm, pagespeed=pagespeed)
Log.info(self, "Successfully updated site" Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain)) " http://{0}".format(ee_domain))
return 0
class EESiteDeleteController(CementBaseController): class EESiteDeleteController(CementBaseController):

56
ee/cli/plugins/site_functions.py

@ -28,6 +28,20 @@ class SiteError(Exception):
return repr(self.message) return repr(self.message)
def pre_run_checks(self):
# Check nginx configuration
Log.info(self, "Running pre-update checks, please wait ...")
try:
Log.debug(self, "checking NGINX configuration ...")
FNULL = open('/dev/null', 'w')
ret = subprocess.check_call(["nginx", "-t"], stdout=FNULL,
stderr=subprocess.STDOUT)
except CalledProcessError as e:
Log.debug(self, "{0}".format(str(e)))
raise SiteError("nginx configuration check failed.")
def check_domain_exists(self, domain): def check_domain_exists(self, domain):
if getSiteInfo(self, domain): if getSiteInfo(self, domain):
return True return True
@ -534,7 +548,7 @@ def site_package_check(self, stype):
if stype in ['html', 'php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']: if stype in ['html', 'php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for Nginx") Log.debug(self, "Setting apt_packages variable for Nginx")
if EEVariables.ee_platform_distro == 'Debian': if EEVariables.ee_platform_distro == 'debian':
check_nginx = 'nginx-extras' check_nginx = 'nginx-extras'
else: else:
check_nginx = 'nginx-custom' check_nginx = 'nginx-custom'
@ -571,10 +585,44 @@ def site_package_check(self, stype):
if not EEAptGet.is_installed(self, 'hhvm'): if not EEAptGet.is_installed(self, 'hhvm'):
apt_packages = apt_packages + EEVariables.ee_hhvm apt_packages = apt_packages + EEVariables.ee_hhvm
if os.path.isdir("/etc/nginx/common") 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()
# Check if Nginx is allready installed and Pagespeed config there or not # Check if Nginx is allready installed and Pagespeed config there or not
# If not then copy pagespeed config # If not then copy pagespeed config
if self.app.pargs.pagespeed: if self.app.pargs.pagespeed:
if (os.path.isdir('/etc/nginx') and if (os.path.isfile('/etc/nginx/nginx.conf') and
(not os.path.isfile('/etc/nginx/conf.d/pagespeed.conf'))): (not os.path.isfile('/etc/nginx/conf.d/pagespeed.conf'))):
# Pagespeed configuration # Pagespeed configuration
data = dict() data = dict()
@ -649,9 +697,7 @@ def updatewpuserpassword(self, ee_domain, ee_site_webroot):
except CommandExecutionError as e: except CommandExecutionError as e:
raise SiteError("wp user password update command failed") raise SiteError("wp user password update command failed")
Log.info(self, "Password updated successfully") Log.info(self, "Password updated successfully")
if len(ee_wp_pass) < 8:
Log.warn(self, "Warning: You have provided a "
"weak password")
else: else:
Log.error(self, "Invalid WordPress user {0} for {1}." Log.error(self, "Invalid WordPress user {0} for {1}."
.format(ee_wp_user, ee_domain)) .format(ee_wp_user, ee_domain))

8
ee/cli/plugins/stack.py

@ -588,6 +588,9 @@ class EEStackController(CementBaseController):
EEService.reload_service(self, 'php5-fpm') EEService.reload_service(self, 'php5-fpm')
if set(EEVariables.ee_hhvm).issubset(set(apt_packages)): if set(EEVariables.ee_hhvm).issubset(set(apt_packages)):
EEShellExec.cmd_exec(self, "update-rc.d hhvm defaults")
EEFileUtils.searchreplace(self, "/etc/hhvm/server.ini", EEFileUtils.searchreplace(self, "/etc/hhvm/server.ini",
"9000", "8000") "9000", "8000")
EEFileUtils.searchreplace(self, "/etc/nginx/hhvm.conf", EEFileUtils.searchreplace(self, "/etc/nginx/hhvm.conf",
@ -624,9 +627,8 @@ class EEStackController(CementBaseController):
EEGit.add(self, ["/etc/hhvm"], msg="Adding HHVM into Git") EEGit.add(self, ["/etc/hhvm"], msg="Adding HHVM into Git")
EEService.restart_service(self, 'hhvm') EEService.restart_service(self, 'hhvm')
EEService.reload_service(self, 'nginx')
if os.path.isdir("/etc/nginx") and (not if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/common/php-hhvm.conf")): os.path.isfile("/etc/nginx/common/php-hhvm.conf")):
data = dict() data = dict()
@ -662,6 +664,8 @@ class EEStackController(CementBaseController):
out=ee_nginx) out=ee_nginx)
ee_nginx.close() ee_nginx.close()
EEService.reload_service(self, 'nginx')
if set(EEVariables.ee_mysql).issubset(set(apt_packages)): if set(EEVariables.ee_mysql).issubset(set(apt_packages)):
# TODO: Currently we are using, we need to remove it in future # TODO: Currently we are using, we need to remove it in future
# config = configparser.ConfigParser() # config = configparser.ConfigParser()

4
ee/cli/templates/virtualconf.mustache

@ -27,8 +27,8 @@ server {
} }
{{/static}} {{/static}}
{{^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}} {{^static}}include {{^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}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}}
{{#wp}}include common/wpcommon.conf;{{/wp}} {{#wp}}include common/wpcommon.conf;{{/wp}}
include common/locations.conf; include common/locations.conf;
{{^vma}}{{^rc}}include {{webroot}}/conf/nginx/*.conf;{{/rc}}{{/vma}} {{^vma}}{{^rc}}include {{webroot}}/conf/nginx/*.conf;{{/rc}}{{/vma}}

4
ee/core/variables.py

@ -12,11 +12,11 @@ class EEVariables():
"""Intialization of core variables""" """Intialization of core variables"""
# EasyEngine version # EasyEngine version
ee_version = "3.1.0" ee_version = "3.1.1"
# EasyEngine packages versions # EasyEngine packages versions
ee_wp_cli = "0.18.0" ee_wp_cli = "0.18.0"
ee_adminer = "4.1.0" ee_adminer = "4.2.1"
ee_roundcube = "1.1.1" ee_roundcube = "1.1.1"
ee_vimbadmin = "3.0.11" ee_vimbadmin = "3.0.11"

8
install

@ -48,7 +48,7 @@ fi
# Define variables for later use # Define variables for later use
ee_branch=$1 ee_branch=$1
readonly ee_version_old="2.2.3" readonly ee_version_old="2.2.3"
readonly ee_version_new="3.1.0" readonly ee_version_new="3.1.1"
readonly ee_log_dir=/var/log/ee/ readonly ee_log_dir=/var/log/ee/
readonly ee_install_log=/var/log/ee/install.log readonly ee_install_log=/var/log/ee/install.log
readonly ee_linux_distro=$(lsb_release -i | awk '{print $3}') readonly ee_linux_distro=$(lsb_release -i | awk '{print $3}')
@ -299,6 +299,12 @@ function ee_update_latest()
fi fi
fi fi
fi fi
# Fix HHVM autostart on reboot
dpkg -l | grep hhvm &>> /dev/null
if [ $? -eq 0 ]; then
sudo update-rc.d hhvm defaults &>> /dev/null
fi
} }
# Do git intialisation # Do git intialisation

2
setup.py

@ -54,7 +54,7 @@ except Exception as e:
os.system("git config --global user.email {0}".format(ee_email)) os.system("git config --global user.email {0}".format(ee_email))
setup(name='ee', setup(name='ee',
version='3.1.0', version='3.1.1',
description=long_description, description=long_description,
long_description=long_description, long_description=long_description,
classifiers=[], classifiers=[],

Loading…
Cancel
Save