Browse Source

Merge branch 'master' into stable

stable v3.1.2
gau1991 10 years ago
parent
commit
9a5d447bbe
  1. 4
      .travis.yml
  2. 8
      CHANGELOG.txt
  3. 45
      config/bash_completion.d/ee_auto.rc
  4. 17
      ee/cli/plugins/debug.py
  5. 118
      ee/cli/plugins/site.py
  6. 31
      ee/cli/plugins/site_functions.py
  7. 57
      ee/cli/plugins/stack.py
  8. 6
      ee/cli/plugins/stack_migrate.py
  9. 195
      ee/cli/plugins/stack_upgrade.py
  10. 2
      ee/cli/plugins/sync.py
  11. 2
      ee/cli/plugins/update.py
  12. 2
      ee/cli/templates/siteinfo.mustache
  13. 18
      ee/cli/templates/virtualconf.mustache
  14. 20
      ee/core/apt_repo.py
  15. 62
      ee/core/aptget.py
  16. 24
      ee/core/variables.py
  17. 14
      install
  18. 12
      setup.py

4
.travis.yml

@ -14,6 +14,7 @@ before_install:
- rm -rf ~/.gnupg - rm -rf ~/.gnupg
before_script: before_script:
- sudo rm -rf /etc/mysql/
- sudo bash -c 'echo example.com > /etc/hostname' - sudo bash -c 'echo example.com > /etc/hostname'
- sudo service hostname restart - sudo service hostname restart
- sudo apt-get -qq purge mysql* graphviz* - sudo apt-get -qq purge mysql* graphviz*
@ -22,7 +23,7 @@ before_script:
script: script:
- unset LANG - unset LANG
- sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig - sudo bash -c 'echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > /home/travis/.gitconfig'
- sudo echo "Travis Banch = $TRAVIS_BRANCH" - sudo echo "Travis Banch = $TRAVIS_BRANCH"
- sudo apt-get install -y --force-yes git python3-setuptools python3-dev python3-apt - sudo apt-get install -y --force-yes git python3-setuptools python3-dev python3-apt
- sudo bash install $TRAVIS_BRANCH - sudo bash install $TRAVIS_BRANCH
@ -117,3 +118,4 @@ script:
- sudo ee stack install --mail - sudo ee stack install --mail
- sudo ls /var/www/ - sudo ls /var/www/
- sudo wp --allow-root --info - sudo wp --allow-root --info
- sudo bash -c 'cat /var/log/ee/ee.log'

8
CHANGELOG.txt

@ -1,3 +1,11 @@
v 3.1.2 - April 29, 2015
- Updated PHP version from PHP 5.5 to PHP 5.6 #425
- Added ee stack upgrade command for stack upgrade #458
- Added support for Proxy site creation #389
- Added extra parameters such as User, Password and EMail during site creation #453
- Fixed timezone related warnings and errors #451
v 3.1.1 - April 21, 2015 v 3.1.1 - April 21, 2015
- Feature: update all site at once #491 - Feature: update all site at once #491
- Tweaked import-slow-log command #322 - Tweaked import-slow-log command #322

45
config/bash_completion.d/ee_auto.rc

@ -35,7 +35,7 @@ _ee_complete()
"stack") "stack")
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "install purge reload remove restart start status stop migrate" \ -W "upgrade install purge reload remove restart start status stop migrate" \
-- $cur) ) -- $cur) )
;; ;;
@ -74,7 +74,12 @@ _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 "--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot --all --mailscanner --hhvm" \ -W "--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --all --mailscanner --hhvm" \
-- $cur) )
;;
"upgrade" )
COMPREPLY=( $(compgen \
-W "--web --mail --nginx --php --mysql --postfix --all --hhvm --php56 --no-prompt" \
-- $cur) ) -- $cur) )
;; ;;
"start" | "stop" | "reload" | "restart" | "status") "start" | "stop" | "reload" | "restart" | "status")
@ -160,7 +165,7 @@ _ee_complete()
"create") "create")
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "--html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed" \ -W "--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --proxy= --pagespeed" \
-- $cur) ) -- $cur) )
;; ;;
@ -211,7 +216,13 @@ _ee_complete()
case "$prev" in case "$prev" in
"--wp" | "--wpsubdir" | "--wpsubdomain") "--wp" | "--wpsubdir" | "--wpsubdomain")
if [ ${COMP_WORDS[1]} != "debug" ]; then if [ ${COMP_WORDS[1]} != "debug" ]; then
retlist="--w3tc --wpfc --wpsc" if [ ${COMP_WORDS[2]} == "create" ]; then
retlist="--w3tc --wpfc --wpsc --pagespeed --hhvm --user --email --pass"
elif [ ${COMP_WORDS[2]} == "update" ]; then
retlist="--w3tc --wpfc --wpsc --pagespeed --hhvm --pagespeed=off --hhvm=off"
else
retlist=""
fi
else else
retlist="--wp=off --rewrite --rewrite=off -i --interactive" retlist="--wp=off --rewrite --rewrite=off -i --interactive"
fi fi
@ -222,6 +233,21 @@ _ee_complete()
-- $cur) ) -- $cur) )
;; ;;
"--pagespeed" | "--hhvm")
if [ ${COMP_WORDS[2]} == "create" ]; then
retlist="--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed"
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
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \
-W "$(echo $ret)" \
-- $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")
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"
@ -310,6 +336,17 @@ _ee_complete()
*) *)
;; ;;
esac esac
case "$mprev" in
"--user" | "--email" | "--pass")
if [ ${COMP_WORDS[2]} == "create" ]; then
retlist="--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed"
fi
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \
-W "$(echo $ret)" \
-- $cur) )
;;
esac
return 0 return 0

17
ee/cli/plugins/debug.py

@ -180,6 +180,17 @@ class EEDebugController(CementBaseController):
";zend_extension", ";zend_extension",
"zend_extension") "zend_extension")
# Fix slow log is not enabled default in PHP5.6
config = configparser.ConfigParser()
config.read('/etc/php5/fpm/pool.d/debug.conf')
config['debug']['slowlog'] = '/var/log/php5/slow.log'
config['debug']['request_slowlog_timeout'] = '10s'
with open('/etc/php5/fpm/pool.d/debug.conf',
encoding='utf-8', mode='w') as confifile:
Log.debug(self, "Writting debug.conf configuration into "
"/etc/php5/fpm/pool.d/debug.conf")
config.write(confifile)
self.trigger_php = True self.trigger_php = True
self.trigger_nginx = True self.trigger_nginx = True
else: else:
@ -505,7 +516,7 @@ class EEDebugController(CementBaseController):
"'ee debug --import-slow-log'"): "'ee debug --import-slow-log'"):
if not cron_time == 0: if not cron_time == 0:
Log.info(self, "setting up crontab entry," Log.info(self, "setting up crontab entry,"
" please wait ...") " please wait...")
EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l " EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
"2> /dev/null | {{ cat; echo -e" "2> /dev/null | {{ cat; echo -e"
" \\\"#EasyEngine start MySQL " " \\\"#EasyEngine start MySQL "
@ -518,7 +529,7 @@ class EEDebugController(CementBaseController):
else: else:
if not cron_time == 0: if not cron_time == 0:
Log.info(self, "updating crontab entry," Log.info(self, "updating crontab entry,"
" please wait ...") " please wait...")
if not EEShellExec.cmd_exec(self, "/bin/bash -c " if not EEShellExec.cmd_exec(self, "/bin/bash -c "
"\"crontab " "\"crontab "
"-l | sed '/EasyEngine " "-l | sed '/EasyEngine "
@ -533,7 +544,7 @@ class EEDebugController(CementBaseController):
Log.error(self, "failed to update crontab entry") Log.error(self, "failed to update crontab entry")
else: else:
Log.info(self, "removing crontab entry," Log.info(self, "removing crontab entry,"
" please wait ...") " please wait...")
if not EEShellExec.cmd_exec(self, "/bin/bash -c " if not EEShellExec.cmd_exec(self, "/bin/bash -c "
"\"crontab " "\"crontab "
"-l | sed '/EasyEngine " "-l | sed '/EasyEngine "

118
ee/cli/plugins/site.py

@ -144,6 +144,10 @@ class EESiteController(CementBaseController):
ee_db_host = siteinfo.db_host ee_db_host = siteinfo.db_host
if sitetype != "html": if sitetype != "html":
hhvm = ("enabled" if siteinfo.is_hhvm else "disabled") hhvm = ("enabled" if siteinfo.is_hhvm else "disabled")
if sitetype == "proxy":
access_log = "/var/log/nginx/{0}.access.log".format(ee_domain)
error_log = "/var/log/nginx/{0}.error.log".format(ee_domain)
ee_site_webroot = ''
pagespeed = ("enabled" if siteinfo.is_pagespeed else "disabled") pagespeed = ("enabled" if siteinfo.is_pagespeed else "disabled")
@ -338,6 +342,15 @@ class EESiteCreateController(CementBaseController):
dict(help="create HHVM site", action='store_true')), dict(help="create HHVM site", action='store_true')),
(['--pagespeed'], (['--pagespeed'],
dict(help="create pagespeed site", action='store_true')), dict(help="create pagespeed site", action='store_true')),
(['--user'],
dict(help="provide user for wordpress site")),
(['--email'],
dict(help="provide email address for wordpress site")),
(['--pass'],
dict(help="provide password for wordpress user",
dest='wppass')),
(['--proxy'],
dict(help="create proxy for site", nargs='+'))
] ]
@expose(hide=True) @expose(hide=True)
@ -345,12 +358,29 @@ class EESiteCreateController(CementBaseController):
# self.app.render((data), 'default.mustache') # self.app.render((data), 'default.mustache')
# Check domain name validation # Check domain name validation
data = dict() data = dict()
host, port = None, None
try: try:
stype, cache = detSitePar(vars(self.app.pargs)) stype, cache = detSitePar(vars(self.app.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 to creating site") Log.error(self, "Please provide valid options to creating site")
if stype is None and self.app.pargs.proxy:
stype, cache = 'proxy', ''
proxyinfo = self.app.pargs.proxy[0].strip()
if not proxyinfo:
Log.error(self, "Please provide proxy server host information")
proxyinfo = proxyinfo.split(':')
host = proxyinfo[0].strip()
port = '80' if len(proxyinfo) < 2 else proxyinfo[1].strip()
elif stype is None and not self.app.pargs.proxy:
stype, cache = 'html', 'basic'
elif stype and self.app.pargs.proxy:
Log.error(self, "proxy should not be used with other site types")
if (self.app.pargs.proxy and (self.app.pargs.pagespeed
or self.app.pargs.hhvm)):
Log.error(self, "Proxy site can not run on pagespeed or hhvm")
if not self.app.pargs.site_name: if not self.app.pargs.site_name:
try: try:
while not self.app.pargs.site_name: while not self.app.pargs.site_name:
@ -377,6 +407,14 @@ class EESiteCreateController(CementBaseController):
Log.error(self, "Nginx configuration /etc/nginx/sites-available/" Log.error(self, "Nginx configuration /etc/nginx/sites-available/"
"{0} already exists".format(ee_domain)) "{0} already exists".format(ee_domain))
if stype == 'proxy':
data['site_name'] = ee_domain
data['www_domain'] = ee_www_domain
data['proxy'] = True
data['host'] = host
data['port'] = port
ee_site_webroot = ""
if stype in ['html', 'php']: if stype in ['html', 'php']:
data = dict(site_name=ee_domain, www_domain=ee_www_domain, data = dict(site_name=ee_domain, www_domain=ee_www_domain,
static=True, basic=False, wp=False, w3tc=False, static=True, basic=False, wp=False, w3tc=False,
@ -386,6 +424,7 @@ class EESiteCreateController(CementBaseController):
if stype == 'php': if stype == 'php':
data['static'] = False data['static'] = False
data['basic'] = True data['basic'] = True
elif stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']: elif stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
data = dict(site_name=ee_domain, www_domain=ee_www_domain, data = dict(site_name=ee_domain, www_domain=ee_www_domain,
@ -399,10 +438,15 @@ class EESiteCreateController(CementBaseController):
data['wp'] = True data['wp'] = True
data['basic'] = False data['basic'] = False
data[cache] = True data[cache] = True
data['wp-user'] = self.app.pargs.user
data['wp-email'] = self.app.pargs.email
data['wp-pass'] = self.app.pargs.wppass
if stype in ['wpsubdir', 'wpsubdomain']: if stype in ['wpsubdir', 'wpsubdomain']:
data['multisite'] = True data['multisite'] = True
if stype == 'wpsubdir': if stype == 'wpsubdir':
data['wpsubdir'] = True data['wpsubdir'] = True
else:
pass
if stype == "html" and self.app.pargs.hhvm: if stype == "html" and self.app.pargs.hhvm:
Log.error(self, "Can not create HTML site with HHVM") Log.error(self, "Can not create HTML site with HHVM")
@ -421,13 +465,12 @@ class EESiteCreateController(CementBaseController):
data['pagespeed'] = False data['pagespeed'] = False
pagespeed = 0 pagespeed = 0
if not data: # if not data:
self.app.args.print_help() # self.app.args.print_help()
self.app.close(1) # self.app.close(1)
# Check rerequired packages are installed or not # Check rerequired packages are installed or not
ee_auth = site_package_check(self, stype) ee_auth = site_package_check(self, stype)
try: try:
try: try:
# setup NGINX configuration, and webroot # setup NGINX configuration, and webroot
@ -442,12 +485,23 @@ class EESiteCreateController(CementBaseController):
Log.error(self, "Check logs for reason " Log.error(self, "Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
if 'proxy' in data.keys() and data['proxy']:
addNewSite(self, ee_domain, stype, cache, ee_site_webroot)
# Service Nginx Reload
EEService.reload_service(self, 'nginx')
if ee_auth and len(ee_auth):
for msg in ee_auth:
Log.info(self, Log.ENDC + msg, log=False)
Log.info(self, "Successfully created site"
" http://{0}".format(ee_domain))
return
# Update pagespeed config # Update pagespeed config
if self.app.pargs.pagespeed: if self.app.pargs.pagespeed:
operateOnPagespeed(self, data) operateOnPagespeed(self, data)
addNewSite(self, ee_domain, stype, cache, ee_site_webroot, addNewSite(self, ee_domain, stype, cache, ee_site_webroot,
hhvm=hhvm, pagespeed=pagespeed) hhvm=hhvm, pagespeed=pagespeed)
# Setup database for MySQL site # Setup database for MySQL site
if 'ee_db_name' in data.keys() and not data['wp']: if 'ee_db_name' in data.keys() and not data['wp']:
try: try:
@ -605,6 +659,8 @@ class EESiteUpdateController(CementBaseController):
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='?')),
(['--proxy'],
dict(help="update to prxy site", nargs='+')),
(['--all'], (['--all'],
dict(help="update all sites", action='store_true')), dict(help="update all sites", action='store_true')),
] ]
@ -633,7 +689,7 @@ class EESiteUpdateController(CementBaseController):
for site in sites: for site in sites:
pargs.site_name = site.sitename pargs.site_name = site.sitename
Log.info(self, Log.ENDC + Log.BOLD + "Updating site {0}," Log.info(self, Log.ENDC + Log.BOLD + "Updating site {0},"
" please wait ..." " please wait..."
.format(pargs.site_name)) .format(pargs.site_name))
self.doupdatesite(pargs) self.doupdatesite(pargs)
print("\n") print("\n")
@ -652,6 +708,21 @@ class EESiteUpdateController(CementBaseController):
Log.error(self, "Please provide valid options combination for" Log.error(self, "Please provide valid options combination for"
" site update") " site update")
if stype is None and pargs.proxy:
stype, cache = 'proxy', ''
proxyinfo = pargs.proxy[0].strip()
if not proxyinfo:
Log.error(self, "Please provide proxy server host information")
proxyinfo = proxyinfo.split(':')
host = proxyinfo[0].strip()
port = '80' if len(proxyinfo) < 2 else proxyinfo[1].strip()
elif stype is None and not pargs.proxy:
stype, cache = 'html', 'basic'
elif stype and pargs.proxy:
Log.error(self, "--proxy can not be used with other site types")
if (pargs.proxy and (pargs.pagespeed or pargs.hhvm)):
Log.error(self, "Proxy site can not run on pagespeed or hhvm")
if not pargs.site_name: if not pargs.site_name:
try: try:
while not pargs.site_name: while not pargs.site_name:
@ -685,14 +756,21 @@ class EESiteUpdateController(CementBaseController):
Log.info(self, "Password Unchanged.") Log.info(self, "Password Unchanged.")
return 0 return 0
if ((stype == "proxy" and stype == oldsitetype and self.app.pargs.hhvm)
or (stype == "proxy" and
stype == oldsitetype and self.app.pargs.pagespeed)):
Log.info(self, Log.FAIL +
"Can not update proxy site to HHVM or Pagespeed")
return 1
if stype == "html" and stype == oldsitetype and self.app.pargs.hhvm: if stype == "html" and stype == oldsitetype and self.app.pargs.hhvm:
Log.info(self, Log.FAIL + "Can not update HTML site to HHVM") Log.info(self, Log.FAIL + "Can not update HTML site to HHVM")
return 1 return 1
if ((stype == 'php' and oldsitetype != 'html') or if ((stype == 'php' and oldsitetype not in ['html', 'proxy']) or
(stype == 'mysql' and oldsitetype not in ['html', 'php']) or (stype == 'mysql' and oldsitetype not in ['html', 'php',
'proxy']) or
(stype == 'wp' and oldsitetype not in ['html', 'php', 'mysql', (stype == 'wp' and oldsitetype not in ['html', 'php', 'mysql',
'wp']) or 'proxy', '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) and (stype == oldsitetype and cache == oldcachetype) and
@ -701,6 +779,18 @@ class EESiteUpdateController(CementBaseController):
format(oldsitetype, oldcachetype, stype, cache)) format(oldsitetype, oldcachetype, stype, cache))
return 1 return 1
if stype == 'proxy':
data['site_name'] = ee_domain
data['www_domain'] = ee_www_domain
data['proxy'] = True
data['host'] = host
data['port'] = port
pagespeed = False
hhvm = False
data['webroot'] = ee_site_webroot
data['currsitetype'] = oldsitetype
data['currcachetype'] = oldcachetype
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,
@ -736,8 +826,7 @@ class EESiteUpdateController(CementBaseController):
stype = oldsitetype stype = oldsitetype
cache = oldcachetype cache = oldcachetype
if oldsitetype == 'html' or oldsitetype == 'proxy':
if oldsitetype == 'html':
data['static'] = True data['static'] = True
data['wp'] = False data['wp'] = False
data['multisite'] = False data['multisite'] = False
@ -871,6 +960,13 @@ class EESiteUpdateController(CementBaseController):
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
return 1 return 1
if 'proxy' in data.keys() and data['proxy']:
updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
hhvm=hhvm, pagespeed=pagespeed)
Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain))
return 0
# Update pagespeed config # Update pagespeed config
if pargs.pagespeed: if pargs.pagespeed:
operateOnPagespeed(self, data) operateOnPagespeed(self, data)
@ -917,7 +1013,7 @@ class EESiteUpdateController(CementBaseController):
return 1 return 1
# 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', 'proxy', 'php', 'mysql']:
try: try:
ee_wp_creds = setupwordpress(self, data) ee_wp_creds = setupwordpress(self, data)
except SiteError as e: except SiteError as e:

31
ee/cli/plugins/site_functions.py

@ -31,7 +31,7 @@ class SiteError(Exception):
def pre_run_checks(self): def pre_run_checks(self):
# Check nginx configuration # Check nginx configuration
Log.info(self, "Running pre-update checks, please wait ...") Log.info(self, "Running pre-update checks, please wait...")
try: try:
Log.debug(self, "checking NGINX configuration ...") Log.debug(self, "checking NGINX configuration ...")
FNULL = open('/dev/null', 'w') FNULL = open('/dev/null', 'w')
@ -52,7 +52,7 @@ def check_domain_exists(self, domain):
def setupdomain(self, data): def setupdomain(self, data):
ee_domain_name = data['site_name'] ee_domain_name = data['site_name']
ee_site_webroot = data['webroot'] ee_site_webroot = data['webroot'] if 'webroot' in data.keys() else ''
# Check if nginx configuration already exists # Check if nginx configuration already exists
# if os.path.isfile('/etc/nginx/sites-available/{0}' # if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -78,7 +78,7 @@ def setupdomain(self, data):
finally: finally:
# Check nginx -t and return status over it # Check nginx -t and return status over it
try: try:
Log.debug(self, "Checking generated nginx conf, please wait ...") Log.debug(self, "Checking generated nginx conf, please wait...")
FNULL = open('/dev/null', 'w') FNULL = open('/dev/null', 'w')
ret = subprocess.check_call(["nginx", "-t"], stdout=FNULL, ret = subprocess.check_call(["nginx", "-t"], stdout=FNULL,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
@ -90,6 +90,9 @@ def setupdomain(self, data):
raise SiteError("created nginx configuration failed for site." raise SiteError("created nginx configuration failed for site."
" check with `nginx -t`") " check with `nginx -t`")
if 'proxy' in data.keys() and data['proxy']:
return
# create symbolic link for # create symbolic link for
EEFileUtils.create_symlink(self, ['/etc/nginx/sites-available/{0}' EEFileUtils.create_symlink(self, ['/etc/nginx/sites-available/{0}'
.format(ee_domain_name), .format(ee_domain_name),
@ -235,6 +238,13 @@ def setupwordpress(self, data):
# ee_wp_user = '' # ee_wp_user = ''
# ee_wp_pass = '' # ee_wp_pass = ''
if 'wp-user' in data.keys() and data['wp-user']:
ee_wp_user = data['wp-user']
if 'wp-email' in data.keys() and data['wp-email']:
ee_wp_email = data['wp-email']
if 'wp-pass' in data.keys() and data['wp-pass']:
ee_wp_pass = data['wp-pass']
Log.info(self, "Downloading Wordpress \t\t", end='') Log.info(self, "Downloading Wordpress \t\t", end='')
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
try: try:
@ -456,7 +466,7 @@ def setupwordpressnetwork(self, data):
def installwp_plugin(self, plugin_name, data): def installwp_plugin(self, plugin_name, data):
ee_site_webroot = data['webroot'] ee_site_webroot = data['webroot']
Log.info(self, "Installing plugin {0}, please wait ..." Log.info(self, "Installing 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))
try: try:
@ -480,7 +490,7 @@ def installwp_plugin(self, plugin_name, data):
def uninstallwp_plugin(self, plugin_name, data): def uninstallwp_plugin(self, plugin_name, data):
ee_site_webroot = data['webroot'] ee_site_webroot = data['webroot']
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))
try: try:
@ -510,7 +520,7 @@ def sitebackup(self, data):
EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}' EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}'
.format(data['site_name']), backup_path) .format(data['site_name']), backup_path)
if data['currsitetype'] in ['html', 'php', 'mysql']: if data['currsitetype'] in ['html', 'php', 'proxy', 'mysql']:
Log.info(self, "Backing up Webroot \t\t", end='') Log.info(self, "Backing up Webroot \t\t", end='')
EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path) EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path)
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
@ -534,7 +544,7 @@ def sitebackup(self, data):
raise SiteError("mysqldump failed to backup database") raise SiteError("mysqldump failed to backup database")
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
# move wp-config.php/ee-config.php to backup # move wp-config.php/ee-config.php to backup
if data['currsitetype'] in ['mysql']: if data['currsitetype'] in ['mysql', 'proxy']:
EEFileUtils.mvfile(self, configfiles[0], backup_path) EEFileUtils.mvfile(self, configfiles[0], backup_path)
else: else:
EEFileUtils.copyfile(self, configfiles[0], backup_path) EEFileUtils.copyfile(self, configfiles[0], backup_path)
@ -545,7 +555,8 @@ def site_package_check(self, stype):
packages = [] packages = []
stack = EEStackController() stack = EEStackController()
stack.app = self.app stack.app = self.app
if stype in ['html', 'php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']: if stype in ['html', 'proxy', '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':
@ -790,8 +801,8 @@ def detSitePar(opts):
raise RuntimeError("could not determine site and cache type") raise RuntimeError("could not determine site and cache type")
else: else:
if not typelist and not cachelist: if not typelist and not cachelist:
sitetype = 'html' sitetype = None
cachetype = 'basic' cachetype = None
elif (not typelist) and cachelist: elif (not typelist) and cachelist:
sitetype = 'wp' sitetype = 'wp'
cachetype = cachelist[0] cachetype = cachelist[0]

57
ee/cli/plugins/stack.py

@ -27,6 +27,7 @@ import grp
import codecs import codecs
from ee.cli.plugins.stack_services import EEStackStatusController from ee.cli.plugins.stack_services import EEStackStatusController
from ee.cli.plugins.stack_migrate import EEStackMigrateController from ee.cli.plugins.stack_migrate import EEStackMigrateController
from ee.cli.plugins.stack_upgrade import EEStackUpgradeController
from ee.core.logging import Log from ee.core.logging import Log
@ -95,7 +96,7 @@ class EEStackController(CementBaseController):
Log.error(self, "Failed to intialize postfix package") Log.error(self, "Failed to intialize postfix package")
if set(EEVariables.ee_mysql).issubset(set(apt_packages)): if set(EEVariables.ee_mysql).issubset(set(apt_packages)):
Log.info(self, "Adding repository for MySQL, please wait ...") Log.info(self, "Adding repository for MySQL, please wait...")
mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au" mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au"
"\nPin-Priority: 1000\n") "\nPin-Priority: 1000\n")
with open('/etc/apt/preferences.d/' with open('/etc/apt/preferences.d/'
@ -149,7 +150,7 @@ class EEStackController(CementBaseController):
config.write(configfile) config.write(configfile)
if set(EEVariables.ee_nginx).issubset(set(apt_packages)): if set(EEVariables.ee_nginx).issubset(set(apt_packages)):
Log.info(self, "Adding repository for NGINX, please wait ...") Log.info(self, "Adding repository for NGINX, please wait...")
if EEVariables.ee_platform_distro == 'debian': if EEVariables.ee_platform_distro == 'debian':
Log.debug(self, 'Adding Dotdeb/nginx GPG key') Log.debug(self, 'Adding Dotdeb/nginx GPG key')
EERepo.add(self, repo_url=EEVariables.ee_nginx_repo) EERepo.add(self, repo_url=EEVariables.ee_nginx_repo)
@ -158,7 +159,7 @@ class EEStackController(CementBaseController):
Log.debug(self, 'Adding ppa of Nginx') Log.debug(self, 'Adding ppa of Nginx')
if set(EEVariables.ee_php).issubset(set(apt_packages)): if set(EEVariables.ee_php).issubset(set(apt_packages)):
Log.info(self, "Adding repository for PHP, please wait ...") Log.info(self, "Adding repository for PHP, please wait...")
if EEVariables.ee_platform_distro == 'debian': if EEVariables.ee_platform_distro == 'debian':
Log.debug(self, 'Adding repo_url of php for debian') Log.debug(self, 'Adding repo_url of php for debian')
EERepo.add(self, repo_url=EEVariables.ee_php_repo) EERepo.add(self, repo_url=EEVariables.ee_php_repo)
@ -169,7 +170,7 @@ class EEStackController(CementBaseController):
EERepo.add(self, ppa=EEVariables.ee_php_repo) EERepo.add(self, ppa=EEVariables.ee_php_repo)
if set(EEVariables.ee_hhvm).issubset(set(apt_packages)): if set(EEVariables.ee_hhvm).issubset(set(apt_packages)):
Log.info(self, "Adding repository for HHVM, please wait ...") Log.info(self, "Adding repository for HHVM, please wait...")
if EEVariables.ee_platform_codename == 'precise': if EEVariables.ee_platform_codename == 'precise':
Log.debug(self, 'Adding PPA for Boost') Log.debug(self, 'Adding PPA for Boost')
EERepo.add(self, ppa=EEVariables.ee_boost_repo) EERepo.add(self, ppa=EEVariables.ee_boost_repo)
@ -469,6 +470,21 @@ class EEStackController(CementBaseController):
Log.debug(self, 'Creating directory /var/log/php5/') Log.debug(self, 'Creating directory /var/log/php5/')
os.makedirs('/var/log/php5/') os.makedirs('/var/log/php5/')
# For debian install xdebug
if EEVariables.ee_platform_distro == "debian":
EEShellExec.cmd_exec(self, "pecl install xdebug")
with open("/etc/php5/mods-available/xdebug.ini",
encoding='utf-8', mode='a') as myfile:
myfile.write("zend_extension=/usr/lib/php5/20131226/"
"xdebug.so\n")
EEFileUtils.create_symlink(self, ["/etc/php5/"
"mods-available/xdebug.ini",
"/etc/php5/fpm/conf.d"
"/20-xedbug.ini"])
# Parse etc/php5/fpm/php.ini # Parse etc/php5/fpm/php.ini
config = configparser.ConfigParser() config = configparser.ConfigParser()
Log.debug(self, "configuring php file /etc/php5/fpm/php.ini") Log.debug(self, "configuring php file /etc/php5/fpm/php.ini")
@ -477,7 +493,7 @@ class EEStackController(CementBaseController):
config['PHP']['post_max_size'] = '100M' config['PHP']['post_max_size'] = '100M'
config['PHP']['upload_max_filesize'] = '100M' config['PHP']['upload_max_filesize'] = '100M'
config['PHP']['max_execution_time'] = '300' config['PHP']['max_execution_time'] = '300'
config['PHP']['date.timezone'] = time.tzname[time.daylight] config['PHP']['date.timezone'] = EEVariables.ee_timezone
with open('/etc/php5/fpm/php.ini', with open('/etc/php5/fpm/php.ini',
encoding='utf-8', mode='w') as configfile: encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php configuration into " Log.debug(self, "Writting php configuration into "
@ -529,6 +545,8 @@ class EEStackController(CementBaseController):
config.read('/etc/php5/fpm/pool.d/debug.conf') config.read('/etc/php5/fpm/pool.d/debug.conf')
config['debug']['listen'] = '127.0.0.1:9001' config['debug']['listen'] = '127.0.0.1:9001'
config['debug']['rlimit_core'] = 'unlimited' config['debug']['rlimit_core'] = 'unlimited'
config['debug']['slowlog'] = '/var/log/php5/slow.log'
config['debug']['request_slowlog_timeout'] = '10s'
with open('/etc/php5/fpm/pool.d/debug.conf', with open('/etc/php5/fpm/pool.d/debug.conf',
encoding='utf-8', mode='w') as confifile: encoding='utf-8', mode='w') as confifile:
Log.debug(self, "writting PHP5 configuration into " Log.debug(self, "writting PHP5 configuration into "
@ -1008,10 +1026,22 @@ class EEStackController(CementBaseController):
shutil.move('/tmp/webgrind-master/', shutil.move('/tmp/webgrind-master/',
'{0}22222/htdocs/php/webgrind' '{0}22222/htdocs/php/webgrind'
.format(EEVariables.ee_webroot)) .format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "sed -i \"s\'/usr/local/bin/dot\'"
"/usr/bin/dot\'\" {0}22222/htdocs/" EEFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/"
"php/webgrind/config.php" "config.php"
.format(EEVariables.ee_webroot)) .format(EEVariables.ee_webroot),
"/usr/local/bin/dot", "/usr/bin/dot")
EEFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/"
"config.php"
.format(EEVariables.ee_webroot),
"Europe/Copenhagen",
EEVariables.ee_timezone)
EEFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/"
"config.php"
.format(EEVariables.ee_webroot),
"90", "100")
Log.debug(self, "Setting Privileges of webroot permission to " Log.debug(self, "Setting Privileges of webroot permission to "
"{0}22222/htdocs/php/webgrind/ file " "{0}22222/htdocs/php/webgrind/ file "
.format(EEVariables.ee_webroot)) .format(EEVariables.ee_webroot))
@ -1552,9 +1582,9 @@ class EEStackController(CementBaseController):
self.pre_pref(apt_packages) self.pre_pref(apt_packages)
if len(apt_packages): if len(apt_packages):
EESwap.add(self) EESwap.add(self)
Log.info(self, "Updating apt-cache, please wait ...") Log.info(self, "Updating apt-cache, please wait...")
EEAptGet.update(self) EEAptGet.update(self)
Log.info(self, "Installing packages, please wait ...") Log.info(self, "Installing packages, please wait...")
EEAptGet.install(self, apt_packages) EEAptGet.install(self, apt_packages)
if len(packages): if len(packages):
Log.debug(self, "Downloading following: {0}".format(packages)) Log.debug(self, "Downloading following: {0}".format(packages))
@ -1672,7 +1702,7 @@ class EEStackController(CementBaseController):
if len(apt_packages): if len(apt_packages):
if ee_prompt == 'YES' or ee_prompt == 'yes': if ee_prompt == 'YES' or ee_prompt == 'yes':
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)
@ -1785,7 +1815,7 @@ class EEStackController(CementBaseController):
if len(apt_packages): if len(apt_packages):
if ee_prompt == 'YES' or ee_prompt == 'yes': if ee_prompt == 'YES' or ee_prompt == 'yes':
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)
@ -1803,6 +1833,7 @@ def load(app):
handler.register(EEStackController) handler.register(EEStackController)
handler.register(EEStackStatusController) handler.register(EEStackStatusController)
handler.register(EEStackMigrateController) handler.register(EEStackMigrateController)
handler.register(EEStackUpgradeController)
# register a hook (function) to run after arguments are parsed. # register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', ee_stack_hook) hook.register('post_argument_parsing', ee_stack_hook)

6
ee/cli/plugins/stack_migrate.py

@ -31,7 +31,7 @@ class EEStackMigrateController(CementBaseController):
EEMysql.backupAll(self) EEMysql.backupAll(self)
# Add MariaDB repo # Add MariaDB repo
Log.info(self, "Adding repository for MariaDB, please wait ...") Log.info(self, "Adding repository for MariaDB, please wait...")
mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au" mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au"
"\nPin-Priority: 1000\n") "\nPin-Priority: 1000\n")
@ -87,9 +87,9 @@ class EEStackMigrateController(CementBaseController):
apt_packages = apt_packages + ["dovecot-mysql", "postfix-mysql", apt_packages = apt_packages + ["dovecot-mysql", "postfix-mysql",
"libclass-dbi-mysql-perl"] "libclass-dbi-mysql-perl"]
Log.info(self, "Updating apt-cache, please wait ...") Log.info(self, "Updating apt-cache, please wait...")
EEAptGet.update(self) EEAptGet.update(self)
Log.info(self, "Installing MariaDB, please wait ...") Log.info(self, "Installing MariaDB, please wait...")
EEAptGet.remove(self, ["mysql-common", "libmysqlclient18"]) EEAptGet.remove(self, ["mysql-common", "libmysqlclient18"])
EEAptGet.auto_remove(self) EEAptGet.auto_remove(self)
EEAptGet.install(self, apt_packages) EEAptGet.install(self, apt_packages)

195
ee/cli/plugins/stack_upgrade.py

@ -0,0 +1,195 @@
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.logging import Log
from ee.core.variables import EEVariables
from ee.core.aptget import EEAptGet
from ee.core.apt_repo import EERepo
from ee.core.services import EEService
from ee.core.fileutils import EEFileUtils
from ee.core.shellexec import EEShellExec
import configparser
import os
class EEStackUpgradeController(CementBaseController):
class Meta:
label = 'upgrade'
stacked_on = 'stack'
stacked_type = 'nested'
description = ('Upgrade stack safely')
arguments = [
(['--all'],
dict(help='Upgrade all stack', action='store_true')),
(['--web'],
dict(help='Upgrade web stack', action='store_true')),
(['--admin'],
dict(help='Upgrade admin tools stack', action='store_true')),
(['--mail'],
dict(help='Upgrade mail server stack', action='store_true')),
(['--mailscanner'],
dict(help='Upgrade mail scanner stack', action='store_true')),
(['--nginx'],
dict(help='Upgrade Nginx stack', action='store_true')),
(['--php'],
dict(help='Upgrade PHP stack', action='store_true')),
(['--mysql'],
dict(help='Upgrade MySQL stack', action='store_true')),
(['--hhvm'],
dict(help='Upgrade HHVM stack', action='store_true')),
(['--postfix'],
dict(help='Upgrade Postfix stack', action='store_true')),
(['--php56'],
dict(help="Upgrade to PHP5.6 from PHP5.5",
action='store_true')),
(['--no-prompt'],
dict(help="Upgrade Packages without any prompt",
action='store_true')),
]
@expose(hide=True)
def upgrade_php56(self):
if EEVariables.ee_platform_distro == "Ubuntu":
if os.path.isfile("/etc/apt/sources.list.d/ondrej-php5-5_6-{0}."
"list".format(EEVariables.ee_platform_codename)):
Log.error(self, "Unable to find PHP 5.5")
else:
if not(os.path.isfile(EEVariables.ee_repo_file_path) and
EEFileUtils.grep(self, EEVariables.ee_repo_file_path,
"php55")):
Log.error(self, "Unable to find PHP 5.5")
Log.info(self, "During PHP 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 PHP package update")
if EEVariables.ee_platform_distro == "Ubuntu":
EERepo.remove(self, ppa="ppa:ondrej/php5")
EERepo.add(self, ppa=EEVariables.ee_php_repo)
else:
EEAptGet.remove(self, ["php5-xdebug"])
EEFileUtils.searchreplace(self, EEVariables.ee_repo_file_path,
"php55", "php56")
Log.info(self, "Updating apt-cache, please wait...")
EEAptGet.update(self)
Log.info(self, "Installing packages, please wait ...")
EEAptGet.install(self, EEVariables.ee_php)
if EEVariables.ee_platform_distro == "debian":
EEShellExec.cmd_exec(self, "pecl install xdebug")
with open("/etc/php5/mods-available/xdebug.ini",
encoding='utf-8', mode='a') as myfile:
myfile.write(";zend_extension=/usr/lib/php5/20131226/"
"xdebug.so\n")
EEFileUtils.create_symlink(self, ["/etc/php5/mods-available/"
"xdebug.ini", "/etc/php5/fpm/conf.d"
"/20-xedbug.ini"])
Log.info(self, "Successfully upgraded from PHP 5.5 to PHP 5.6")
@expose(hide=True)
def default(self):
# All package update
if ((not self.app.pargs.php56)):
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")
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.postfix) and (not self.app.pargs.hhvm) and
(not self.app.pargs.mailscanner) and (not self.app.pargs.all)):
self.app.pargs.web = True
if self.app.pargs.all:
self.app.pargs.web = True
self.app.pargs.mail = True
if self.app.pargs.web:
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.mysql = True
self.app.pargs.postfix = True
self.app.pargs.hhvm = True
if self.app.pargs.mail:
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.mysql = True
self.app.pargs.postfix = True
if EEAptGet.is_installed(self, 'dovecot-core'):
apt_packages = apt_packages + EEVariables.ee_mail
self.app.pargs.mailscanner = True
else:
Log.info(self, "Mail server is not installed")
if self.app.pargs.nginx:
if EEVariables.ee_platform_distro == 'debian':
check_nginx = 'nginx-extras'
else:
check_nginx = 'nginx-custom'
if EEAptGet.is_installed(self, check_nginx):
apt_packages = apt_packages + EEVariables.ee_nginx
else:
Log.info(self, "Nginx is not already installed")
if self.app.pargs.php:
if EEAptGet.is_installed(self, 'php5-fpm'):
apt_packages = apt_packages + EEVariables.ee_php
else:
Log.info(self, "PHP is not installed")
if self.app.pargs.hhvm:
if EEAptGet.is_installed(self, 'hhvm'):
apt_packages = apt_packages + EEVariables.ee_hhvm
else:
Log.info(self, "HHVM is not installed")
if self.app.pargs.mysql:
if EEAptGet.is_installed(self, 'mariadb-server'):
apt_packages = apt_packages + EEVariables.ee_mysql
else:
Log.info(self, "MySQL is not installed")
if self.app.pargs.postfix:
if EEAptGet.is_installed(self, 'postfix'):
apt_packages = apt_packages + EEVariables.ee_postfix
else:
Log.info(self, "Postfix is not installed")
if self.app.pargs.mailscanner:
if EEAptGet.is_installed(self, 'amavisd-new'):
apt_packages = (apt_packages + EEVariables.ee_mailscanner)
else:
Log.info(self, "MailScanner is not installed")
if len(apt_packages):
# apt-get update
EEAptGet.update(self)
# Update packages
Log.info(self, "Updating packages, please wait...")
EEAptGet.install(self, apt_packages)
Log.info(self, "Successfully updated packages")
# PHP 5.6 to 5.6
elif (self.app.pargs.php56):
self.upgrade_php56()
else:
self.app.args.print_help()

2
ee/cli/plugins/sync.py

@ -28,7 +28,7 @@ class EESyncController(CementBaseController):
1. reads database information from wp/ee-config.php 1. reads database information from wp/ee-config.php
2. updates records into ee database accordingly. 2. updates records into ee database accordingly.
""" """
Log.info(self, "Synchronizing ee database, please wait ....") Log.info(self, "Synchronizing ee database, please wait...")
sites = getAllsites(self) sites = getAllsites(self)
if not sites: if not sites:
pass pass

2
ee/cli/plugins/update.py

@ -28,7 +28,7 @@ class EEUpdateController(CementBaseController):
"/tmp/{0}".format(filename), "/tmp/{0}".format(filename),
"update script"]]) "update script"]])
try: try:
Log.info(self, "updating EasyEngine, please wait ...") Log.info(self, "updating EasyEngine, please wait...")
os.system("bash /tmp/{0}".format(filename)) os.system("bash /tmp/{0}".format(filename))
except OSError as e: except OSError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))

2
ee/cli/templates/siteinfo.mustache

@ -5,7 +5,7 @@ Nginx configuration {{type}} {{enable}}
{{#hhvm}}HHVM {{hhvm}}{{/hhvm}} {{#hhvm}}HHVM {{hhvm}}{{/hhvm}}
access_log {{accesslog}} access_log {{accesslog}}
error_log {{errorlog}} error_log {{errorlog}}
Webroot {{webroot}} {{#webroot}}Webroot {{webroot}}{{/webroot}}
{{#dbname}}DB_NAME {{dbname}}{{/dbname}} {{#dbname}}DB_NAME {{dbname}}{{/dbname}}
{{#dbname}}DB_USER {{dbuser}}{{/dbname}} {{#dbname}}DB_USER {{dbuser}}{{/dbname}}
{{#dbname}}DB_PASS {{dbpass}}{{/dbname}} {{#dbname}}DB_PASS {{dbpass}}{{/dbname}}

18
ee/cli/templates/virtualconf.mustache

@ -15,11 +15,24 @@ server {
access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}}; access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}};
error_log /var/log/nginx/{{site_name}}.error.log; error_log /var/log/nginx/{{site_name}}.error.log;
{{#proxy}}
add_header X-Proxy-Cache $upstream_cache_status;
location / {
proxy_pass http://{{host}}:{{port}};
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
{{/proxy}}
{{^proxy}}
{{^vma}}{{^rc}}root {{webroot}}/htdocs;{{/rc}}{{/vma}} {{^vma}}{{^rc}}root {{webroot}}/htdocs;{{/rc}}{{/vma}}
{{#vma}}root /var/www/22222/htdocs/vimbadmin/public;{{/vma}} {{#vma}}root /var/www/22222/htdocs/vimbadmin/public;{{/vma}}
{{#rc}}root /var/www/roundcubemail/htdocs/;{{/rc}} {{#rc}}root /var/www/roundcubemail/htdocs/;{{/rc}}
index {{^static}}index.php{{/static}} index.html index.htm; {{^proxy}}index {{^static}}index.php{{/static}} index.html index.htm;{{/proxy}}
{{#static}} {{#static}}
location / { location / {
@ -30,6 +43,7 @@ server {
{{^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}} {{/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}}{{/static}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}}
{{#wp}}include common/wpcommon.conf;{{/wp}} {{#wp}}include common/wpcommon.conf;{{/wp}}
include common/locations.conf; {{^proxy}}include common/locations.conf;{{/proxy}}
{{^vma}}{{^rc}}include {{webroot}}/conf/nginx/*.conf;{{/rc}}{{/vma}} {{^vma}}{{^rc}}include {{webroot}}/conf/nginx/*.conf;{{/rc}}{{/vma}}
{{/proxy}}
} }

20
ee/core/apt_repo.py

@ -1,6 +1,7 @@
"""EasyEngine packages repository operations""" """EasyEngine packages repository operations"""
from ee.core.shellexec import EEShellExec from ee.core.shellexec import EEShellExec
from ee.core.variables import EEVariables from ee.core.variables import EEVariables
from ee.core.logging import Log
import os import os
@ -54,16 +55,31 @@ class EERepo():
"'{ppa_name}'" "'{ppa_name}'"
.format(ppa_name=ppa)) .format(ppa_name=ppa))
def remove(self, ppa=None): def remove(self, ppa=None, repo_url=None):
""" """
This function used to remove ppa's This function used to remove ppa's
If ppa is provided adds repo file to If ppa is provided adds repo file to
/etc/apt/sources.list.d/ /etc/apt/sources.list.d/
command. command.
""" """
if ppa:
EEShellExec.cmd_exec(self, "add-apt-repository -y " EEShellExec.cmd_exec(self, "add-apt-repository -y "
"--remove '{ppa_name}'" "--remove '{ppa_name}'"
.format(ppa_name=repo_url)) .format(ppa_name=ppa))
elif repo_url:
repo_file_path = ("/etc/apt/sources.list.d/"
+ EEVariables().ee_repo_file)
try:
repofile = open(repo_file_path, "w+")
repofile.write(repofile.read().replace(repo_url, ""))
repofile.close()
except IOError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "File I/O error.")
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to remove repo")
def add_key(self, keyids, keyserver=None): def add_key(self, keyids, keyserver=None):
""" """

62
ee/core/aptget.py

@ -32,32 +32,60 @@ class EEAptGet():
Log.error(self, "Error while installing packages, " Log.error(self, "Error while installing packages, "
"apt-get exited with error") "apt-get exited with error")
def dist_upgrade(): def check_upgrade(self):
""" """
Similar to `apt-get upgrade` Similar to `apt-get upgrade`
""" """
try: try:
apt_cache = apt.cache.Cache() check_update = subprocess.Popen(['apt-get upgrade -s | grep '
apt_cache.update() '\"^Inst\" | wc -l'],
apt_cache.open(None) stdout=subprocess.PIPE,
apt_cache.upgrade(True) shell=True).communicate()[0]
success = (apt_cache.commit( if check_update == b'0\n':
apt.progress.text.AcquireProgress(), Log.error(self, "No package updates available")
apt.progress.base.InstallProgress())) Log.info(self, "Following package updates are available:")
# apt_cache.close() subprocess.Popen("apt-get -s dist-upgrade | grep \"^Inst\"",
return success shell=True, executable="/bin/bash",
except AttributeError as e: stdout=sys.stdout).communicate()
Log.error(self, 'AttributeError: ' + str(e))
except FetchFailedException as e: except Exception as e:
Log.debug(self, 'SystemError: ' + str(e)) Log.error(self, "Unable to check for packages upgrades")
Log.error(self, 'Unable to Fetch update')
def dist_upgrade(self):
"""
Similar to `apt-get upgrade`
"""
try:
with open('/var/log/ee/ee.log', 'a') as f:
proc = subprocess.Popen("DEBIAN_FRONTEND=noninteractive "
"apt-get dist-upgrade -o "
"Dpkg::Options::=\"--force-confdef\""
" -o "
"Dpkg::Options::=\"--force-confold\""
" -y ",
shell=True, stdin=None,
stdout=f, stderr=f,
executable="/bin/bash")
proc.wait()
if proc.returncode == 0:
return True
else:
Log.error(self, "Unable to run apt-get dist_upgrade")
except Exception as e:
Log.error(self, "Error while installing packages, "
"apt-get exited with error")
def install(self, packages): def install(self, packages):
all_packages = ' '.join(packages) all_packages = ' '.join(packages)
try: try:
with open('/var/log/ee/ee.log', 'a') as f: with open('/var/log/ee/ee.log', 'a') as f:
proc = subprocess.Popen("apt-get install -o Dpkg::Options::=--" proc = subprocess.Popen("DEBIAN_FRONTEND=noninteractive "
"force-confold -y {0}" "apt-get install -o "
"Dpkg::Options::=\"--force-confdef\""
" -o "
"Dpkg::Options::=\"--force-confold\""
" -y {0}"
.format(all_packages), shell=True, .format(all_packages), shell=True,
stdin=None, stdout=f, stderr=f, stdin=None, stdout=f, stderr=f,
executable="/bin/bash") executable="/bin/bash")

24
ee/core/variables.py

@ -12,10 +12,10 @@ class EEVariables():
"""Intialization of core variables""" """Intialization of core variables"""
# EasyEngine version # EasyEngine version
ee_version = "3.1.1" ee_version = "3.1.2"
# EasyEngine packages versions # EasyEngine packages versions
ee_wp_cli = "0.18.0" ee_wp_cli = "0.19.0"
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"
@ -28,6 +28,15 @@ class EEVariables():
ee_platform_version = platform.linux_distribution()[1] ee_platform_version = platform.linux_distribution()[1]
ee_platform_codename = os.popen("lsb_release -sc | tr -d \'\\n\'").read() ee_platform_codename = os.popen("lsb_release -sc | tr -d \'\\n\'").read()
# Get timezone of system
if os.path.isfile('/etc/timezone'):
with open("/etc/timezone", "r") as tzfile:
ee_timezone = tzfile.read().replace('\n', '')
if ee_timezone == "Etc/UTC":
ee_timezone = "UTC"
else:
ee_timezone = "UTC"
# Get FQDN of system # Get FQDN of system
ee_fqdn = socket.getfqdn() ee_fqdn = socket.getfqdn()
@ -77,14 +86,17 @@ class EEVariables():
# PHP repo and packages # PHP repo and packages
if ee_platform_distro == 'Ubuntu': if ee_platform_distro == 'Ubuntu':
ee_php_repo = "ppa:ondrej/php5" ee_php_repo = "ppa:ondrej/php5-5.6"
elif ee_platform_codename == 'wheezy': elif ee_platform_codename == 'wheezy':
ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php55 all" ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php56 all"
.format(codename=ee_platform_codename)) .format(codename=ee_platform_codename))
ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap", ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap",
"php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline", "php5-mcrypt", "php5-common", "php5-readline",
"php5-mysql", "php5-cli", "php5-memcache", "php5-imagick", "php5-mysql", "php5-cli", "php5-memcache", "php5-imagick",
"memcached", "graphviz"] "memcached", "graphviz", "php-pear", "php5-dev"]
if ee_platform_distro == 'Ubuntu':
ee_php = ee_php + ["php5-xdebug"]
# MySQL repo and packages # MySQL repo and packages
if ee_platform_distro == 'Ubuntu': if ee_platform_distro == 'Ubuntu':

14
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.1" readonly ee_version_new="3.1.2"
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}')
@ -301,9 +301,9 @@ function ee_update_latest()
fi fi
# Fix HHVM autostart on reboot # Fix HHVM autostart on reboot
dpkg -l | grep hhvm &>> /dev/null dpkg --get-selections | grep -v deinstall | grep hhvm &>> /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo update-rc.d hhvm defaults &>> /dev/null update-rc.d hhvm defaults &>> /dev/null
fi fi
} }
@ -372,3 +372,11 @@ else
fi fi
fi fi
ee sync | tee -ai $EE_INSTALL_LOG ee sync | tee -ai $EE_INSTALL_LOG
echo
ee_lib_echo "For EasyEngine (ee) auto completion, run the following command"
echo
ee_lib_echo_info "source /etc/bash_completion.d/ee_auto.rc"
echo
ee_lib_echo "EasyEngine (ee) installed successfully"
ee_lib_echo "EasyEngine (ee) help: http://docs.rtcamp.com/easyengine/"

12
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.1', version='3.1.2',
description=long_description, description=long_description,
long_description=long_description, long_description=long_description,
classifiers=[], classifiers=[],
@ -97,13 +97,3 @@ setup(name='ee',
""", """,
namespace_packages=[], namespace_packages=[],
) )
print("""\033[94m
For EasyEngine (ee) auto completion, run the following command
\033[92m
source /etc/bash_completion.d/ee_auto.rc
\033[94m
EasyEngine (ee) installed successfully
EasyEngine (ee) help: http://docs.rtcamp.com/easyengine/
\033[0m
""")

Loading…
Cancel
Save