Browse Source

Merge branch 'release/v3.3.0'

hotfix/v3.3.3 v3.3.0
harshadyeola 10 years ago
parent
commit
ddd825bb88
  1. 8
      CHANGELOG.txt
  2. 30
      config/bash_completion.d/ee_auto.rc
  3. 29
      ee/cli/plugins/clean.py
  4. 43
      ee/cli/plugins/debug.py
  5. 113
      ee/cli/plugins/site.py
  6. 153
      ee/cli/plugins/site_functions.py
  7. 205
      ee/cli/plugins/stack.py
  8. 43
      ee/cli/plugins/stack_services.py
  9. 65
      ee/cli/plugins/stack_upgrade.py
  10. 57
      ee/cli/templates/redis-hhvm.mustache
  11. 57
      ee/cli/templates/redis.mustache
  12. 4
      ee/cli/templates/virtualconf.mustache
  13. 2
      ee/core/extract.py
  14. 19
      ee/core/variables.py
  15. 2
      install
  16. 2
      setup.py

8
CHANGELOG.txt

@ -1,3 +1,11 @@
v 3.3.0 - Jul 13, 2015
- Added support for Redis full page cache
- Added support to update WPCLI
- Added support for custom WPCLI location
- Updated WPCLI to v0.19.2
- Refined ee site update command
- autoconfigure nginx-helper plugin
v 3.2.2 - Jun 19, 2015 v 3.2.2 - Jun 19, 2015
- Fixed bug that was preventing disabling debug - Fixed bug that was preventing disabling debug

30
config/bash_completion.d/ee_auto.rc

@ -74,17 +74,17 @@ _ee_complete()
# HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE # HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE
"install" | "purge" | "remove" ) "install" | "purge" | "remove" )
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "--pagespeed --web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --all --mailscanner --hhvm" \ -W "--pagespeed --web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --all --mailscanner --hhvm --redis --phpredisadmin" \
-- $cur) ) -- $cur) )
;; ;;
"upgrade" ) "upgrade" )
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "--web --mail --nginx --php --mysql --postfix --all --hhvm --php56 --no-prompt" \ -W "--web --mail --nginx --php --mysql --postfix --all --hhvm --php56 --no-prompt --wpcli" \
-- $cur) ) -- $cur) )
;; ;;
"start" | "stop" | "reload" | "restart" | "status") "start" | "stop" | "reload" | "restart" | "status")
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "--nginx --php --mysql --postfix --memcache --dovecot" \ -W "--nginx --php --mysql --postfix --memcache --dovecot --redis" \
-- $cur) ) -- $cur) )
;; ;;
"migrate") "migrate")
@ -165,13 +165,13 @@ _ee_complete()
"create") "create")
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --proxy= --pagespeed" \ -W "--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --proxy= --pagespeed --wpredis" \
-- $cur) ) -- $cur) )
;; ;;
"update") "update")
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off" \ -W "--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off --wpredis" \
-- $cur) ) -- $cur) )
;; ;;
"delete") "delete")
@ -217,9 +217,9 @@ _ee_complete()
"--wp" | "--wpsubdir" | "--wpsubdomain") "--wp" | "--wpsubdir" | "--wpsubdomain")
if [ ${COMP_WORDS[1]} != "debug" ]; then if [ ${COMP_WORDS[1]} != "debug" ]; then
if [ ${COMP_WORDS[2]} == "create" ]; then if [ ${COMP_WORDS[2]} == "create" ]; then
retlist="--w3tc --wpfc --wpsc --pagespeed --hhvm --user --email --pass" retlist="--w3tc --wpfc --wpsc --pagespeed --hhvm --user --email --pass --wpredis"
elif [ ${COMP_WORDS[2]} == "update" ]; then elif [ ${COMP_WORDS[2]} == "update" ]; then
retlist="--w3tc --wpfc --wpsc --pagespeed --hhvm --pagespeed=off --hhvm=off" retlist="--w3tc --wpfc --wpsc --pagespeed --hhvm --pagespeed=off --hhvm=off --wpredis"
else else
retlist="" retlist=""
fi fi
@ -233,11 +233,11 @@ _ee_complete()
-- $cur) ) -- $cur) )
;; ;;
"--pagespeed" | "--hhvm") "--pagespeed" | "--hhvm" | "--wpredis" )
if [ ${COMP_WORDS[2]} == "create" ]; then if [ ${COMP_WORDS[2]} == "create" ]; then
retlist="--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed --experimenal" retlist="--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed --experimenal --wpredis"
elif [ ${COMP_WORDS[2]} == "update" ]; then elif [ ${COMP_WORDS[2]} == "update" ]; then
retlist="--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off --experimenal" retlist="--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off --experimenal --wpredis"
else else
retlist="" retlist=""
fi fi
@ -248,11 +248,11 @@ _ee_complete()
-- $cur) ) -- $cur) )
;; ;;
"--web" | "--admin" | "--mail" | "--nginx" | "--php" | "--mysql" | "--postfix" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--memcache" | "--dovecot") "--web" | "--admin" | "--mail" | "--nginx" | "--php" | "--mysql" | "--postfix" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--memcache" | "--dovecot" | "--redis | --phpredisadmin")
if [[ ${COMP_WORDS[2]} == "install" || ${COMP_WORDS[2]} == "purge" || ${COMP_WORDS[2]} == "remove" ]]; then if [[ ${COMP_WORDS[2]} == "install" || ${COMP_WORDS[2]} == "purge" || ${COMP_WORDS[2]} == "remove" ]]; then
retlist="--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot" retlist="--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot --redis --phpredisadmin"
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 --redis"
elif [[ ${COMP_WORDS[1]} == "debug" ]]; then elif [[ ${COMP_WORDS[1]} == "debug" ]]; then
retlist="--start --nginx --php --fpm --mysql -i --interactive -stop --import-slow-log --import-slow-log-interval= -" retlist="--start --nginx --php --fpm --mysql -i --interactive -stop --import-slow-log --import-slow-log-interval= -"
if [[ $prev == '--mysql' ]]; then if [[ $prev == '--mysql' ]]; then
@ -290,7 +290,7 @@ _ee_complete()
elif [ ${COMP_WORDS[2]} == "delete" ]; then elif [ ${COMP_WORDS[2]} == "delete" ]; then
retlist="--db --files" retlist="--db --files"
elif [ ${COMP_WORDS[2]} == "update" ]; then elif [ ${COMP_WORDS[2]} == "update" ]; then
retlist="--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off" retlist="--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off --wpredis"
else else
retlist="" retlist=""
fi fi
@ -339,7 +339,7 @@ _ee_complete()
case "$mprev" in case "$mprev" in
"--user" | "--email" | "--pass") "--user" | "--email" | "--pass")
if [ ${COMP_WORDS[2]} == "create" ]; then if [ ${COMP_WORDS[2]} == "create" ]; then
retlist="--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed" retlist="--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed --wpredis"
fi fi
ret="${retlist[@]/$prev}" ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \

29
ee/cli/plugins/clean.py

@ -32,6 +32,8 @@ class EECleanController(CementBaseController):
dict(help='Clean OpCache', action='store_true')), dict(help='Clean OpCache', action='store_true')),
(['--pagespeed'], (['--pagespeed'],
dict(help='Clean Pagespeed Cache', action='store_true')), dict(help='Clean Pagespeed Cache', action='store_true')),
(['--redis'],
dict(help='Clean Redis Cache', action='store_true')),
] ]
usage = "ee clean [options]" usage = "ee clean [options]"
@ -39,12 +41,13 @@ class EECleanController(CementBaseController):
def default(self): def default(self):
if (not (self.app.pargs.all or self.app.pargs.fastcgi or if (not (self.app.pargs.all or self.app.pargs.fastcgi or
self.app.pargs.memcache or self.app.pargs.opcache or self.app.pargs.memcache or self.app.pargs.opcache or
self.app.pargs.pagespeed)): self.app.pargs.pagespeed or self.app.pargs.redis)):
self.clean_fastcgi() self.clean_fastcgi()
if self.app.pargs.all: if self.app.pargs.all:
self.clean_memcache() self.clean_memcache()
self.clean_fastcgi() self.clean_fastcgi()
self.clean_opcache() self.clean_opcache()
self.clean_redis()
self.clean_pagespeed() self.clean_pagespeed()
if self.app.pargs.fastcgi: if self.app.pargs.fastcgi:
self.clean_fastcgi() self.clean_fastcgi()
@ -54,6 +57,17 @@ class EECleanController(CementBaseController):
self.clean_opcache() self.clean_opcache()
if self.app.pargs.pagespeed: if self.app.pargs.pagespeed:
self.clean_pagespeed() self.clean_pagespeed()
if self.app.pargs.redis:
self.clean_redis()
@expose(hide=True)
def clean_redis(self):
"""This function clears Redis cache"""
if(EEAptGet.is_installed(self, "redis-server")):
Log.info(self, "Cleaning Redis cache")
EEShellExec.cmd_exec(self, "redis-cli flushall")
else:
Log.info(self, "Redis is not installed")
@expose(hide=True) @expose(hide=True)
def clean_memcache(self): def clean_memcache(self):
@ -63,7 +77,7 @@ class EECleanController(CementBaseController):
EEService.restart_service(self, "memcached") EEService.restart_service(self, "memcached")
Log.info(self, "Cleaning MemCache") Log.info(self, "Cleaning MemCache")
else: else:
Log.error(self, "Memcache not installed") Log.info(self, "Memcache not installed")
except Exception as e: except Exception as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to restart Memcached") Log.error(self, "Unable to restart Memcached")
@ -86,7 +100,12 @@ class EECleanController(CementBaseController):
"/opcache/opgui.php?page=reset").read() "/opcache/opgui.php?page=reset").read()
except Exception as e: except Exception as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to clean OpCache") Log.debug(self, "Unable hit url, "
" https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset,"
" please check you have admin tools installed")
Log.debug(self, "please check you have admin tools installed,"
" or install them with `ee stack install --admin`")
Log.error(self, "Unable to clean opcache")
@expose(hide=True) @expose(hide=True)
def clean_pagespeed(self): def clean_pagespeed(self):
@ -95,7 +114,9 @@ class EECleanController(CementBaseController):
Log.info(self, "Cleaning PageSpeed cache") Log.info(self, "Cleaning PageSpeed cache")
EEShellExec.cmd_exec(self, "rm -rf /var/ngx_pagespeed_cache/*") EEShellExec.cmd_exec(self, "rm -rf /var/ngx_pagespeed_cache/*")
else: else:
Log.error(self, "Unable to clean Pagespeed cache") Log.debug(self, "/var/ngx_pagespeed_cache does not exist,"
" so cache not cleared")
Log.error(self, "Unable to clean pagespeed cache")
def load(app): def load(app):

43
ee/cli/plugins/debug.py

@ -9,6 +9,7 @@ from ee.core.logging import Log
from ee.cli.plugins.site_functions import logwatch from ee.cli.plugins.site_functions import logwatch
from ee.core.variables import EEVariables from ee.core.variables import EEVariables
from ee.core.fileutils import EEFileUtils from ee.core.fileutils import EEFileUtils
from pynginxconfig import NginxConfig
import os import os
import configparser import configparser
import glob import glob
@ -173,20 +174,15 @@ class EEDebugController(CementBaseController):
"| grep 9001")): "| grep 9001")):
Log.info(self, "Enabling PHP debug") Log.info(self, "Enabling PHP debug")
# Check HHVM is installed if not instlled then dont not enable
# it in upstream config # Change upstream.conf
nc = NginxConfig()
nc.loadf('/etc/nginx/conf.d/upstream.conf')
nc.set([('upstream','php',), 'server'], '127.0.0.1:9001')
if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"): if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"):
hhvmconf=True nc.set([('upstream','hhvm',), 'server'], '127.0.0.1:9001')
else: nc.savef('/etc/nginx/conf.d/upstream.conf')
hhvmconf=False
data = dict(php="9001", debug="9001", hhvm="9001",
hhvmconf=hhvmconf)
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)
ee_nginx.close()
# Enable xdebug # Enable xdebug
EEFileUtils.searchreplace(self, "/etc/php5/mods-available/" EEFileUtils.searchreplace(self, "/etc/php5/mods-available/"
"xdebug.ini", "xdebug.ini",
@ -218,21 +214,14 @@ class EEDebugController(CementBaseController):
"| grep 9001"): "| grep 9001"):
Log.info(self, "Disabling PHP debug") Log.info(self, "Disabling PHP debug")
# Check HHVM is installed if not instlled then dont not enable # Change upstream.conf
# it in upstream config nc = NginxConfig()
nc.loadf('/etc/nginx/conf.d/upstream.conf')
nc.set([('upstream','php',), 'server'], '127.0.0.1:9000')
if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"): if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"):
hhvmconf=True nc.set([('upstream','hhvm',), 'server'], '127.0.0.1:8000')
else: nc.savef('/etc/nginx/conf.d/upstream.conf')
hhvmconf=False
data = dict(php="9000", debug="9001", hhvm="8000",
hhvmconf=hhvmconf)
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)
ee_nginx.close()
# Disable xdebug # Disable xdebug
EEFileUtils.searchreplace(self, "/etc/php5/mods-available/" EEFileUtils.searchreplace(self, "/etc/php5/mods-available/"
"xdebug.ini", "xdebug.ini",

113
ee/cli/plugins/site.py

@ -347,6 +347,9 @@ class EESiteCreateController(CementBaseController):
(['--wpsc'], (['--wpsc'],
dict(help="create wordpress single/multi site with wpsc cache", dict(help="create wordpress single/multi site with wpsc cache",
action='store_true')), action='store_true')),
(['--wpredis'],
dict(help="create wordpress single/multi site with redis cache",
action='store_true')),
(['--hhvm'], (['--hhvm'],
dict(help="create HHVM site", action='store_true')), dict(help="create HHVM site", action='store_true')),
(['--pagespeed'], (['--pagespeed'],
@ -441,7 +444,7 @@ class EESiteCreateController(CementBaseController):
data = dict(site_name=ee_domain, www_domain=ee_www_domain, data = dict(site_name=ee_domain, www_domain=ee_www_domain,
static=False, basic=True, wp=False, w3tc=False, static=False, basic=True, wp=False, w3tc=False,
wpfc=False, wpsc=False, multisite=False, wpfc=False, wpsc=False, wpredis=False, multisite=False,
wpsubdir=False, webroot=ee_site_webroot, wpsubdir=False, webroot=ee_site_webroot,
ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_name='', ee_db_user='', ee_db_pass='',
ee_db_host='') ee_db_host='')
@ -512,6 +515,21 @@ class EESiteCreateController(CementBaseController):
data['pagespeed'] = False data['pagespeed'] = False
pagespeed = 0 pagespeed = 0
if (cache == 'wpredis' and (not self.app.pargs.experimental)):
Log.info(self, "Redis is experimental feature and it may not"
"work with all CSS/JS/Cache of your site.\nYou can "
"disable it by changing cache later.\nDo you wish"
" to enable Redis now for {0}?".format(ee_domain))
# Check prompt
check_prompt = input("Type \"y\" to continue [n]:")
if check_prompt != "Y" and check_prompt != "y":
Log.error(self, "Not using Redis for site")
cache = 'basic'
data['wpredis'] = False
data['basic'] = True
self.app.pargs.wpredis = False
# self.app.args.print_help() # self.app.args.print_help()
# if not data: # if not data:
# self.app.close(1) # self.app.close(1)
@ -733,6 +751,8 @@ class EESiteUpdateController(CementBaseController):
dict(help="update to wpfc cache", action='store_true')), dict(help="update to wpfc cache", action='store_true')),
(['--wpsc'], (['--wpsc'],
dict(help="update to wpsc cache", action='store_true')), dict(help="update to wpsc cache", action='store_true')),
(['--wpredis'],
dict(help="update to redis cache", action='store_true')),
(['--hhvm'], (['--hhvm'],
dict(help='Use HHVM for site', dict(help='Use HHVM for site',
action='store' or 'store_const', action='store' or 'store_const',
@ -760,13 +780,18 @@ class EESiteUpdateController(CementBaseController):
" provided") " provided")
if pargs.html: if pargs.html:
Log.error(self, "No site can be updated to html") Log.error(self, "No site can be updated to html")
if not (pargs.php or if not (pargs.php or
pargs.mysql or pargs.wp or pargs.wpsubdir or pargs.mysql or pargs.wp or pargs.wpsubdir or
pargs.wpsubdomain or pargs.w3tc or pargs.wpfc or pargs.wpsubdomain or pargs.w3tc or pargs.wpfc or
pargs.wpsc or pargs.hhvm or pargs.pagespeed): pargs.wpsc or pargs.hhvm or pargs.pagespeed or pargs.wpredis):
Log.error(self, "Please provide options to update sites.") Log.error(self, "Please provide options to update sites.")
if pargs.all: if pargs.all:
if pargs.site_name:
Log.error(self, "`--all` option cannot be used with site name"
" provided")
sites = getAllsites(self) sites = getAllsites(self)
if not sites: if not sites:
pass pass
@ -879,7 +904,7 @@ class EESiteUpdateController(CementBaseController):
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,
static=False, basic=True, wp=False, w3tc=False, static=False, basic=True, wp=False, w3tc=False,
wpfc=False, wpsc=False, multisite=False, wpfc=False, wpsc=False, wpredis=False, multisite=False,
wpsubdir=False, webroot=ee_site_webroot, wpsubdir=False, webroot=ee_site_webroot,
currsitetype=oldsitetype, currcachetype=oldcachetype) currsitetype=oldsitetype, currcachetype=oldcachetype)
@ -887,7 +912,7 @@ class EESiteUpdateController(CementBaseController):
data = dict(site_name=ee_domain, www_domain=ee_www_domain, data = dict(site_name=ee_domain, www_domain=ee_www_domain,
static=False, basic=True, wp=False, w3tc=False, static=False, basic=True, wp=False, w3tc=False,
wpfc=False, wpsc=False, multisite=False, wpfc=False, wpsc=False, wpredis=False, multisite=False,
wpsubdir=False, webroot=ee_site_webroot, wpsubdir=False, webroot=ee_site_webroot,
ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_name='', ee_db_user='', ee_db_pass='',
ee_db_host='', ee_db_host='',
@ -942,21 +967,31 @@ class EESiteUpdateController(CementBaseController):
data['w3tc'] = False data['w3tc'] = False
data['wpfc'] = False data['wpfc'] = False
data['wpsc'] = False data['wpsc'] = False
data['wpredis'] = False
elif oldcachetype == 'w3tc': elif oldcachetype == 'w3tc':
data['basic'] = False data['basic'] = False
data['w3tc'] = True data['w3tc'] = True
data['wpfc'] = False data['wpfc'] = False
data['wpsc'] = False data['wpsc'] = False
data['wpredis'] = False
elif oldcachetype == 'wpfc': elif oldcachetype == 'wpfc':
data['basic'] = False data['basic'] = False
data['w3tc'] = False data['w3tc'] = False
data['wpfc'] = True data['wpfc'] = True
data['wpsc'] = False data['wpsc'] = False
data['wpredis'] = False
elif oldcachetype == 'wpsc': elif oldcachetype == 'wpsc':
data['basic'] = False data['basic'] = False
data['w3tc'] = False data['w3tc'] = False
data['wpfc'] = False data['wpfc'] = False
data['wpsc'] = True data['wpsc'] = True
data['wpredis'] = False
elif oldcachetype == 'wpredis':
data['basic'] = False
data['w3tc'] = False
data['wpfc'] = False
data['wpsc'] = False
data['wpredis'] = True
if pargs.hhvm != 'off': if pargs.hhvm != 'off':
data['hhvm'] = True data['hhvm'] = True
@ -1050,6 +1085,21 @@ class EESiteUpdateController(CementBaseController):
data['pagespeed'] = True data['pagespeed'] = True
pagespeed = True pagespeed = True
if data['currcachetype'] != 'wpredis' and pargs.wpredis:
if (not pargs.experimental):
Log.info(self, "Redis is experimental feature and it may not"
" work with all plugins of your site.\nYou can "
"disable it by changing cache type later.\nDo you wish"
" to enable Redis now for {0}?".format(ee_domain))
# Check prompt
check_prompt = input("Type \"y\" to continue [n]: ")
if check_prompt != "Y" and check_prompt != "y":
Log.error(self, "Not using Redis for site")
data['wpredis'] = False
data['basic'] = True
cache = 'basic'
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)):
return 1 return 1
@ -1178,6 +1228,40 @@ class EESiteUpdateController(CementBaseController):
" `tail /var/log/ee/ee.log` & Try Again!!!") " `tail /var/log/ee/ee.log` & Try Again!!!")
return 1 return 1
if ((oldcachetype in ['w3tc', 'wpsc', 'basic', 'wpredis'] and
(data['wpfc'])) or (oldsitetype == 'wp' and data['multisite'] and data['wpfc'])):
try:
plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_fastcgi","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)
except SiteError as e:
Log.debug(self, str(e))
Log.info(self, Log.FAIL + "Update nginx-helper settings failed. "
"Check logs for reason"
" `tail /var/log/ee/ee.log` & Try Again!!!")
return 1
elif ((oldcachetype in ['w3tc', 'wpsc', 'basic', 'wpfc'] and
(data['wpredis'])) or (oldsitetype == 'wp' and data['multisite'] and data['wpredis'])):
try:
plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_redis","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)
except SiteError as e:
Log.debug(self, str(e))
Log.info(self, Log.FAIL + "Update nginx-helper settings failed. "
"Check logs for reason"
" `tail /var/log/ee/ee.log` & Try Again!!!")
return 1
else:
try:
plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":0,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_redis","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)
except SiteError as e:
Log.debug(self, str(e))
Log.info(self, Log.FAIL + "Update nginx-helper settings failed. "
"Check logs for reason"
" `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)
@ -1188,6 +1272,16 @@ class EESiteUpdateController(CementBaseController):
" `tail /var/log/ee/ee.log` & Try Again!!!") " `tail /var/log/ee/ee.log` & Try Again!!!")
return 1 return 1
if oldcachetype == 'wpredis' and not data['wpredis']:
try:
uninstallwp_plugin(self, 'redis-cache', data)
except SiteError as e:
Log.debug(self, str(e))
Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason"
" `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']):
try: try:
@ -1208,6 +1302,17 @@ class EESiteUpdateController(CementBaseController):
"Check logs for reason " "Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
return 1 return 1
if oldcachetype != 'wpredis' and data['wpredis']:
try:
installwp_plugin(self, 'redis-cache', data)
except SiteError as e:
Log.debug(self, str(e))
Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
# Service Nginx Reload # Service Nginx Reload
if not EEService.reload_service(self, 'nginx'): if not EEService.reload_service(self, 'nginx'):
Log.error(self, "service nginx reload failed. " Log.error(self, "service nginx reload failed. "

153
ee/cli/plugins/site_functions.py

@ -281,7 +281,8 @@ def setupwordpress(self, data):
Log.debug(self, "Setting up wp-config file") Log.debug(self, "Setting up wp-config file")
if not data['multisite']: if not data['multisite']:
Log.debug(self, "Generating wp-config for WordPress Single site") Log.debug(self, "Generating wp-config for WordPress Single site")
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root " Log.debug(self, "bash -c \"php {0} --allow-root "
.format(EEVariables.ee_wpcli_path)
+ "core config " + "core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' " + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
"--dbhost=\'{3}\' " "--dbhost=\'{3}\' "
@ -292,7 +293,8 @@ def setupwordpress(self, data):
.format(data['ee_db_pass'], .format(data['ee_db_pass'],
"\n\ndefine(\'WP_DEBUG\', false);")) "\n\ndefine(\'WP_DEBUG\', false);"))
try: try:
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root" EEShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root"
.format(EEVariables.ee_wpcli_path)
+ " core config " + " core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' " + "--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbuser=\'{2}\' --dbhost=\'{3}\' " "--dbuser=\'{2}\' --dbhost=\'{3}\' "
@ -309,7 +311,8 @@ def setupwordpress(self, data):
raise SiteError("generate wp-config failed for wp single site") raise SiteError("generate wp-config failed for wp single site")
else: else:
Log.debug(self, "Generating wp-config for WordPress multisite") Log.debug(self, "Generating wp-config for WordPress multisite")
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root " Log.debug(self, "bash -c \"php {0} --allow-root "
.format(EEVariables.ee_wpcli_path)
+ "core config " + "core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' " + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
.format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host']) .format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host'])
@ -322,7 +325,8 @@ def setupwordpress(self, data):
" true);", " true);",
"\n\ndefine(\'WP_DEBUG\', false);")) "\n\ndefine(\'WP_DEBUG\', false);"))
try: try:
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root" EEShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root"
.format(EEVariables.ee_wpcli_path)
+ " core config " + " core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' " + "--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbhost=\'{2}\' " "--dbhost=\'{2}\' "
@ -382,14 +386,16 @@ def setupwordpress(self, data):
if not data['multisite']: if not data['multisite']:
Log.debug(self, "Creating tables for WordPress Single site") Log.debug(self, "Creating tables for WordPress Single site")
Log.debug(self, "php /usr/bin/wp --allow-root core install " Log.debug(self, "php {0} --allow-root core install "
"--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' " .format(EEVariables.ee_wpcli_path)
+ "--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user) .format(data['www_domain'], ee_wp_user)
+ "--admin_password= --admin_email=\'{1}\'" + "--admin_password= --admin_email=\'{1}\'"
.format(ee_wp_pass, ee_wp_email)) .format(ee_wp_pass, ee_wp_email))
try: try:
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core " EEShellExec.cmd_exec(self, "php {0} --allow-root core "
"install --url=\'{0}\' --title=\'{0}\' " .format(EEVariables.ee_wpcli_path)
+ "install --url=\'{0}\' --title=\'{0}\' "
"--admin_name=\'{1}\' " "--admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user) .format(data['www_domain'], ee_wp_user)
+ "--admin_password=\'{0}\' " + "--admin_password=\'{0}\' "
@ -400,8 +406,9 @@ def setupwordpress(self, data):
raise SiteError("setup wordpress tables failed for single site") raise SiteError("setup wordpress tables failed for single site")
else: else:
Log.debug(self, "Creating tables for WordPress multisite") Log.debug(self, "Creating tables for WordPress multisite")
Log.debug(self, "php /usr/bin/wp --allow-root " Log.debug(self, "php {0} --allow-root "
"core multisite-install " .format(EEVariables.ee_wpcli_path)
+ "core multisite-install "
"--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' " "--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user) .format(data['www_domain'], ee_wp_user)
+ "--admin_password= --admin_email=\'{1}\' " + "--admin_password= --admin_email=\'{1}\' "
@ -410,8 +417,9 @@ def setupwordpress(self, data):
subdomains='--subdomains' subdomains='--subdomains'
if not data['wpsubdir'] else '')) if not data['wpsubdir'] else ''))
try: try:
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root " EEShellExec.cmd_exec(self, "php {0} --allow-root "
"core multisite-install " .format(EEVariables.ee_wpcli_path)
+ "core multisite-install "
"--url=\'{0}\' --title=\'{0}\' " "--url=\'{0}\' --title=\'{0}\' "
"--admin_name=\'{1}\' " "--admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user) .format(data['www_domain'], ee_wp_user)
@ -427,19 +435,30 @@ def setupwordpress(self, data):
Log.debug(self, "Updating WordPress permalink") Log.debug(self, "Updating WordPress permalink")
try: try:
EEShellExec.cmd_exec(self, " php /usr/bin/wp --allow-root " EEShellExec.cmd_exec(self, " php {0} --allow-root "
"rewrite structure " .format(EEVariables.ee_wpcli_path)
+ "rewrite structure "
"/%year%/%monthnum%/%day%/%postname%/") "/%year%/%monthnum%/%day%/%postname%/")
except CommandExecutionError as e: except CommandExecutionError as e:
raise SiteError("Update wordpress permalinks failed") raise SiteError("Update wordpress permalinks failed")
"""Install nginx-helper plugin """ """Install nginx-helper plugin """
installwp_plugin(self, 'nginx-helper', data) installwp_plugin(self, 'nginx-helper', data)
if data['wpfc']:
plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_fastcgi","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)
elif data['wpredis']:
plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_redis","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)
"""Install Wp Super Cache""" """Install Wp Super Cache"""
if data['wpsc']: if data['wpsc']:
installwp_plugin(self, 'wp-super-cache', data) installwp_plugin(self, 'wp-super-cache', data)
"""Install Redis Cache"""
if data['wpredis']:
installwp_plugin(self, 'redis-cache', data)
"""Install W3 Total Cache""" """Install W3 Total Cache"""
if data['w3tc'] or data['wpfc']: if data['w3tc'] or data['wpfc']:
installwp_plugin(self, 'w3-total-cache', data) installwp_plugin(self, 'w3-total-cache', data)
@ -472,15 +491,17 @@ def installwp_plugin(self, plugin_name, data):
.format(plugin_name)) .format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
try: try:
EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin " EEShellExec.cmd_exec(self, "php {0} plugin "
"--allow-root install " .format(EEVariables.ee_wpcli_path)
+ "--allow-root install "
"{0}".format(plugin_name)) "{0}".format(plugin_name))
except CommandExecutionError as e: except CommandExecutionError as e:
raise SiteError("plugin installation failed") raise SiteError("plugin installation failed")
try: try:
EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin " EEShellExec.cmd_exec(self, "php {0} plugin "
"--allow-root activate " .format(EEVariables.ee_wpcli_path)
+ "--allow-root activate "
"{0} {na}" "{0} {na}"
.format(plugin_name, .format(plugin_name,
na='--network' if data['multisite'] na='--network' if data['multisite']
@ -495,13 +516,46 @@ def uninstallwp_plugin(self, plugin_name, data):
Log.debug(self, "Uninstalling plugin {0}, please wait..." Log.debug(self, "Uninstalling plugin {0}, please wait..."
.format(plugin_name)) .format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
Log.info(self, "Uninstalling plugin {0}, please wait..."
.format(plugin_name))
try: try:
EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin " EEShellExec.cmd_exec(self, "php {0} plugin "
"--allow-root uninstall " .format(EEVariables.ee_wpcli_path)
+ "--allow-root deactivate "
"{0}".format(plugin_name))
EEShellExec.cmd_exec(self, "php {0} plugin "
.format(EEVariables.ee_wpcli_path)
+ "--allow-root uninstall "
"{0}".format(plugin_name)) "{0}".format(plugin_name))
except CommandExecutionError as e: except CommandExecutionError as e:
raise SiteError("plugin uninstall failed") raise SiteError("plugin uninstall failed")
def setupwp_plugin(self, plugin_name, plugin_option, plugin_data, data):
ee_site_webroot = data['webroot']
Log.info(self, "Setting plugin {0}, please wait..."
.format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
if not data['multisite']:
try:
EEShellExec.cmd_exec(self, "php {0} "
.format(EEVariables.ee_wpcli_path)
+ "--allow-root option update "
"{0} \'{1}\' --format=json".format(plugin_option, plugin_data))
except CommandExecutionError as e:
raise SiteError("plugin setup failed")
else:
try:
EEShellExec.cmd_exec(self, "php {0} "
.format(EEVariables.ee_wpcli_path)
+ "--allow-root network meta update 1 "
"{0} \'{1}\' --format=json"
.format(plugin_option, plugin_data
))
except CommandExecutionError as e:
raise SiteError("plugin setup failed")
def setwebrootpermissions(self, webroot): def setwebrootpermissions(self, webroot):
Log.debug(self, "Setting up permissions") Log.debug(self, "Setting up permissions")
@ -599,6 +653,52 @@ def site_package_check(self, stype):
"wp-cli-{0}.phar" "wp-cli-{0}.phar"
.format(EEVariables.ee_wp_cli), .format(EEVariables.ee_wp_cli),
"/usr/bin/wp", "WP-CLI"]] "/usr/bin/wp", "WP-CLI"]]
if self.app.pargs.wpredis:
Log.debug(self, "Setting apt_packages variable for redis")
if not EEAptGet.is_installed(self, 'redis-server'):
apt_packages = apt_packages + EEVariables.ee_redis
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/common/redis.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis.conf')
ee_nginx = open('/etc/nginx/common/redis.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/common/redis-hhvm.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-hhvm.conf')
ee_nginx = open('/etc/nginx/common/redis-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isfile("/etc/nginx/conf.d/upstream.conf"):
if not EEFileUtils.grep(self, "/etc/nginx/conf.d/"
"upstream.conf",
"redis"):
with open("/etc/nginx/conf.d/upstream.conf",
"a") as redis_file:
redis_file.write("upstream redis {\n"
" server 127.0.0.1:6379;\n"
" keepalive 10;\n}")
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/conf.d/redis.conf")):
with open("/etc/nginx/conf.d/redis.conf", "a") as redis_file:
redis_file.write("# Log format Settings\n"
"log_format rt_cache_redis '$remote_addr $upstream_response_time $srcache_fetch_status [$time_local] '\n"
"'$http_host \"$request\" $status $body_bytes_sent '\n"
"'\"$http_referer\" \"$http_user_agent\"';\n")
if self.app.pargs.hhvm: if self.app.pargs.hhvm:
if platform.architecture()[0] is '32bit': if platform.architecture()[0] is '32bit':
@ -745,15 +845,16 @@ def display_cache_settings(self, data):
"page=wpsupercache" "page=wpsupercache"
.format(data['site_name'])) .format(data['site_name']))
if data['wpfc']: if data['wpredis']:
if data['multisite']: if data['multisite']:
Log.info(self, "Configure nginx-helper:" Log.info(self, "Configure redis-cache:"
"\thttp://{0}/wp-admin/network/settings.php?" "\thttp://{0}/wp-admin/network/settings.php?"
"page=nginx".format(data['site_name'])) "page=redis-cache".format(data['site_name']))
else: else:
Log.info(self, "Configure nginx-helper:" Log.info(self, "Configure redis-cache:"
"\thttp://{0}/wp-admin/options-general.php?" "\thttp://{0}/wp-admin/options-general.php?"
"page=nginx".format(data['site_name'])) "page=redis-cache".format(data['site_name']))
Log.info(self, "Object Cache:\t\tEnable")
if data['wpfc'] or data['w3tc']: if data['wpfc'] or data['w3tc']:
if data['multisite']: if data['multisite']:
@ -812,7 +913,7 @@ def detSitePar(opts):
if val and key in ['html', 'php', 'mysql', 'wp', if val and key in ['html', 'php', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']: 'wpsubdir', 'wpsubdomain']:
typelist.append(key) typelist.append(key)
elif val and key in ['wpfc', 'wpsc', 'w3tc']: elif val and key in ['wpfc', 'wpsc', 'w3tc', 'wpredis']:
cachelist.append(key) cachelist.append(key)
if len(typelist) > 1 or len(cachelist) > 1: if len(typelist) > 1 or len(cachelist) > 1:

205
ee/cli/plugins/stack.py

@ -74,6 +74,10 @@ class EEStackController(CementBaseController):
dict(help='Install Utils stack', action='store_true')), dict(help='Install Utils stack', action='store_true')),
(['--pagespeed'], (['--pagespeed'],
dict(help='Install Pagespeed', action='store_true')), dict(help='Install Pagespeed', action='store_true')),
(['--redis'],
dict(help='Install Redis', action='store_true')),
(['--phpredisadmin'],
dict(help='Install Redis', action='store_true')),
] ]
usage = "ee stack (command) [options]" usage = "ee stack (command) [options]"
@ -194,6 +198,17 @@ class EEStackController(CementBaseController):
except CommandExecutionError as e: except CommandExecutionError as e:
Log.error("Failed to initialize dovecot packages") Log.error("Failed to initialize dovecot packages")
if set(EEVariables.ee_redis).issubset(set(apt_packages)):
Log.info(self, "Adding repository for Redis, please wait...")
if EEVariables.ee_platform_distro == 'debian':
Log.debug(self, 'Adding repo_url of redis for debian')
EERepo.add(self, repo_url=EEVariables.ee_redis_repo)
Log.debug(self, 'Adding Dotdeb GPG key')
EERepo.add_key(self, '89DF5277')
else:
Log.debug(self, 'Adding ppa for redis')
EERepo.add(self, ppa=EEVariables.ee_redis_repo)
@expose(hide=True) @expose(hide=True)
def post_pref(self, apt_packages, packages): def post_pref(self, apt_packages, packages):
"""Post activity after installation of packages""" """Post activity after installation of packages"""
@ -410,6 +425,49 @@ class EEStackController(CementBaseController):
self.msg = (self.msg + ["HTTP Auth User Name: easyengine"] self.msg = (self.msg + ["HTTP Auth User Name: easyengine"]
+ ["HTTP Auth Password : {0}".format(passwd)]) + ["HTTP Auth Password : {0}".format(passwd)])
if EEAptGet.is_installed(self,'redis-server'):
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/common/redis.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis.conf')
ee_nginx = open('/etc/nginx/common/redis.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/common/redis-hhvm.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-hhvm.conf')
ee_nginx = open('/etc/nginx/common/redis-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isfile("/etc/nginx/conf.d/upstream.conf"):
if not EEFileUtils.grep(self, "/etc/nginx/conf.d/"
"upstream.conf",
"redis"):
with open("/etc/nginx/conf.d/upstream.conf",
"a") as redis_file:
redis_file.write("upstream redis {\n"
" server 127.0.0.1:6379;\n"
" keepalive 10;\n}\n")
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/conf.d/redis.conf")):
with open("/etc/nginx/conf.d/redis.conf", "a") as redis_file:
redis_file.write("# Log format Settings\n"
"log_format rt_cache_redis '$remote_addr $upstream_response_time $srcache_fetch_status [$time_local] '\n"
"'$http_host \"$request\" $status $body_bytes_sent '\n"
"'\"$http_referer\" \"$http_user_agent\"';\n")
# Set up pagespeed config # Set up pagespeed config
if self.app.pargs.pagespeed: if self.app.pargs.pagespeed:
if (os.path.isfile('/etc/nginx/nginx.conf') and if (os.path.isfile('/etc/nginx/nginx.conf') and
@ -509,6 +567,49 @@ class EEStackController(CementBaseController):
Log.error(self, "Failed to reload Nginx, please check " Log.error(self, "Failed to reload Nginx, please check "
"output of `nginx -t`") "output of `nginx -t`")
if set(EEVariables.ee_redis).issubset(set(apt_packages)):
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/common/redis.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis.conf')
ee_nginx = open('/etc/nginx/common/redis.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/common/redis-hhvm.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-hhvm.conf')
ee_nginx = open('/etc/nginx/common/redis-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis-hhvm.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isfile("/etc/nginx/conf.d/upstream.conf"):
if not EEFileUtils.grep(self, "/etc/nginx/conf.d/"
"upstream.conf",
"redis"):
with open("/etc/nginx/conf.d/upstream.conf",
"a") as redis_file:
redis_file.write("upstream redis {\n"
" server 127.0.0.1:6379;\n"
" keepalive 10;\n}\n")
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/conf.d/redis.conf")):
with open("/etc/nginx/conf.d/redis.conf", "a") as redis_file:
redis_file.write("# Log format Settings\n"
"log_format rt_cache_redis '$remote_addr $upstream_response_time $srcache_fetch_status [$time_local] '\n"
"'$http_host \"$request\" $status $body_bytes_sent '\n"
"'\"$http_referer\" \"$http_user_agent\"';\n")
if set(EEVariables.ee_php).issubset(set(apt_packages)): if set(EEVariables.ee_php).issubset(set(apt_packages)):
# Create log directories # Create log directories
if not os.path.exists('/var/log/php5/'): if not os.path.exists('/var/log/php5/'):
@ -1346,6 +1447,38 @@ class EEStackController(CementBaseController):
EEVariables.ee_php_user, EEVariables.ee_php_user,
recursive=True) recursive=True)
if any('/tmp/pra.tar.gz' == x[1]
for x in packages):
Log.debug(self, 'Extracting file /tmp/pra.tar.gz to '
'loaction /tmp/')
EEExtract.extract(self, '/tmp/pra.tar.gz', '/tmp/')
if not os.path.exists('{0}22222/htdocs/cache/redis'
.format(EEVariables.ee_webroot)):
Log.debug(self, "Creating new directory "
"{0}22222/htdocs/cache/redis"
.format(EEVariables.ee_webroot))
os.makedirs('{0}22222/htdocs/cache/redis'
.format(EEVariables.ee_webroot))
shutil.move('/tmp/phpRedisAdmin-master/',
'{0}22222/htdocs/cache/redis/phpRedisAdmin'
.format(EEVariables.ee_webroot))
Log.debug(self, 'Extracting file /tmp/predis.tar.gz to '
'loaction /tmp/')
EEExtract.extract(self, '/tmp/predis.tar.gz', '/tmp/')
shutil.move('/tmp/predis-1.0.1/',
'{0}22222/htdocs/cache/redis/phpRedisAdmin/vendor'
.format(EEVariables.ee_webroot))
Log.debug(self, 'Setting Privileges of webroot permission to '
'{0}22222/htdocs/cache/ file '
.format(EEVariables.ee_webroot))
EEFileUtils.chown(self, '{0}22222'
.format(EEVariables.ee_webroot),
EEVariables.ee_php_user,
EEVariables.ee_php_user,
recursive=True)
@expose(help="Install packages") @expose(help="Install packages")
def install(self, packages=[], apt_packages=[], disp_msg=True): def install(self, packages=[], apt_packages=[], disp_msg=True):
"""Start installation of packages""" """Start installation of packages"""
@ -1359,7 +1492,9 @@ class EEStackController(CementBaseController):
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm) (not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm)
and (not self.app.pargs.pagespeed) and and (not self.app.pargs.pagespeed) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and
(not self.app.pargs.mailscanner) and (not self.app.pargs.all)): (not self.app.pargs.mailscanner) and (not self.app.pargs.all)
and (not self.app.pargs.redis) and
(not self.app.pargs.phpredisadmin)):
self.app.pargs.web = True self.app.pargs.web = True
self.app.pargs.admin = True self.app.pargs.admin = True
@ -1421,6 +1556,12 @@ class EEStackController(CementBaseController):
else: else:
Log.info(self, "Nginx already installed") Log.info(self, "Nginx already installed")
if self.app.pargs.redis:
if not EEAptGet.is_installed(self, 'redis-server'):
apt_packages = apt_packages + EEVariables.ee_redis
else:
Log.info(self, "Redis already installed")
if self.app.pargs.nginx: if self.app.pargs.nginx:
Log.debug(self, "Setting apt_packages variable for Nginx") Log.debug(self, "Setting apt_packages variable for Nginx")
@ -1486,6 +1627,15 @@ class EEStackController(CementBaseController):
"phpmyadmin/archive/STABLE.tar.gz", "phpmyadmin/archive/STABLE.tar.gz",
"/tmp/pma.tar.gz", "phpMyAdmin"]] "/tmp/pma.tar.gz", "phpMyAdmin"]]
if self.app.pargs.phpredisadmin:
Log.debug(self, "Setting packages varible for phpRedisAdmin")
packages = packages + [["https://github.com/ErikDubbelboer/"
"phpRedisAdmin/archive/master.tar.gz",
"/tmp/pra.tar.gz","phpRedisAdmin"],
["https://github.com/nrk/predis/"
"archive/v1.0.1.tar.gz",
"/tmp/predis.tar.gz", "Predis"]]
if self.app.pargs.adminer: if self.app.pargs.adminer:
Log.debug(self, "Setting packages variable for Adminer ") Log.debug(self, "Setting packages variable for Adminer ")
packages = packages + [["http://downloads.sourceforge.net/" packages = packages + [["http://downloads.sourceforge.net/"
@ -1592,7 +1742,8 @@ class EEStackController(CementBaseController):
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm) 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.adminer) and (not self.app.pargs.utils) and
(not self.app.pargs.mailscanner) and (not self.app.pargs.all) and (not self.app.pargs.mailscanner) and (not self.app.pargs.all) and
(not self.app.pargs.pagespeed)): (not self.app.pargs.pagespeed) and (not self.app.pargs.redis) and
(not self.app.pargs.phpredisadmin)):
self.app.pargs.web = True self.app.pargs.web = True
self.app.pargs.admin = True self.app.pargs.admin = True
@ -1643,7 +1794,9 @@ class EEStackController(CementBaseController):
if EEAptGet.is_installed(self, 'hhvm'): if EEAptGet.is_installed(self, 'hhvm'):
Log.debug(self, "Removing apt_packages varible of HHVM") Log.debug(self, "Removing apt_packages varible of HHVM")
apt_packages = apt_packages + EEVariables.ee_hhvm apt_packages = apt_packages + EEVariables.ee_hhvm
if self.app.pargs.redis:
Log.debug(self, "Remove apt_packages variable of Redis")
apt_packages = apt_packages + EEVariables.ee_redis
if self.app.pargs.mysql: if self.app.pargs.mysql:
Log.debug(self, "Removing apt_packages variable of MySQL") Log.debug(self, "Removing apt_packages variable of MySQL")
apt_packages = apt_packages + EEVariables.ee_mysql apt_packages = apt_packages + EEVariables.ee_mysql
@ -1653,11 +1806,18 @@ class EEStackController(CementBaseController):
apt_packages = apt_packages + EEVariables.ee_postfix apt_packages = apt_packages + EEVariables.ee_postfix
if self.app.pargs.wpcli: if self.app.pargs.wpcli:
Log.debug(self, "Removing package variable of WPCLI ") Log.debug(self, "Removing package variable of WPCLI ")
if os.path.isfile('/usr/bin/wp'):
packages = packages + ['/usr/bin/wp'] packages = packages + ['/usr/bin/wp']
else:
Log.warn(self, "WP-CLI is not installed with EasyEngine")
if self.app.pargs.phpmyadmin: if self.app.pargs.phpmyadmin:
Log.debug(self, "Removing package variable of phpMyAdmin ") Log.debug(self, "Removing package variable of phpMyAdmin ")
packages = packages + ['{0}22222/htdocs/db/pma' packages = packages + ['{0}22222/htdocs/db/pma'
.format(EEVariables.ee_webroot)] .format(EEVariables.ee_webroot)]
if self.app.pargs.phpredisadmin:
Log.debug(self, "Removing package variable of phpRedisAdmin ")
packages = packages + ['{0}22222/htdocs/cache/redis/phpRedisAdmin'
.format(EEVariables.ee_webroot)]
if self.app.pargs.adminer: if self.app.pargs.adminer:
Log.debug(self, "Removing package variable of Adminer ") Log.debug(self, "Removing package variable of Adminer ")
packages = packages + ['{0}22222/htdocs/db/adminer' packages = packages + ['{0}22222/htdocs/db/adminer'
@ -1675,27 +1835,27 @@ class EEStackController(CementBaseController):
'/usr/bin/pt-query-advisor', '/usr/bin/pt-query-advisor',
'{0}22222/htdocs/db/anemometer' '{0}22222/htdocs/db/anemometer'
.format(EEVariables.ee_webroot)] .format(EEVariables.ee_webroot)]
if len(packages) or len(apt_packages):
ee_prompt = input('Are you sure you to want to' ee_prompt = input('Are you sure you to want to'
' remove from server.' ' remove from server.'
'Package configuration will remain' '\nPackage configuration will remain'
' on server after this operation.\n' ' on server after this operation.\n'
'Any answer other than ' 'Any answer other than '
'"yes" will be stop this' '"yes" will be stop this'
' operation : ') ' operation : ')
if len(apt_packages):
if ee_prompt == 'YES' or ee_prompt == 'yes': if ee_prompt == 'YES' or ee_prompt == 'yes':
if len(packages):
EEFileUtils.remove(self, packages)
EEAptGet.auto_remove(self)
if len(apt_packages):
Log.debug(self, "Removing apt_packages") Log.debug(self, "Removing apt_packages")
Log.info(self, "Removing packages, please wait...") Log.info(self, "Removing packages, please wait...")
EEAptGet.remove(self, apt_packages) EEAptGet.remove(self, apt_packages)
EEAptGet.auto_remove(self) EEAptGet.auto_remove(self)
if len(packages):
if ee_prompt == 'YES' or ee_prompt == 'yes':
EEFileUtils.remove(self, packages)
EEAptGet.auto_remove(self)
if ee_prompt == 'YES' or ee_prompt == 'yes':
Log.info(self, "Successfully removed packages") Log.info(self, "Successfully removed packages")
@expose(help="Purge packages") @expose(help="Purge packages")
@ -1712,7 +1872,8 @@ class EEStackController(CementBaseController):
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm) 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.adminer) and (not self.app.pargs.utils) and
(not self.app.pargs.mailscanner) and (not self.app.pargs.all) and (not self.app.pargs.mailscanner) and (not self.app.pargs.all) and
(not self.app.pargs.pagespeed)): (not self.app.pargs.pagespeed) and (not self.app.pargs.redis) and
(not self.app.pargs.phpredisadmin)):
self.app.pargs.web = True self.app.pargs.web = True
self.app.pargs.admin = True self.app.pargs.admin = True
@ -1760,8 +1921,11 @@ class EEStackController(CementBaseController):
apt_packages = apt_packages + EEVariables.ee_php apt_packages = apt_packages + EEVariables.ee_php
if self.app.pargs.hhvm: if self.app.pargs.hhvm:
if EEAptGet.is_installed(self, 'hhvm'): if EEAptGet.is_installed(self, 'hhvm'):
Log.debug(self, "Removing apt_packages varible of HHVM") Log.debug(self, "Purge apt_packages varible of HHVM")
apt_packages = apt_packages + EEVariables.ee_hhvm apt_packages = apt_packages + EEVariables.ee_hhvm
if self.app.pargs.redis:
Log.debug(self, "Purge apt_packages variable of Redis")
apt_packages = apt_packages + EEVariables.ee_redis
if self.app.pargs.mysql: if self.app.pargs.mysql:
Log.debug(self, "Purge apt_packages variable MySQL") Log.debug(self, "Purge apt_packages variable MySQL")
apt_packages = apt_packages + EEVariables.ee_mysql apt_packages = apt_packages + EEVariables.ee_mysql
@ -1771,11 +1935,18 @@ class EEStackController(CementBaseController):
apt_packages = apt_packages + EEVariables.ee_postfix apt_packages = apt_packages + EEVariables.ee_postfix
if self.app.pargs.wpcli: if self.app.pargs.wpcli:
Log.debug(self, "Purge package variable WPCLI") Log.debug(self, "Purge package variable WPCLI")
if os.path.isfile('/usr/bin/wp'):
packages = packages + ['/usr/bin/wp'] packages = packages + ['/usr/bin/wp']
else:
Log.warn(self, "WP-CLI is not installed with EasyEngine")
if self.app.pargs.phpmyadmin: if self.app.pargs.phpmyadmin:
packages = packages + ['{0}22222/htdocs/db/pma'. packages = packages + ['{0}22222/htdocs/db/pma'.
format(EEVariables.ee_webroot)] format(EEVariables.ee_webroot)]
Log.debug(self, "Purge package variable phpMyAdmin") Log.debug(self, "Purge package variable phpMyAdmin")
if self.app.pargs.phpredisadmin:
Log.debug(self, "Removing package variable of phpRedisAdmin ")
packages = packages + ['{0}22222/htdocs/cache/redis/phpRedisAdmin'
.format(EEVariables.ee_webroot)]
if self.app.pargs.adminer: if self.app.pargs.adminer:
Log.debug(self, "Purge package variable Adminer") Log.debug(self, "Purge package variable Adminer")
packages = packages + ['{0}22222/htdocs/db/adminer' packages = packages + ['{0}22222/htdocs/db/adminer'
@ -1795,28 +1966,26 @@ class EEStackController(CementBaseController):
.format(EEVariables.ee_webroot) .format(EEVariables.ee_webroot)
] ]
if len(packages) or len(apt_packages):
ee_prompt = input('Are you sure you to want to purge ' ee_prompt = input('Are you sure you to want to purge '
'from server ' 'from server '
'alongwith their configuration' 'along with their configuration'
' packages,\nAny answer other than ' ' packages,\nAny answer other than '
'"yes" will be stop this ' '"yes" will be stop this '
'operation :') 'operation :')
if len(apt_packages):
if ee_prompt == 'YES' or ee_prompt == 'yes': if ee_prompt == 'YES' or ee_prompt == 'yes':
if len(apt_packages):
Log.info(self, "Purging packages, please wait...") Log.info(self, "Purging packages, please wait...")
EEAptGet.remove(self, apt_packages, purge=True) EEAptGet.remove(self, apt_packages, purge=True)
EEAptGet.auto_remove(self) EEAptGet.auto_remove(self)
if len(packages): if len(packages):
if ee_prompt == 'YES' or ee_prompt == 'yes':
EEFileUtils.remove(self, packages) EEFileUtils.remove(self, packages)
EEAptGet.auto_remove(self) EEAptGet.auto_remove(self)
if ee_prompt == 'YES' or ee_prompt == 'yes':
Log.info(self, "Successfully purged packages") Log.info(self, "Successfully purged packages")
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
handler.register(EEStackController) handler.register(EEStackController)

43
ee/cli/plugins/stack_services.py

@ -26,12 +26,11 @@ class EEStackStatusController(CementBaseController):
if not (self.app.pargs.nginx or self.app.pargs.php if not (self.app.pargs.nginx or self.app.pargs.php
or self.app.pargs.mysql or self.app.pargs.postfix or self.app.pargs.mysql or self.app.pargs.postfix
or self.app.pargs.hhvm or self.app.pargs.memcache or self.app.pargs.hhvm or self.app.pargs.memcache
or self.app.pargs.dovecot): or self.app.pargs.dovecot or self.app.pargs.redis):
self.app.pargs.nginx = True self.app.pargs.nginx = True
self.app.pargs.php = True self.app.pargs.php = True
self.app.pargs.mysql = True self.app.pargs.mysql = True
self.app.pargs.postfix = True self.app.pargs.postfix = True
self.app.pargs.hhvm = True
if self.app.pargs.nginx: if self.app.pargs.nginx:
if EEAptGet.is_installed(self, 'nginx-custom'): if EEAptGet.is_installed(self, 'nginx-custom'):
@ -81,6 +80,12 @@ class EEStackStatusController(CementBaseController):
else: else:
Log.info(self, "Mail server is not installed") Log.info(self, "Mail server is not installed")
if self.app.pargs.redis:
if EEAptGet.is_installed(self, 'redis-server'):
services = services + ['redis-server']
else:
Log.info(self, "Redis server is not installed")
for service in services: for service in services:
Log.debug(self, "Starting service: {0}".format(service)) Log.debug(self, "Starting service: {0}".format(service))
EEService.start_service(self, service) EEService.start_service(self, service)
@ -92,12 +97,11 @@ class EEStackStatusController(CementBaseController):
if not (self.app.pargs.nginx or self.app.pargs.php if not (self.app.pargs.nginx or self.app.pargs.php
or self.app.pargs.mysql or self.app.pargs.postfix or self.app.pargs.mysql or self.app.pargs.postfix
or self.app.pargs.hhvm or self.app.pargs.memcache or self.app.pargs.hhvm or self.app.pargs.memcache
or self.app.pargs.dovecot): or self.app.pargs.dovecot or self.app.pargs.redis):
self.app.pargs.nginx = True self.app.pargs.nginx = True
self.app.pargs.php = True self.app.pargs.php = True
self.app.pargs.mysql = True self.app.pargs.mysql = True
self.app.pargs.postfix = True self.app.pargs.postfix = True
self.app.pargs.hhvm = True
if self.app.pargs.nginx: if self.app.pargs.nginx:
if EEAptGet.is_installed(self, 'nginx-custom'): if EEAptGet.is_installed(self, 'nginx-custom'):
@ -147,6 +151,12 @@ class EEStackStatusController(CementBaseController):
else: else:
Log.info(self, "Mail server is not installed") Log.info(self, "Mail server is not installed")
if self.app.pargs.redis:
if EEAptGet.is_installed(self, 'redis-server'):
services = services + ['redis-server']
else:
Log.info(self, "Redis server is not installed")
for service in services: for service in services:
Log.debug(self, "Stopping service: {0}".format(service)) Log.debug(self, "Stopping service: {0}".format(service))
EEService.stop_service(self, service) EEService.stop_service(self, service)
@ -158,12 +168,11 @@ class EEStackStatusController(CementBaseController):
if not (self.app.pargs.nginx or self.app.pargs.php if not (self.app.pargs.nginx or self.app.pargs.php
or self.app.pargs.mysql or self.app.pargs.postfix or self.app.pargs.mysql or self.app.pargs.postfix
or self.app.pargs.hhvm or self.app.pargs.memcache or self.app.pargs.hhvm or self.app.pargs.memcache
or self.app.pargs.dovecot): or self.app.pargs.dovecot or self.app.pargs.redis):
self.app.pargs.nginx = True self.app.pargs.nginx = True
self.app.pargs.php = True self.app.pargs.php = True
self.app.pargs.mysql = True self.app.pargs.mysql = True
self.app.pargs.postfix = True self.app.pargs.postfix = True
self.app.pargs.hhvm = True
if self.app.pargs.nginx: if self.app.pargs.nginx:
if EEAptGet.is_installed(self, 'nginx-custom'): if EEAptGet.is_installed(self, 'nginx-custom'):
@ -213,6 +222,12 @@ class EEStackStatusController(CementBaseController):
else: else:
Log.info(self, "Mail server is not installed") Log.info(self, "Mail server is not installed")
if self.app.pargs.redis:
if EEAptGet.is_installed(self, 'redis-server'):
services = services + ['redis-server']
else:
Log.info(self, "Redis server is not installed")
for service in services: for service in services:
Log.debug(self, "Restarting service: {0}".format(service)) Log.debug(self, "Restarting service: {0}".format(service))
EEService.restart_service(self, service) EEService.restart_service(self, service)
@ -224,7 +239,7 @@ class EEStackStatusController(CementBaseController):
if not (self.app.pargs.nginx or self.app.pargs.php if not (self.app.pargs.nginx or self.app.pargs.php
or self.app.pargs.mysql or self.app.pargs.postfix or self.app.pargs.mysql or self.app.pargs.postfix
or self.app.pargs.hhvm or self.app.pargs.memcache or self.app.pargs.hhvm or self.app.pargs.memcache
or self.app.pargs.dovecot): or self.app.pargs.dovecot or self.app.pargs.redis):
self.app.pargs.nginx = True self.app.pargs.nginx = True
self.app.pargs.php = True self.app.pargs.php = True
self.app.pargs.mysql = True self.app.pargs.mysql = True
@ -279,6 +294,12 @@ class EEStackStatusController(CementBaseController):
else: else:
Log.info(self, "Mail server is not installed") Log.info(self, "Mail server is not installed")
if self.app.pargs.redis:
if EEAptGet.is_installed(self, 'redis-server'):
services = services + ['redis-server']
else:
Log.info(self, "Redis server is not installed")
for service in services: for service in services:
if EEService.get_service_status(self, service): if EEService.get_service_status(self, service):
Log.info(self, "{0:10}: {1}".format(service, "Running")) Log.info(self, "{0:10}: {1}".format(service, "Running"))
@ -290,7 +311,7 @@ class EEStackStatusController(CementBaseController):
if not (self.app.pargs.nginx or self.app.pargs.php if not (self.app.pargs.nginx or self.app.pargs.php
or self.app.pargs.mysql or self.app.pargs.postfix or self.app.pargs.mysql or self.app.pargs.postfix
or self.app.pargs.hhvm or self.app.pargs.memcache or self.app.pargs.hhvm or self.app.pargs.memcache
or self.app.pargs.dovecot): or self.app.pargs.dovecot or self.app.pargs.redis):
self.app.pargs.nginx = True self.app.pargs.nginx = True
self.app.pargs.php = True self.app.pargs.php = True
self.app.pargs.mysql = True self.app.pargs.mysql = True
@ -342,6 +363,12 @@ class EEStackStatusController(CementBaseController):
else: else:
Log.info(self, "Mail server is not installed") Log.info(self, "Mail server is not installed")
if self.app.pargs.redis:
if EEAptGet.is_installed(self, 'redis-server'):
services = services + ['redis-server']
else:
Log.info(self, "Redis server is not installed")
for service in services: for service in services:
Log.debug(self, "Reloading service: {0}".format(service)) Log.debug(self, "Reloading service: {0}".format(service))
EEService.reload_service(self, service) EEService.reload_service(self, service)

65
ee/cli/plugins/stack_upgrade.py

@ -8,6 +8,7 @@ from ee.core.services import EEService
from ee.core.fileutils import EEFileUtils from ee.core.fileutils import EEFileUtils
from ee.core.shellexec import EEShellExec from ee.core.shellexec import EEShellExec
from ee.core.git import EEGit from ee.core.git import EEGit
from ee.core.download import EEDownload
import configparser import configparser
import os import os
@ -39,6 +40,10 @@ class EEStackUpgradeController(CementBaseController):
dict(help='Upgrade HHVM stack', action='store_true')), dict(help='Upgrade HHVM stack', action='store_true')),
(['--postfix'], (['--postfix'],
dict(help='Upgrade Postfix stack', action='store_true')), dict(help='Upgrade Postfix stack', action='store_true')),
(['--wpcli'],
dict(help='Upgrade WPCLI', action='store_true')),
(['--redis'],
dict(help='Upgrade Redis', action='store_true')),
(['--php56'], (['--php56'],
dict(help="Upgrade to PHP5.6 from PHP5.5", dict(help="Upgrade to PHP5.6 from PHP5.5",
action='store_true')), action='store_true')),
@ -101,19 +106,13 @@ class EEStackUpgradeController(CementBaseController):
if ((not self.app.pargs.php56)): if ((not self.app.pargs.php56)):
apt_packages = [] apt_packages = []
packages = []
Log.info(self, "During package update process non nginx-cached"
" parts of your site may remain down")
# Check prompt
if (not self.app.pargs.no_prompt):
start_upgrade = input("Do you want to continue:[y/N]")
if start_upgrade != "Y" and start_upgrade != "y":
Log.error(self, "Not starting package update")
if ((not self.app.pargs.web) and (not self.app.pargs.nginx) and if ((not self.app.pargs.web) and (not self.app.pargs.nginx) and
(not self.app.pargs.php) and (not self.app.pargs.mysql) and (not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.postfix) and (not self.app.pargs.hhvm) and (not self.app.pargs.postfix) and (not self.app.pargs.hhvm) and
(not self.app.pargs.mailscanner) and (not self.app.pargs.all)): (not self.app.pargs.mailscanner) and (not self.app.pargs.all)
and (not self.app.pargs.wpcli) and (not self.app.pargs.redis)):
self.app.pargs.web = True self.app.pargs.web = True
if self.app.pargs.all: if self.app.pargs.all:
@ -125,12 +124,13 @@ class EEStackUpgradeController(CementBaseController):
self.app.pargs.php = True self.app.pargs.php = True
self.app.pargs.mysql = True self.app.pargs.mysql = True
self.app.pargs.postfix = True self.app.pargs.postfix = True
self.app.pargs.hhvm = True self.app.pargs.wpcli = True
if self.app.pargs.mail: if self.app.pargs.mail:
self.app.pargs.nginx = True self.app.pargs.nginx = True
self.app.pargs.php = True self.app.pargs.php = True
self.app.pargs.mysql = True self.app.pargs.mysql = True
self.app.pargs.wpcli = True
self.app.pargs.postfix = True self.app.pargs.postfix = True
if EEAptGet.is_installed(self, 'dovecot-core'): if EEAptGet.is_installed(self, 'dovecot-core'):
@ -169,20 +169,45 @@ class EEStackUpgradeController(CementBaseController):
else: else:
Log.info(self, "Postfix is not installed") Log.info(self, "Postfix is not installed")
if self.app.pargs.redis:
if EEAptGet.is_installed(self, 'redis-server'):
apt_packages = apt_packages + EEVariables.ee_redis
else:
Log.info(self, "Redis is not installed")
if self.app.pargs.wpcli:
if os.path.isfile('/usr/bin/wp'):
packages = packages + [["https://github.com/wp-cli/wp-cli/"
"releases/download/v{0}/"
"wp-cli-{0}.phar"
"".format(EEVariables.ee_wp_cli),
"/usr/bin/wp",
"WP-CLI"]]
else:
Log.info(self, "WPCLI is not installed with EasyEngine")
if self.app.pargs.mailscanner: if self.app.pargs.mailscanner:
if EEAptGet.is_installed(self, 'amavisd-new'): if EEAptGet.is_installed(self, 'amavisd-new'):
apt_packages = (apt_packages + EEVariables.ee_mailscanner) apt_packages = (apt_packages + EEVariables.ee_mailscanner)
else: else:
Log.info(self, "MailScanner is not installed") Log.info(self, "MailScanner is not installed")
if len(packages) or len(apt_packages):
Log.info(self, "During package update process non nginx-cached"
" parts of your site may remain down")
# Check prompt
if (not self.app.pargs.no_prompt):
start_upgrade = input("Do you want to continue:[y/N]")
if start_upgrade != "Y" and start_upgrade != "y":
Log.error(self, "Not starting package update")
Log.info(self, "Updating packages, please wait...")
if len(apt_packages): if len(apt_packages):
# apt-get update # apt-get update
EEAptGet.update(self) EEAptGet.update(self)
# Update packages # Update packages
Log.info(self, "Updating packages, please wait...")
EEAptGet.install(self, apt_packages) EEAptGet.install(self, apt_packages)
Log.info(self, "Successfully updated packages")
# Post Actions after package updates # Post Actions after package updates
if set(EEVariables.ee_nginx).issubset(set(apt_packages)): if set(EEVariables.ee_nginx).issubset(set(apt_packages)):
@ -197,6 +222,20 @@ class EEStackUpgradeController(CementBaseController):
EEService.restart_service(self, 'hhvm') EEService.restart_service(self, 'hhvm')
if set(EEVariables.ee_mail).issubset(set(apt_packages)): if set(EEVariables.ee_mail).issubset(set(apt_packages)):
EEService.restart_service(self, 'dovecot') EEService.restart_service(self, 'dovecot')
if set(EEVariables.ee_redis).issubset(set(apt_packages)):
EEService.restart_service(self, 'redis-server')
if len(packages):
if self.app.pargs.wpcli:
EEFileUtils.remove(self,['/usr/bin/wp'])
Log.debug(self, "Downloading following: {0}".format(packages))
EEDownload.download(self, packages)
if self.app.pargs.wpcli:
EEFileUtils.chmod(self, "/usr/bin/wp", 0o775)
Log.info(self, "Successfully updated packages")
# PHP 5.6 to 5.6 # PHP 5.6 to 5.6
elif (self.app.pargs.php56): elif (self.app.pargs.php56):

57
ee/cli/templates/redis-hhvm.mustache

@ -0,0 +1,57 @@
# Redis NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES 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 0;
}
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 /redis-fetch {
internal ;
set $redis_key $args;
redis_pass redis;
}
location /redis-store {
internal ;
set_unescape_uri $key $arg_key ;
redis2_query set $key $echo_request_body;
redis2_query expire $key 6h;
redis2_pass redis;
}
location ~ \.php$ {
set $key "nginx-cache:$scheme$request_method$host$request_uri";
try_files $uri =404;
srcache_fetch_skip $skip_cache;
srcache_store_skip $skip_cache;
srcache_response_cache_control off;
set_escape_uri $escaped_key $key;
srcache_fetch GET /redis-fetch $key;
srcache_store PUT /redis-store key=$escaped_key;
more_set_headers 'X-Cache $srcache_fetch_status';
more_set_headers 'X-Cache-2 $srcache_store_status';
include fastcgi_params;
fastcgi_pass hhvm;
}

57
ee/cli/templates/redis.mustache

@ -0,0 +1,57 @@
# Redis NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES 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 0;
}
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 /redis-fetch {
internal ;
set $redis_key $args;
redis_pass redis;
}
location /redis-store {
internal ;
set_unescape_uri $key $arg_key ;
redis2_query set $key $echo_request_body;
redis2_query expire $key 14400;
redis2_pass redis;
}
location ~ \.php$ {
set $key "nginx-cache:$scheme$request_method$host$request_uri";
try_files $uri =404;
srcache_fetch_skip $skip_cache;
srcache_store_skip $skip_cache;
srcache_response_cache_control off;
set_escape_uri $escaped_key $key;
srcache_fetch GET /redis-fetch $key;
srcache_store PUT /redis-store key=$escaped_key;
more_set_headers 'X-Cache $srcache_fetch_status';
more_set_headers 'X-Cache-2 $srcache_store_status';
include fastcgi_params;
fastcgi_pass php;
}

4
ee/cli/templates/virtualconf.mustache

@ -13,7 +13,7 @@ server {
#server_name_in_redirect off; #server_name_in_redirect off;
{{/multisite}} {{/multisite}}
access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}}; access_log /var/log/nginx/{{site_name}}.access.log {{^wpredis}}{{^static}}rt_cache{{/static}}{{/wpredis}}{{#wpredis}}rt_cache_redis{{/wpredis}};
error_log /var/log/nginx/{{site_name}}.error.log; error_log /var/log/nginx/{{site_name}}.error.log;
{{#proxy}} {{#proxy}}
@ -40,7 +40,7 @@ server {
} }
{{/static}} {{/static}}
{{^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}} {{^static}}include {{^hhvm}}{{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}}{{#wpredis}}common/redis.conf;{{/wpredis}} {{/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}}{{#wpredis}}common/redis-hhvm.conf;{{/wpredis}} {{/hhvm}}
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}}
{{#wp}}include common/wpcommon.conf;{{/wp}} {{#wp}}include common/wpcommon.conf;{{/wp}}
{{^proxy}}include common/locations.conf;{{/proxy}} {{^proxy}}include common/locations.conf;{{/proxy}}

2
ee/core/extract.py

@ -16,6 +16,6 @@ class EEExtract():
os.remove(file) os.remove(file)
return True return True
except tarfile.TarError as e: except tarfile.TarError as e:
Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) Log.debug(self, "{0}".format(e))
Log.error(self, 'Unable to extract file \{0}'.format(file)) Log.error(self, 'Unable to extract file \{0}'.format(file))
return False return False

19
ee/core/variables.py

@ -12,14 +12,19 @@ class EEVariables():
"""Intialization of core variables""" """Intialization of core variables"""
# EasyEngine version # EasyEngine version
ee_version = "3.2.2" ee_version = "3.3.0"
# EasyEngine packages versions # EasyEngine packages versions
ee_wp_cli = "0.19.1" ee_wp_cli = "0.19.2"
ee_adminer = "4.2.1" 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"
# Get WPCLI path
ee_wpcli_path = os.popen('which wp | tr "\n" " "').read()
if ee_wpcli_path == '':
ee_wpcli_path = '/usr/bin/wp '
# Current date and time of System # Current date and time of System
ee_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S') ee_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S')
@ -154,6 +159,16 @@ class EEVariables():
ee_hhvm = ["hhvm"] ee_hhvm = ["hhvm"]
# Redis repo details
if ee_platform_distro == 'ubuntu':
ee_redis_repo = ("ppa:chris-lea/redis-server")
else:
ee_redis_repo = ("deb http://packages.dotdeb.org {codename} all"
.format(codename=ee_platform_codename))
ee_redis = ['redis-server', 'php5-redis']
# Repo path # Repo path
ee_repo_file = "ee-repo.list" ee_repo_file = "ee-repo.list"
ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file) ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file)

2
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.2.2" readonly ee_version_new="3.3.0"
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}')

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.2.2', version='3.3.0',
description=long_description, description=long_description,
long_description=long_description, long_description=long_description,
classifiers=[], classifiers=[],

Loading…
Cancel
Save