Browse Source

Merge branch 'python'

bugfixes
gau1991 10 years ago
parent
commit
dba28ec2ed
  1. 1
      .travis.yml
  2. 22
      ee/cli/main.py
  3. 51
      ee/cli/plugins/debug.py
  4. 65
      ee/cli/plugins/site.py
  5. 12
      ee/cli/plugins/stack.py
  6. 75
      ee/cli/plugins/stack_services.py
  7. 4
      install

1
.travis.yml

@ -21,6 +21,7 @@ before_script:
- sudo apt-get update - sudo apt-get update
script: script:
- unset LANG
- sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.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

22
ee/cli/main.py

@ -13,8 +13,11 @@ else:
from cement.core import foundation from cement.core import foundation
from cement.utils.misc import init_defaults from cement.utils.misc import init_defaults
from cement.core.exc import FrameworkError, CaughtSignal from cement.core.exc import FrameworkError, CaughtSignal
from cement.utils import fs
from cement.ext.ext_mustache import MustacheOutputHandler
from ee.core import exc from ee.core import exc
# Application default. Should update config/ee.conf to reflect any # Application default. Should update config/ee.conf to reflect any
# changes, or additions here. # changes, or additions here.
defaults = init_defaults('ee') defaults = init_defaults('ee')
@ -29,6 +32,23 @@ defaults['ee']['plugin_dir'] = '/var/lib/ee/plugins'
defaults['ee']['template_dir'] = '/var/lib/ee/templates' defaults['ee']['template_dir'] = '/var/lib/ee/templates'
# Based on https://github.com/datafolklabs/cement/issues/295
# To avoid encoding releated error,we defined our custom output handler
# I hope we will remove this when we upgarde to Cement 2.6 (Not released yet)
class EEOutputHandler(MustacheOutputHandler):
class Meta:
label = 'ee_output_handler'
def _load_template_from_file(self, path):
for templ_dir in self.app._meta.template_dirs:
full_path = fs.abspath(os.path.join(templ_dir, path))
if os.path.exists(full_path):
self.app.log.debug('loading template file %s' % full_path)
return open(full_path, encoding='utf-8', mode='r').read()
else:
continue
class EEApp(foundation.CementApp): class EEApp(foundation.CementApp):
class Meta: class Meta:
label = 'ee' label = 'ee'
@ -50,7 +70,7 @@ class EEApp(foundation.CementApp):
extensions = ['mustache'] extensions = ['mustache']
# default output handler # default output handler
output_handler = 'mustache' output_handler = EEOutputHandler
debug = TOGGLE_DEBUG debug = TOGGLE_DEBUG

51
ee/cli/plugins/debug.py

@ -103,7 +103,7 @@ class EEDebugController(CementBaseController):
self.trigger_nginx = True self.trigger_nginx = True
else: else:
Log.info(self, "Debug for site allready enabled") Log.info(self, "Nginx debug for site already enabled")
self.msg = self.msg + ['{0}{1}/logs/error.log' self.msg = self.msg + ['{0}{1}/logs/error.log'
.format(EEVariables.ee_webroot, .format(EEVariables.ee_webroot,
@ -129,7 +129,7 @@ class EEDebugController(CementBaseController):
else: else:
Log.info(self, "Debug for site allready disabled") Log.info(self, "Nginx debug for site already disabled")
else: else:
Log.info(self, "{0} domain not valid" Log.info(self, "{0} domain not valid"
.format(self.app.pargs.site_name)) .format(self.app.pargs.site_name))
@ -154,7 +154,7 @@ class EEDebugController(CementBaseController):
self.trigger_php = True self.trigger_php = True
self.trigger_nginx = True self.trigger_nginx = True
else: else:
Log.info(self, "PHP debug is allready enabled") Log.info(self, "PHP debug is already enabled")
self.msg = self.msg + ['/var/log/php5/slow.log'] self.msg = self.msg + ['/var/log/php5/slow.log']
@ -174,7 +174,7 @@ class EEDebugController(CementBaseController):
self.trigger_php = True self.trigger_php = True
self.trigger_nginx = True self.trigger_nginx = True
else: else:
Log.info(self, "PHP debug is allready disabled") Log.info(self, "PHP debug is already disabled")
@expose(hide=True) @expose(hide=True)
def debug_fpm(self): def debug_fpm(self):
@ -249,7 +249,7 @@ class EEDebugController(CementBaseController):
"n#EasyEngine end MySQL slow log\\\";" "n#EasyEngine end MySQL slow log\\\";"
" }} | crontab -\"".format(cron_time)) " }} | crontab -\"".format(cron_time))
else: else:
Log.info(self, "MySQL slow log is allready enabled") Log.info(self, "MySQL slow log is already enabled")
self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] self.msg = self.msg + ['/var/log/mysql/mysql-slow.log']
@ -273,7 +273,7 @@ class EEDebugController(CementBaseController):
def debug_wp(self): def debug_wp(self):
"""Start/Stop WordPress debug""" """Start/Stop WordPress debug"""
if self.start and self.app.pargs.site_name: if self.start and self.app.pargs.site_name:
wp_config = ("{0}{1}/wp-config.php" wp_config = ("{0}/{1}/wp-config.php"
.format(EEVariables.ee_webroot, .format(EEVariables.ee_webroot,
self.app.pargs.site_name)) self.app.pargs.site_name))
webroot = "{0}{1}".format(EEVariables.ee_webroot, webroot = "{0}{1}".format(EEVariables.ee_webroot,
@ -301,8 +301,6 @@ class EEDebugController(CementBaseController):
"wp-content/plugins" "wp-content/plugins"
.format(webroot, .format(webroot,
EEVariables.ee_php_user)) EEVariables.ee_php_user))
else:
Log.info(self, "WordPress debug log already enabled")
self.msg = self.msg + ['{0}{1}/htdocs/wp-content' self.msg = self.msg + ['{0}{1}/htdocs/wp-content'
'/debug.log' '/debug.log'
@ -337,9 +335,6 @@ class EEDebugController(CementBaseController):
"true);/d\" {0}".format(wp_config)) "true);/d\" {0}".format(wp_config))
else: else:
Log.info(self, "WordPress debug all already disabled") Log.info(self, "WordPress debug all already disabled")
else:
Log.error(self, "{0} domain not valid"
.format(self.app.pargs.site_name))
else: else:
Log.error(self, "Missing argument site name") Log.error(self, "Missing argument site name")
@ -383,7 +378,7 @@ class EEDebugController(CementBaseController):
.format(config_path)) .format(config_path))
self.trigger_nginx = True self.trigger_nginx = True
else: else:
Log.info(self, "Nginx rewrite logs for {0} allready setup" Log.info(self, "Nginx rewrite logs for {0} already setup"
.format(self.app.pargs.site_name)) .format(self.app.pargs.site_name))
if ('{0}{1}/logs/error.log'.format(EEVariables.ee_webroot, if ('{0}{1}/logs/error.log'.format(EEVariables.ee_webroot,
@ -405,7 +400,7 @@ class EEDebugController(CementBaseController):
.format(config_path)) .format(config_path))
self.trigger_nginx = True self.trigger_nginx = True
else: else:
Log.info(self, "Nginx rewrite logs for {0} allready " Log.info(self, "Nginx rewrite logs for {0} already "
" disabled".format(self.app.pargs.site_name)) " disabled".format(self.app.pargs.site_name))
@expose(hide=True) @expose(hide=True)
@ -419,7 +414,12 @@ class EEDebugController(CementBaseController):
if self.app.pargs.fpm: if self.app.pargs.fpm:
self.debug_fpm() self.debug_fpm()
if self.app.pargs.mysql: if self.app.pargs.mysql:
self.debug_mysql() # MySQL debug will not work for remote MySQL
if EEVariables.ee_mysql_host is "localhost":
self.debug_mysql()
else:
Log.warn(self, "Remote MySQL found, EasyEngine will not "
"enable remote debug")
if self.app.pargs.wp: if self.app.pargs.wp:
self.debug_wp() self.debug_wp()
if self.app.pargs.rewrite: if self.app.pargs.rewrite:
@ -450,19 +450,19 @@ class EEDebugController(CementBaseController):
and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql)
and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite)
and (not self.app.pargs.site_name)): and (not self.app.pargs.site_name)):
self.debug_nginx() self.app.pargs.nginx = True
self.debug_php() self.app.pargs.php = True
self.debug_fpm() self.app.pargs.fpm = True
self.debug_mysql() self.app.pargs.mysql = True
self.debug_rewrite() self.app.pargs.rewrite = True
if ((not self.app.pargs.nginx) and (not self.app.pargs.php) if ((not self.app.pargs.nginx) and (not self.app.pargs.php)
and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql)
and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite)
and self.app.pargs.site_name): and self.app.pargs.site_name):
self.debug_nginx() self.app.pargs.nginx = True
self.debug_wp() self.app.pargs.wp = True
self.debug_rewrite() self.app.pargs.rewrite = True
if self.app.pargs.nginx: if self.app.pargs.nginx:
self.debug_nginx() self.debug_nginx()
@ -471,7 +471,12 @@ class EEDebugController(CementBaseController):
if self.app.pargs.fpm: if self.app.pargs.fpm:
self.debug_fpm() self.debug_fpm()
if self.app.pargs.mysql: if self.app.pargs.mysql:
self.debug_mysql() # MySQL debug will not work for remote MySQL
if EEVariables.ee_mysql_host is "localhost":
self.debug_mysql()
else:
Log.warn(self, "Remote MySQL found, EasyEngine will not "
"enable remote debug")
if self.app.pargs.wp: if self.app.pargs.wp:
self.debug_wp() self.debug_wp()
if self.app.pargs.rewrite: if self.app.pargs.rewrite:

65
ee/cli/plugins/site.py

@ -29,7 +29,7 @@ class EESiteController(CementBaseController):
description = ('Performs website specific operations') description = ('Performs website specific operations')
arguments = [ arguments = [
(['site_name'], (['site_name'],
dict(help='Website name')), dict(help='Website name', nargs='?')),
] ]
@expose(hide=True) @expose(hide=True)
@ -38,6 +38,11 @@ class EESiteController(CementBaseController):
@expose(help="Enable site example.com") @expose(help="Enable site example.com")
def enable(self): def enable(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
Log.info(self, "Enable domain {0:10} \t".format(ee_domain), end='') Log.info(self, "Enable domain {0:10} \t".format(ee_domain), end='')
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -58,6 +63,11 @@ class EESiteController(CementBaseController):
@expose(help="Disable site example.com") @expose(help="Disable site example.com")
def disable(self): def disable(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
Log.info(self, "Disable domain {0:10} \t".format(ee_domain), end='') Log.info(self, "Disable domain {0:10} \t".format(ee_domain), end='')
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -81,6 +91,11 @@ class EESiteController(CementBaseController):
@expose(help="Get example.com information") @expose(help="Get example.com information")
def info(self): def info(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_db_name = '' ee_db_name = ''
ee_db_user = '' ee_db_user = ''
@ -135,6 +150,11 @@ class EESiteController(CementBaseController):
@expose(help="Edit Nginx configuration of example.com") @expose(help="Edit Nginx configuration of example.com")
def edit(self): def edit(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
.format(ee_domain)): .format(ee_domain)):
@ -151,6 +171,11 @@ class EESiteController(CementBaseController):
@expose(help="Display Nginx configuration of example.com") @expose(help="Display Nginx configuration of example.com")
def show(self): def show(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
# TODO Write code for ee site edit command here # TODO Write code for ee site edit command here
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -167,7 +192,11 @@ class EESiteController(CementBaseController):
@expose(help="Change directory to site webroot") @expose(help="Change directory to site webroot")
def cd(self): def cd(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
.format(ee_domain)): .format(ee_domain)):
@ -189,7 +218,8 @@ class EESiteCreateController(CementBaseController):
'required files as options are provided') 'required files as options are provided')
arguments = [ arguments = [
(['site_name'], (['site_name'],
dict(help='domain name for the site to be created.')), dict(help='domain name for the site to be created.',
nargs='?')),
(['--html'], (['--html'],
dict(help="create html site", action='store_true')), dict(help="create html site", action='store_true')),
(['--php'], (['--php'],
@ -220,6 +250,18 @@ class EESiteCreateController(CementBaseController):
def default(self): def default(self):
# self.app.render((data), 'default.mustache') # self.app.render((data), 'default.mustache')
# Check domain name validation # Check domain name validation
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
if not (self.app.pargs.html or self.app.pargs.php or
self.app.pargs.mysql or self.app.pargs.wp or
self.app.pargs.w3tc or self.app.pargs.wpfc or
self.app.pargs.wpsc or self.app.pargs.wpsubdir or
self.app.pargs.wpsubdomain):
self.app.pargs.html = True
data = '' data = ''
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_site_webroot = EEVariables.ee_webroot + ee_domain ee_site_webroot = EEVariables.ee_webroot + ee_domain
@ -494,7 +536,8 @@ class EESiteUpdateController(CementBaseController):
'another as per the options are provided') 'another as per the options are provided')
arguments = [ arguments = [
(['site_name'], (['site_name'],
dict(help='domain name for the site to be updated')), dict(help='domain name for the site to be updated',
nargs='?')),
(['--password'], (['--password'],
dict(help="update to password for wordpress site user", dict(help="update to password for wordpress site user",
action='store_true')), action='store_true')),
@ -521,6 +564,11 @@ class EESiteUpdateController(CementBaseController):
@expose(help="Update site type or cache") @expose(help="Update site type or cache")
def default(self): def default(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
data = '' data = ''
(ee_domain, (ee_domain,
ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name)
@ -947,7 +995,7 @@ class EESiteDeleteController(CementBaseController):
description = 'delete an existing website' description = 'delete an existing website'
arguments = [ arguments = [
(['site_name'], (['site_name'],
dict(help='domain name to be deleted')), dict(help='domain name to be deleted', nargs='?')),
(['--no-prompt'], (['--no-prompt'],
dict(help="doesnt ask permission for delete", dict(help="doesnt ask permission for delete",
action='store_true')), action='store_true')),
@ -962,12 +1010,15 @@ class EESiteDeleteController(CementBaseController):
@expose(help="Delete website configuration and files") @expose(help="Delete website configuration and files")
@expose(hide=True) @expose(hide=True)
def default(self): def default(self):
# TODO Write code for ee site update here if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_db_name = '' ee_db_name = ''
ee_prompt = '' ee_prompt = ''
ee_nginx_prompt = '' ee_nginx_prompt = ''
if ((not self.app.pargs.db) and (not self.app.pargs.files) and if ((not self.app.pargs.db) and (not self.app.pargs.files) and
(not self.app.pargs.all)): (not self.app.pargs.all)):
self.app.pargs.all = True self.app.pargs.all = True

12
ee/cli/plugins/stack.py

@ -442,6 +442,7 @@ class EEStackController(CementBaseController):
config = configparser.ConfigParser() config = configparser.ConfigParser()
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'
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 "
@ -1122,8 +1123,9 @@ class EEStackController(CementBaseController):
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.phpmyadmin) and
(not self.app.pargs.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)): (not self.app.pargs.mailscanner) and (not self.app.pargs.all)):
self.app.pargs.web = True self.app.pargs.web = True
self.app.pargs.admin = True
if self.app.pargs.all: if self.app.pargs.all:
self.app.pargs.web = True self.app.pargs.web = True
@ -1244,7 +1246,7 @@ class EEStackController(CementBaseController):
else: else:
Log.error(self, "Failed to find installed Dovecot") Log.error(self, "Failed to find installed Dovecot")
else: else:
Log.error(self, "Mail scanner allready installed") Log.error(self, "Mail scanner already installed")
if self.app.pargs.utils: if self.app.pargs.utils:
Log.debug(self, "Setting packages variable for utils") Log.debug(self, "Setting packages variable for utils")
@ -1329,8 +1331,9 @@ class EEStackController(CementBaseController):
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.phpmyadmin) and
(not self.app.pargs.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)): (not self.app.pargs.mailscanner) and (not self.app.pargs.all)):
self.app.pargs.web = True self.app.pargs.web = True
self.app.pargs.admin = True
if self.app.pargs.all: if self.app.pargs.all:
self.app.pargs.web = True self.app.pargs.web = True
@ -1423,8 +1426,9 @@ class EEStackController(CementBaseController):
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.phpmyadmin) and
(not self.app.pargs.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)): (not self.app.pargs.mailscanner) and (not self.app.pargs.all)):
self.app.pargs.web = True self.app.pargs.web = True
self.app.pargs.admin = True
if self.app.pargs.all: if self.app.pargs.all:
self.app.pargs.web = True self.app.pargs.web = True

75
ee/cli/plugins/stack_services.py

@ -2,6 +2,7 @@ from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook from cement.core import handler, hook
from ee.core.services import EEService from ee.core.services import EEService
from ee.core.logging import Log from ee.core.logging import Log
from ee.core.variables import EEVariables
class EEStackStatusController(CementBaseController): class EEStackStatusController(CementBaseController):
@ -28,8 +29,12 @@ class EEStackStatusController(CementBaseController):
Log.debug(self, "php5-fpm service start") Log.debug(self, "php5-fpm service start")
services = services + ['php5-fpm'] services = services + ['php5-fpm']
if self.app.pargs.mysql: if self.app.pargs.mysql:
Log.debug(self, "mysql service start") if EEVariables.ee_mysql_host is "localhost":
services = services + ['mysql'] Log.debug(self, "mysql service start")
services = services + ['mysql']
else:
Log.warn(self, "Remote MySQL found,"
"unable to start MySQL service")
if self.app.pargs.postfix: if self.app.pargs.postfix:
Log.debug(self, "postfix service start") Log.debug(self, "postfix service start")
services = services + ['postfix'] services = services + ['postfix']
@ -39,9 +44,13 @@ class EEStackStatusController(CementBaseController):
if self.app.pargs.dovecot: if self.app.pargs.dovecot:
Log.debug(self, "dovecot service start") Log.debug(self, "dovecot service start")
services = services + ['dovecot'] services = services + ['dovecot']
if not services: if not services and EEVariables.ee_mysql_host is "localhost":
Log.debug(self, "nginx,php5-fpm,mysql,postfix services start")
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
Log.debug(self, "nginx,php5-fpm,mysql,postfix services start")
elif not services:
services = services + ['nginx', 'php5-fpm', 'postfix']
Log.debug(self, "nginx,php5-fpm,postfix services start")
for service in services: for service in services:
EEService.start_service(self, service) EEService.start_service(self, service)
@ -56,8 +65,12 @@ class EEStackStatusController(CementBaseController):
Log.debug(self, "php5-fpm service stop") Log.debug(self, "php5-fpm service stop")
services = services + ['php5-fpm'] services = services + ['php5-fpm']
if self.app.pargs.mysql: if self.app.pargs.mysql:
Log.debug(self, "mysql service stop") if EEVariables.ee_mysql_host is "localhost":
services = services + ['mysql'] Log.debug(self, "mysql service stop")
services = services + ['mysql']
else:
Log.warn(self, "Remote MySQL found, "
"unable to stop MySQL service")
if self.app.pargs.postfix: if self.app.pargs.postfix:
Log.debug(self, "postfix service stop") Log.debug(self, "postfix service stop")
services = services + ['postfix'] services = services + ['postfix']
@ -67,9 +80,12 @@ class EEStackStatusController(CementBaseController):
if self.app.pargs.dovecot: if self.app.pargs.dovecot:
Log.debug(self, "dovecot service stop") Log.debug(self, "dovecot service stop")
services = services + ['dovecot'] services = services + ['dovecot']
if not services: if not services and EEVariables.ee_mysql_host is "localhost":
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
Log.debug(self, "nginx,php5-fpm,mysql,postfix services stop") Log.debug(self, "nginx,php5-fpm,mysql,postfix services stop")
elif not services:
services = services + ['nginx', 'php5-fpm', 'postfix']
Log.debug(self, "nginx,php5-fpm,postfix services stop")
for service in services: for service in services:
EEService.stop_service(self, service) EEService.stop_service(self, service)
@ -84,8 +100,12 @@ class EEStackStatusController(CementBaseController):
Log.debug(self, "php5-fpm service restart") Log.debug(self, "php5-fpm service restart")
services = services + ['php5-fpm'] services = services + ['php5-fpm']
if self.app.pargs.mysql: if self.app.pargs.mysql:
Log.debug(self, "mysql service restart") if EEVariables.ee_mysql_host is "localhost":
services = services + ['mysql'] Log.debug(self, "mysql service restart")
services = services + ['mysql']
else:
Log.warn(self, "Remote MySQL found, "
"unable to restart MySQL service")
if self.app.pargs.postfix: if self.app.pargs.postfix:
Log.debug(self, "postfix service restart") Log.debug(self, "postfix service restart")
services = services + ['postfix'] services = services + ['postfix']
@ -95,10 +115,13 @@ class EEStackStatusController(CementBaseController):
if self.app.pargs.dovecot: if self.app.pargs.dovecot:
Log.debug(self, "dovecot service restart") Log.debug(self, "dovecot service restart")
services = services + ['dovecot'] services = services + ['dovecot']
if not services: if not services and EEVariables.ee_mysql_host is "localhost":
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services:
Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart") Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart")
elif not services:
services = services + ['nginx', 'php5-fpm', 'postfix']
Log.debug(self, "nginx,php5-fpm,postfix services restart")
for service in services:
EEService.restart_service(self, service) EEService.restart_service(self, service)
@expose(help="Get stack status") @expose(help="Get stack status")
@ -112,8 +135,12 @@ class EEStackStatusController(CementBaseController):
Log.debug(self, "php5-fpm service status") Log.debug(self, "php5-fpm service status")
services = services + ['php5-fpm'] services = services + ['php5-fpm']
if self.app.pargs.mysql: if self.app.pargs.mysql:
Log.debug(self, "mysql service status") if EEVariables.ee_mysql_host is "localhost":
services = services + ['mysql'] Log.debug(self, "mysql service status")
services = services + ['mysql']
else:
Log.warn(self, "Remote MySQL found, "
"unable to get MySQL service status")
if self.app.pargs.postfix: if self.app.pargs.postfix:
services = services + ['postfix'] services = services + ['postfix']
Log.debug(self, "postfix service status") Log.debug(self, "postfix service status")
@ -123,9 +150,12 @@ class EEStackStatusController(CementBaseController):
if self.app.pargs.dovecot: if self.app.pargs.dovecot:
Log.debug(self, "dovecot service status") Log.debug(self, "dovecot service status")
services = services + ['dovecot'] services = services + ['dovecot']
if not services: if not services and EEVariables.ee_mysql_host is "localhost":
Log.debug(self, "nginx,php5-fpm,mysql,postfix services status")
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
Log.debug(self, "nginx,php5-fpm,mysql,postfix services status")
elif not services:
services = services + ['nginx', 'php5-fpm', 'postfix']
Log.debug(self, "nginx,php5-fpm,postfix services status")
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"))
@ -141,8 +171,12 @@ class EEStackStatusController(CementBaseController):
Log.debug(self, "php5-fpm service reload") Log.debug(self, "php5-fpm service reload")
services = services + ['php5-fpm'] services = services + ['php5-fpm']
if self.app.pargs.mysql: if self.app.pargs.mysql:
Log.debug(self, "mysql service reload") if EEVariables.ee_mysql_host is "localhost":
services = services + ['mysql'] Log.debug(self, "mysql service reload")
services = services + ['mysql']
else:
Log.warn(self, "Remote MySQL found, "
"unable to remote MySQL service")
if self.app.pargs.postfix: if self.app.pargs.postfix:
Log.debug(self, "postfix service reload") Log.debug(self, "postfix service reload")
services = services + ['postfix'] services = services + ['postfix']
@ -152,8 +186,11 @@ class EEStackStatusController(CementBaseController):
if self.app.pargs.dovecot: if self.app.pargs.dovecot:
Log.debug(self, "dovecot service reload") Log.debug(self, "dovecot service reload")
services = services + ['dovecot'] services = services + ['dovecot']
if not services: if not services and EEVariables.ee_mysql_host is "localhost":
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services:
Log.debug(self, "nginx,php5-fpm,mysql,postfix services reload") Log.debug(self, "nginx,php5-fpm,mysql,postfix services reload")
elif not services:
services = services + ['nginx', 'php5-fpm', 'postfix']
Log.debug(self, "nginx,php5-fpm,postfix services reload")
for service in services:
EEService.reload_service(self, service) EEService.reload_service(self, service)

4
install

@ -175,7 +175,7 @@ function update_to_ee3()
sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $new_ee_version\";/" /etc/nginx/nginx.conf &>> /dev/null sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $new_ee_version\";/" /etc/nginx/nginx.conf &>> /dev/null
fi fi
grant_host=$(grep grant-host /etc/easyengine/ee.conf | awk '{ print $3 }') grant_host=$(grep grant-host /etc/easyengine/ee.conf | awk '{ print $3 }' | head -1 )
db_name=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }') db_name=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }')
db_user=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }') db_user=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }')
wp_prefix=$(grep prefix /etc/easyengine/ee.conf | awk '{ print $3 }') wp_prefix=$(grep prefix /etc/easyengine/ee.conf | awk '{ print $3 }')
@ -318,7 +318,7 @@ else
service nginx reload &>> /dev/null service nginx reload &>> /dev/null
fi fi
else else
ee_lib_echo_fail "You allready have EasyEngine $new_ee_version" | tee -ai $EE_INSTALL_LOG ee_lib_echo_fail "You already have EasyEngine $new_ee_version" | tee -ai $EE_INSTALL_LOG
exit 1 exit 1
fi fi
fi fi

Loading…
Cancel
Save