diff --git a/.travis.yml b/.travis.yml index 1ed05379..2c09927d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ before_script: - sudo apt-get update script: + - unset LANG - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig - sudo echo "Travis Banch = $TRAVIS_BRANCH" - sudo apt-get install -y --force-yes git python3-setuptools python3-dev python3-apt diff --git a/ee/cli/main.py b/ee/cli/main.py index 98de372f..ef828f51 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -13,8 +13,11 @@ else: from cement.core import foundation from cement.utils.misc import init_defaults from cement.core.exc import FrameworkError, CaughtSignal +from cement.utils import fs +from cement.ext.ext_mustache import MustacheOutputHandler from ee.core import exc + # Application default. Should update config/ee.conf to reflect any # changes, or additions here. defaults = init_defaults('ee') @@ -29,6 +32,23 @@ defaults['ee']['plugin_dir'] = '/var/lib/ee/plugins' 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 Meta: label = 'ee' @@ -50,7 +70,7 @@ class EEApp(foundation.CementApp): extensions = ['mustache'] # default output handler - output_handler = 'mustache' + output_handler = EEOutputHandler debug = TOGGLE_DEBUG diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 29ec309b..a99b1a2b 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -103,7 +103,7 @@ class EEDebugController(CementBaseController): self.trigger_nginx = True else: - Log.info(self, "Nginx debug for site allready enabled") + Log.info(self, "Nginx debug for site already enabled") self.msg = self.msg + ['{0}{1}/logs/error.log' .format(EEVariables.ee_webroot, @@ -129,7 +129,7 @@ class EEDebugController(CementBaseController): else: - Log.info(self, "Nginx debug for site allready disabled") + Log.info(self, "Nginx debug for site already disabled") else: Log.info(self, "{0} domain not valid" .format(self.app.pargs.site_name)) @@ -154,7 +154,7 @@ class EEDebugController(CementBaseController): self.trigger_php = True self.trigger_nginx = True 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'] @@ -174,7 +174,7 @@ class EEDebugController(CementBaseController): self.trigger_php = True self.trigger_nginx = True else: - Log.info(self, "PHP debug is allready disabled") + Log.info(self, "PHP debug is already disabled") @expose(hide=True) def debug_fpm(self): @@ -249,7 +249,7 @@ class EEDebugController(CementBaseController): "n#EasyEngine end MySQL slow log\\\";" " }} | crontab -\"".format(cron_time)) 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'] @@ -378,7 +378,7 @@ class EEDebugController(CementBaseController): .format(config_path)) self.trigger_nginx = True 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)) if ('{0}{1}/logs/error.log'.format(EEVariables.ee_webroot, @@ -400,7 +400,7 @@ class EEDebugController(CementBaseController): .format(config_path)) self.trigger_nginx = True 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)) @expose(hide=True) @@ -414,7 +414,12 @@ class EEDebugController(CementBaseController): if self.app.pargs.fpm: self.debug_fpm() 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: self.debug_wp() if self.app.pargs.rewrite: @@ -445,19 +450,19 @@ class EEDebugController(CementBaseController): 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.site_name)): - self.debug_nginx() - self.debug_php() - self.debug_fpm() - self.debug_mysql() - self.debug_rewrite() + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.fpm = True + self.app.pargs.mysql = True + self.app.pargs.rewrite = True 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.wp) and (not self.app.pargs.rewrite) and self.app.pargs.site_name): - self.debug_nginx() - self.debug_wp() - self.debug_rewrite() + self.app.pargs.nginx = True + self.app.pargs.wp = True + self.app.pargs.rewrite = True if self.app.pargs.nginx: self.debug_nginx() @@ -466,7 +471,12 @@ class EEDebugController(CementBaseController): if self.app.pargs.fpm: self.debug_fpm() 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: self.debug_wp() if self.app.pargs.rewrite: diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 14c0382c..01bec554 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -888,10 +888,12 @@ class EEStackController(CementBaseController): Log.debug(self, "Creating vimbadmin database if not exist") EEMysql.execute(self, "create database if not exists" " vimbadmin") - Log.debug(self, "Granting all privileges on vimbadmin.* to " - "vimbadmin@root IDENTIFIED BY password ") - EEMysql.execute(self, "grant all privileges on vimbadmin.* to" - " vimbadmin@{0} IDENTIFIED BY" + Log.debug(self, " grant all privileges on `vimbadmin`.* to" + " `vimbadmin`@`{0}` IDENTIFIED BY" + " ' '".format(self.app.config.get('mysql', + 'grant-host'))) + EEMysql.execute(self, "grant all privileges on `vimbadmin`.* " + " to `vimbadmin`@`{0}` IDENTIFIED BY" " '{1}'".format(self.app.config.get('mysql', 'grant-host'), vm_passwd), errormsg="Cannot grant " @@ -1022,10 +1024,14 @@ class EEStackController(CementBaseController): Log.debug(self, "Creating Database roundcubemail") EEMysql.execute(self, "create database if not exists " " roundcubemail") - Log.debug(self, "Grant all privileges on roundcubemail") + Log.debug(self, "grant all privileges" + " on `roundcubemail`.* to " + " `roundcube`@`{0}` IDENTIFIED BY " + "' '".format(self.app.config.get( + 'mysql', 'grant-host'))) EEMysql.execute(self, "grant all privileges" - " on roundcubemail.* to " - " roundcube@{0} IDENTIFIED BY " + " on `roundcubemail`.* to " + " `roundcube`@`{0}` IDENTIFIED BY " "'{1}'".format(self.app.config.get( 'mysql', 'grant-host'), rc_passwd)) @@ -1123,8 +1129,9 @@ class EEStackController(CementBaseController): (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) 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.admin = True if self.app.pargs.all: self.app.pargs.web = True @@ -1245,7 +1252,7 @@ class EEStackController(CementBaseController): else: Log.error(self, "Failed to find installed Dovecot") else: - Log.error(self, "Mail scanner allready installed") + Log.error(self, "Mail scanner already installed") if self.app.pargs.utils: Log.debug(self, "Setting packages variable for utils") @@ -1330,8 +1337,9 @@ class EEStackController(CementBaseController): (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) 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.admin = True if self.app.pargs.all: self.app.pargs.web = True @@ -1424,8 +1432,9 @@ class EEStackController(CementBaseController): (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) 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.admin = True if self.app.pargs.all: self.app.pargs.web = True diff --git a/ee/core/variables.py b/ee/core/variables.py index e42c3950..f481709e 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -12,7 +12,7 @@ class EEVariables(): """Intialization of core variables""" # EasyEngine version - ee_version = "3.0.2" + ee_version = "3.0.3" # EasyEngine packages versions ee_wp_cli = "0.18.0" diff --git a/install b/install index 2ff8e4bf..d6834b33 100644 --- a/install +++ b/install @@ -5,7 +5,7 @@ # to update current EasyEngine from 2.x to 3.x old_ee_version="2.2.3" -new_ee_version="3.0.2" +new_ee_version="3.0.3" branch=$1 # Define echo function @@ -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 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_user=$(grep db-name /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 fi 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 fi fi diff --git a/setup.py b/setup.py index 1d512bb4..60d3ff50 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ except Exception as e: os.system("git config --global user.email {0}".format(ee_email)) setup(name='ee', - version='3.0.2', + version='3.0.3', description=long_description, long_description=long_description, classifiers=[],