diff --git a/.travis.yml b/.travis.yml index 46c38ee8..66350828 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,6 +64,18 @@ script: - sudo ee site create site12.in --wpfc --wpsubdomain - sudo ee site create site12.net --wpfc --wpsubdomain + - sudo ee site create site.hhvm.pagespeed2.com --wpsc --hhvm --pagespeed + - sudo ee site create site.hhvm.pagespeed3.com --w3tc --hhvm --pagespeed + - sudo ee site create site.hhvm.pagespeed4.com --wpfc --hhvm --pagespeed + - sudo ee site create site.hhvm.pagespeed5.com --wpsubdir --hhvm --pagespeed + - sudo ee site create site.hhvm.pagespeed6.com --wpsubdir --wpsc --hhvm --pagespeed + - sudo ee site create site.hhvm.pagespeed7.com --wpsubdir --w3tc --hhvm --pagespeed + - sudo ee site create site.hhvm.pagespeed8.com --wpsubdir --wpfc --hhvm --pagespeed + - sudo ee site create site.hhvm.pagespeed9.com --wpsubdomain --hhvm --pagespeed + - sudo ee site create site.hhvm.pagespeed10.org --wpsubdomain --wpsc --hhvm --pagespeed + - sudo ee site create site.hhvm.pagespeed11.in --w3tc --wpsubdomain --hhvm --pagespeed + - sudo ee site create site.hhvm.pagespeed12.in --wpfc --wpsubdomain --hhvm --pagespeed + - sudo ee debug --all - sudo ee debug --all=off - sudo ee debug site12.net @@ -87,6 +99,10 @@ script: - sudo ee site update site9.com --wpsubdomain --wpfc - sudo ee site update site9.com --wpsubdomain --w3tc - sudo ee site update site9.com --wpsubdomain --wpsc + - sudo ee site update site.hhvm.pagespeed12.in --pagespeed=off --hhvm=off + - sudo ee site update site9.com --hhvm --pagespeed + - sudo ee site info site.hhvm.pagespeed12.in + - sudo ee site info site9.com - sudo ee site create www.site-1.com --wp - sudo ee site create www.subsite.site-1.com --wpfc @@ -96,6 +112,7 @@ script: - sudo ee site delete site12.in --all --no-prompt - sudo ee site delete site12.net --no-prompt - sudo ee site delete site12.org --no-prompt + - sudo ee site delete site9.com --no-prompt - sudo ee stack install --mail - sudo ls /var/www/ diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3c5505c4..56b1ee7c 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,10 @@ +v 3.1.0 - April 16, 2015 +- Added HHVM support #199 +- Added Pagespeed support #473 +- EasyEngine log command now suppots more subcommand #448 +- Before stack purge or remove, EasyEngine now asks confirmation #485 +- Minor fixes and improvements + v 3.0.10 - April 10, 2015 - Fixed regression issue introduced in 3.0.9 diff --git a/config/bash_completion.d/ee_auto.rc b/config/bash_completion.d/ee_auto.rc index d9d3c0f3..26d30ad3 100644 --- a/config/bash_completion.d/ee_auto.rc +++ b/config/bash_completion.d/ee_auto.rc @@ -22,7 +22,7 @@ _ee_complete() # HANDLE EVERYTHING AFTER THE SECOND LEVEL NAMESPACE "clean") COMPREPLY=( $(compgen \ - -W "--memcache --opcache --fastcgi --all" \ + -W "--memcache --opcache --fastcgi --pagespeed --all" \ -- $cur) ) ;; @@ -59,7 +59,7 @@ _ee_complete() "log") COMPREPLY=( $(compgen \ - -W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --mysql --php --nginx --all" \ + -W "show reset gzip mail" \ -- $cur) ) ;; @@ -74,7 +74,7 @@ _ee_complete() # HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE "install" | "purge" | "remove" ) COMPREPLY=( $(compgen \ - -W "--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot --all --mailscanner" \ + -W "--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot --all --mailscanner --hhvm" \ -- $cur) ) ;; "start" | "stop" | "reload" | "restart" | "status") @@ -94,8 +94,32 @@ _ee_complete() ;; "edit" | "enable" | "info" | "log" | "show" | "cd" | "update" | "delete") + if [ ${COMP_WORDS[1]} == "log" ]; then + COMPREPLY=( $(compgen \ + -W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql --access" \ + -- $cur) ) + else + COMPREPLY=( $(compgen \ + -W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null)" \ + -- $cur) ) + fi + ;; + + "gzip") COMPREPLY=( $(compgen \ - -W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null)" \ + -W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql --access" \ + -- $cur) ) + ;; + + "mail") + COMPREPLY=( $(compgen \ + -W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql --access --to=" \ + -- $cur) ) + ;; + + "reset") + COMPREPLY=( $(compgen \ + -W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql --wp --access --slow-log-db" \ -- $cur) ) ;; @@ -117,13 +141,13 @@ _ee_complete() -- $cur) ) fi - if [ ${COMP_WORDS[1]} == "log" ] && ([ "$prev" != "--access" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]); then - retlist="--all --wp --rewrite -i --all=off --wp=off --rewrite=off" - ret="${retlist[@]/$prev}" - COMPREPLY=( $(compgen \ - -W "$(echo $ret)" \ - -- $cur) ) - fi + #if [ ${COMP_WORDS[1]} == "log" ] && ([ "$prev" != "--access" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]); then + # retlist="--all --wp --rewrite -i --all=off --wp=off --rewrite=off" + # ret="${retlist[@]/$prev}" + # COMPREPLY=( $(compgen \ + # -W "$(echo $ret)" \ + # -- $cur) ) + #fi elif [ $COMP_CWORD -eq 4 ]; then @@ -132,13 +156,13 @@ _ee_complete() "create") COMPREPLY=( $(compgen \ - -W "--html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc" \ + -W "--html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed" \ -- $cur) ) ;; "update") COMPREPLY=( $(compgen \ - -W "--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc" \ + -W "--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off" \ -- $cur) ) ;; "delete") @@ -146,6 +170,34 @@ _ee_complete() -W "--db --files --all --no-prompt" \ -- $cur) ) ;; + "show") + COMPREPLY=( $(compgen \ + -W "--wp --nginx --php --fpm --mysql --access" \ + -- $cur) ) + ;; + + "gzip") + COMPREPLY=( $(compgen \ + -W "--wp --nginx --php --fpm --mysql --access" \ + -- $cur) ) + ;; + + "mail") + COMPREPLY=( $(compgen \ + -W "--wp --nginx --php --fpm --mysql --access --to=" \ + -- $cur) ) + ;; + + "reset") + COMPREPLY=( $(compgen \ + -W "--wp --nginx --php --fpm --mysql --wp --access --slow-log-db" \ + -- $cur) ) + ;; + edit) + COMPREPLY=( $(compgen \ + -W "--pagespeed" \ + -- $cur) ) + ;; *) ;; esac @@ -176,6 +228,18 @@ _ee_complete() if [[ $prev == '--mysql' ]]; then retlist="--start --nginx --php --fpm --mysql -i --interactive --stop --import-slow-log" fi + elif [[ ${COMP_WORDS[1]} == "log" ]]; then + if [ ${COMP_WORDS[2]} == "show" ]; then + retlist="--access --nginx --php --mysql --fpm --wp" + + elif [ ${COMP_WORDS[2]} == "reset" ]; then + retlist="--access --nginx --php --mysql --fpm --wp --slow-log-db" + + + elif [ ${COMP_WORDS[2]} == "mail" ]; then + retlist="--access --nginx --php --mysql --fpm --wp --to=" + + fi fi ret="${retlist[@]/$prev}" COMPREPLY=( $(compgen \ @@ -218,6 +282,25 @@ _ee_complete() -W "$(echo $ret)" \ -- $cur) ) ;; + "--access" | "--fpm" | "--wp" | "--slow-log-db") + if [[ ${COMP_WORDS[1]} == "log" ]]; then + if [ ${COMP_WORDS[2]} == "show" ]; then + retlist="--access --nginx --php --mysql --fpm --wp" + + elif [ ${COMP_WORDS[2]} == "reset" ]; then + retlist="--access --nginx --php --mysql --fpm --wp --slow-log-db" + + + elif [ ${COMP_WORDS[2]} == "mail" ]; then + retlist="--access --nginx --php --mysql --fpm --wp --to=" + + fi + fi + ret="${retlist[@]/$prev}" + COMPREPLY=( $(compgen \ + -W "$(echo $ret)" \ + -- $cur) ) + ;; *) ;; esac diff --git a/ee/cli/main.py b/ee/cli/main.py index f3b89d88..cd72f0d1 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -30,6 +30,7 @@ defaults['ee']['plugin_dir'] = '/var/lib/ee/plugins' # External templates (generally, do not ship with application code) defaults['ee']['template_dir'] = '/var/lib/ee/templates' + class EEArgHandler(ArgParseArgumentHandler): class Meta: label = 'ee_args_handler' @@ -80,6 +81,7 @@ app = EEApp() def main(): try: + global sys # Default our exit status to 0 (non-error) code = 0 @@ -91,6 +93,9 @@ def main(): # Setup the application app.setup() + # Dump all arguments into ee log + app.log.debug(sys.argv) + # Run the application app.run() except exc.EEError as e: diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index 9f1ca087..eb7d03b8 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -29,25 +29,31 @@ class EECleanController(CementBaseController): (['--memcache'], dict(help='Clean MemCache', action='store_true')), (['--opcache'], - dict(help='Clean OpCache', action='store_true')) + dict(help='Clean OpCache', action='store_true')), + (['--pagespeed'], + dict(help='Clean Pagespeed Cache', action='store_true')), ] usage = "ee clean [options]" @expose(hide=True) def default(self): if (not (self.app.pargs.all or self.app.pargs.fastcgi or - self.app.pargs.memcache or self.app.pargs.opcache)): + self.app.pargs.memcache or self.app.pargs.opcache or + self.app.pargs.pagespeed)): self.clean_fastcgi() if self.app.pargs.all: self.clean_memcache() self.clean_fastcgi() self.clean_opcache() + self.clean_pagespeed() if self.app.pargs.fastcgi: self.clean_fastcgi() if self.app.pargs.memcache: self.clean_memcache() if self.app.pargs.opcache: self.clean_opcache() + if self.app.pargs.pagespeed: + self.clean_pagespeed() @expose(hide=True) def clean_memcache(self): @@ -82,6 +88,15 @@ class EECleanController(CementBaseController): Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to clean OpCache") + @expose(hide=True) + def clean_pagespeed(self): + """This function clears Pagespeed cache""" + if(os.path.isdir("/var/ngx_pagespeed_cache")): + Log.info(self, "Cleaning PageSpeed cache") + EEShellExec.cmd_exec(self, "rm -rf /var/ngx_pagespeed_cache/*") + else: + Log.error(self, "Unable to clean Pagespeed cache") + def load(app): # register the plugin class.. this only happens if the plugin is enabled diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index e9f44335..c6f370a1 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -164,9 +164,9 @@ class EEDebugController(CementBaseController): "conf.d/upstream.conf " "| grep 9001")): Log.info(self, "Enabling PHP debug") - data = dict(php="9001", debug="9001") - Log.info(self, 'Writting the Nginx debug configration to file ' - '/etc/nginx/conf.d/upstream.conf ') + data = dict(php="9001", debug="9001", hhvm="9001") + Log.debug(self, 'Writting the Nginx debug configration to file' + ' /etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', encoding='utf-8', mode='w') self.app.render((data), 'upstream.mustache', out=ee_nginx) @@ -190,7 +190,7 @@ class EEDebugController(CementBaseController): "/etc/nginx/conf.d/upstream.conf " "| grep 9001"): Log.info(self, "Disabling PHP debug") - data = dict(php="9000", debug="9001") + data = dict(php="9000", debug="9001", hhvm="8000") Log.debug(self, 'Writting the Nginx debug configration to file' ' /etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', diff --git a/ee/cli/plugins/log.py b/ee/cli/plugins/log.py index e645d9fd..fbaffd94 100644 --- a/ee/cli/plugins/log.py +++ b/ee/cli/plugins/log.py @@ -7,8 +7,11 @@ from ee.cli.plugins.site_functions import logwatch from ee.core.variables import EEVariables from ee.core.fileutils import EEFileUtils from ee.core.shellexec import EEShellExec +from ee.core.sendmail import EESendMail +from ee.core.mysql import EEMysql import os import glob +import gzip def ee_log_hook(app): @@ -19,9 +22,22 @@ def ee_log_hook(app): class EELogController(CementBaseController): class Meta: label = 'log' - description = 'Show Nginx, PHP, MySQL log file' + description = 'Perform operations on Nginx, PHP, MySQL log file' stacked_on = 'base' stacked_type = 'nested' + usage = "ee log [] [options]" + + @expose(hide=True) + def default(self): + self.app.args.print_help() + + +class EELogShowController(CementBaseController): + class Meta: + label = 'show' + description = 'Show Nginx, PHP, MySQL log file' + stacked_on = 'log' + stacked_type = 'nested' arguments = [ (['--all'], dict(help='Show All logs file', action='store_true')), @@ -43,11 +59,11 @@ class EELogController(CementBaseController): (['site_name'], dict(help='Website Name', nargs='?', default=None)) ] - usage = "ee log [] [options]" + usage = "ee log show [] [options]" @expose(hide=True) def default(self): - """Default function of debug""" + """Default function of log show""" self.msg = [] if self.app.pargs.php: @@ -86,14 +102,17 @@ class EELogController(CementBaseController): if os.path.isfile('/var/log/mysql/mysql-slow.log'): self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] else: - Log.error(self, "Unable to find MySQL slow log file," - "Please generate it using commnad ee debug " - "--mysql") + Log.info(self, "MySQL slow-log not found, skipped") else: Log.warn(self, "Remote MySQL found, EasyEngine is not able to" "show MySQL log file") if self.app.pargs.site_name: + webroot = "{0}{1}".format(EEVariables.ee_webroot, + self.app.pargs.site_name) + + if not os.path.isdir(webroot): + Log.error(self, "Site not present, quitting") if self.app.pargs.access: self.msg = self.msg + ["{0}/{1}/logs/access.log" .format(EEVariables.ee_webroot, @@ -103,20 +122,20 @@ class EELogController(CementBaseController): .format(EEVariables.ee_webroot, self.app.pargs.site_name)] if self.app.pargs.wp: - webroot = "{0}{1}".format(EEVariables.ee_webroot, - self.app.pargs.site_name) - if not os.path.isfile('{0}/logs/debug.log' - .format(webroot)): - if not os.path.isfile('{0}/htdocs/wp-content/debug.log' + if os.path.isdir('{0}/htdocs/wp-content'.format(webroot)): + if not os.path.isfile('{0}/logs/debug.log' .format(webroot)): - open("{0}/htdocs/wp-content/debug.log".format(webroot), - encoding='utf-8', mode='a').close() - EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-" - "content/debug.log" - "".format(webroot, - EEVariables.ee_php_user) - ) - + if not os.path.isfile('{0}/htdocs/wp-content/debug.log' + .format(webroot)): + open("{0}/htdocs/wp-content/debug.log" + .format(webroot), + encoding='utf-8', mode='a').close() + EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/" + "wp-content/debug.log" + "".format(webroot, + EEVariables + .ee_php_user) + ) # create symbolic link for debug log EEFileUtils.create_symlink(self, ["{0}/htdocs/wp-content/" "debug.log" @@ -124,9 +143,13 @@ class EELogController(CementBaseController): '{0}/logs/debug.log' .format(webroot)]) - self.msg = self.msg + ["{0}/{1}/logs/debug.log" - .format(EEVariables.ee_webroot, - self.app.pargs.site_name)] + self.msg = self.msg + ["{0}/{1}/logs/debug.log" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] + else: + Log.info(self, "Site is not WordPress site, skipping " + "WordPress logs") + watch_list = [] for w_list in self.msg: watch_list = watch_list + glob.glob(w_list) @@ -134,8 +157,422 @@ class EELogController(CementBaseController): logwatch(self, watch_list) +class EELogResetController(CementBaseController): + class Meta: + label = 'reset' + description = 'Reset Nginx, PHP, MySQL log file' + stacked_on = 'log' + stacked_type = 'nested' + arguments = [ + (['--all'], + dict(help='Reset All logs file', action='store_true')), + (['--nginx'], + dict(help='Reset Nginx Error logs file', action='store_true')), + (['--php'], + dict(help='Reset PHP Error logs file', action='store_true')), + (['--fpm'], + dict(help='Reset PHP5-fpm slow logs file', + action='store_true')), + (['--mysql'], + dict(help='Reset MySQL logs file', action='store_true')), + (['--wp'], + dict(help='Reset Site specific WordPress logs file', + action='store_true')), + (['--access'], + dict(help='Reset Nginx access log file', + action='store_true')), + (['--slow-log-db'], + dict(help='Drop all rows from slowlog table in database', + action='store_true')), + (['site_name'], + dict(help='Website Name', nargs='?', default=None)) + ] + usage = "ee log reset [] [options]" + + @expose(hide=True) + def default(self): + """Default function of log reset""" + self.msg = [] + + if self.app.pargs.php: + self.app.pargs.nginx = True + + if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm) + and (not self.app.pargs.mysql) and (not self.app.pargs.access) + and (not self.app.pargs.wp) and (not self.app.pargs.site_name) + and (not self.app.pargs.slow_log_db)): + self.app.pargs.nginx = True + self.app.pargs.fpm = True + self.app.pargs.mysql = True + self.app.pargs.access = True + self.app.pargs.slow_log_db = True + + if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm) + and (not self.app.pargs.mysql) and (not self.app.pargs.access) + and (not self.app.pargs.wp) and (self.app.pargs.site_name) + and (not self.app.pargs.slow-log-db)): + self.app.pargs.nginx = True + self.app.pargs.wp = True + self.app.pargs.access = True + self.app.pargs.mysql = True + + if self.app.pargs.slow_log_db: + if os.path.isdir("/var/www/22222/htdocs/db/anemometer"): + Log.info(self, "Resetting MySQL slow_query_log database table") + EEMysql.execute(self, "TRUNCATE TABLE " + "slow_query_log.global_query_review_history") + EEMysql.execute(self, "TRUNCATE TABLE " + "slow_query_log.global_query_review") + + if self.app.pargs.nginx and (not self.app.pargs.site_name): + self.msg = self.msg + ["/var/log/nginx/*error.log"] + + if self.app.pargs.access and (not self.app.pargs.site_name): + self.msg = self.msg + ["/var/log/nginx/*access.log"] + + if self.app.pargs.fpm: + open('/var/log/php5/slow.log', 'a').close() + open('/var/log/php5/fpm.log', 'a').close() + self.msg = self.msg + ['/var/log/php5/slow.log', + '/var/log/php5/fpm.log'] + if self.app.pargs.mysql: + # MySQL debug will not work for remote MySQL + if EEVariables.ee_mysql_host is "localhost": + if os.path.isfile('/var/log/mysql/mysql-slow.log'): + self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] + else: + Log.info(self, "MySQL slow-log not found, skipped") + else: + Log.warn(self, "Remote MySQL found, EasyEngine is not able to" + "show MySQL log file") + + if self.app.pargs.site_name: + webroot = "{0}{1}".format(EEVariables.ee_webroot, + self.app.pargs.site_name) + + if not os.path.isdir(webroot): + Log.error(self, "Site not present, quitting") + if self.app.pargs.access: + self.msg = self.msg + ["{0}/{1}/logs/access.log" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] + if self.app.pargs.nginx: + self.msg = self.msg + ["{0}/{1}/logs/error.log" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] + if self.app.pargs.wp: + if os.path.isdir('{0}/htdocs/wp-content'.format(webroot)): + if not os.path.isfile('{0}/logs/debug.log' + .format(webroot)): + if not os.path.isfile('{0}/htdocs/wp-content/debug.log' + .format(webroot)): + open("{0}/htdocs/wp-content/debug.log" + .format(webroot), + encoding='utf-8', mode='a').close() + EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/" + "wp-content/debug.log" + "".format(webroot, + EEVariables + .ee_php_user) + ) + # create symbolic link for debug log + EEFileUtils.create_symlink(self, ["{0}/htdocs/wp-content/" + "debug.log" + .format(webroot), + '{0}/logs/debug.log' + .format(webroot)]) + + self.msg = self.msg + ["{0}/{1}/logs/debug.log" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] + else: + Log.info(self, "Site is not WordPress site, skipping " + "WordPress logs") + + reset_list = [] + for r_list in self.msg: + reset_list = reset_list + glob.glob(r_list) + + # Clearing content of file + for r_list in reset_list: + Log.info(self, "Resetting file {file}".format(file=r_list)) + open(r_list, 'w').close() + + +class EELogGzipController(CementBaseController): + class Meta: + label = 'gzip' + description = 'GZip Nginx, PHP, MySQL log file' + stacked_on = 'log' + stacked_type = 'nested' + arguments = [ + (['--all'], + dict(help='GZip All logs file', action='store_true')), + (['--nginx'], + dict(help='GZip Nginx Error logs file', action='store_true')), + (['--php'], + dict(help='GZip PHP Error logs file', action='store_true')), + (['--fpm'], + dict(help='GZip PHP5-fpm slow logs file', + action='store_true')), + (['--mysql'], + dict(help='GZip MySQL logs file', action='store_true')), + (['--wp'], + dict(help='GZip Site specific WordPress logs file', + action='store_true')), + (['--access'], + dict(help='GZip Nginx access log file', + action='store_true')), + (['site_name'], + dict(help='Website Name', nargs='?', default=None)) + ] + usage = "ee log gzip [] [options]" + + @expose(hide=True) + def default(self): + """Default function of log GZip""" + self.msg = [] + + if self.app.pargs.php: + self.app.pargs.nginx = True + + if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm) + and (not self.app.pargs.mysql) and (not self.app.pargs.access) + and (not self.app.pargs.wp) and (not self.app.pargs.site_name)): + self.app.pargs.nginx = True + self.app.pargs.fpm = True + self.app.pargs.mysql = True + self.app.pargs.access = True + + if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm) + and (not self.app.pargs.mysql) and (not self.app.pargs.access) + and (not self.app.pargs.wp) and (self.app.pargs.site_name)): + self.app.pargs.nginx = True + self.app.pargs.wp = True + self.app.pargs.access = True + self.app.pargs.mysql = True + + if self.app.pargs.nginx and (not self.app.pargs.site_name): + self.msg = self.msg + ["/var/log/nginx/*error.log"] + + if self.app.pargs.access and (not self.app.pargs.site_name): + self.msg = self.msg + ["/var/log/nginx/*access.log"] + + if self.app.pargs.fpm: + open('/var/log/php5/slow.log', 'a').close() + open('/var/log/php5/fpm.log', 'a').close() + self.msg = self.msg + ['/var/log/php5/slow.log', + '/var/log/php5/fpm.log'] + if self.app.pargs.mysql: + # MySQL debug will not work for remote MySQL + if EEVariables.ee_mysql_host is "localhost": + if os.path.isfile('/var/log/mysql/mysql-slow.log'): + self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] + else: + Log.info(self, "MySQL slow-log not found, skipped") + + else: + Log.warn(self, "Remote MySQL found, EasyEngine is not able to" + "show MySQL log file") + + if self.app.pargs.site_name: + webroot = "{0}{1}".format(EEVariables.ee_webroot, + self.app.pargs.site_name) + + if not os.path.isdir(webroot): + Log.error(self, "Site not present, quitting") + if self.app.pargs.access: + self.msg = self.msg + ["{0}/{1}/logs/access.log" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] + if self.app.pargs.nginx: + self.msg = self.msg + ["{0}/{1}/logs/error.log" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] + if self.app.pargs.wp: + if os.path.isdir('{0}/htdocs/wp-content'.format(webroot)): + if not os.path.isfile('{0}/logs/debug.log' + .format(webroot)): + if not os.path.isfile('{0}/htdocs/wp-content/debug.log' + .format(webroot)): + open("{0}/htdocs/wp-content/debug.log" + .format(webroot), + encoding='utf-8', mode='a').close() + EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/" + "wp-content/debug.log" + "".format(webroot, + EEVariables + .ee_php_user) + ) + # create symbolic link for debug log + EEFileUtils.create_symlink(self, ["{0}/htdocs/wp-content/" + "debug.log" + .format(webroot), + '{0}/logs/debug.log' + .format(webroot)]) + + self.msg = self.msg + ["{0}/{1}/logs/debug.log" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] + else: + Log.info(self, "Site is not WordPress site, skipping " + "WordPress logs") + + gzip_list = [] + for g_list in self.msg: + gzip_list = gzip_list + glob.glob(g_list) + + # Gzip content of file + for g_list in gzip_list: + Log.info(self, "Gzipping file {file}".format(file=g_list)) + in_file = g_list + in_data = open(in_file, "rb").read() + out_gz = g_list + ".gz" + gzf = gzip.open(out_gz, "wb") + gzf.write(in_data) + gzf.close() + + +class EELogMailController(CementBaseController): + class Meta: + label = 'mail' + description = 'Mail Nginx, PHP, MySQL log file' + stacked_on = 'log' + stacked_type = 'nested' + arguments = [ + (['--all'], + dict(help='Mail All logs file', action='store_true')), + (['--nginx'], + dict(help='Mail Nginx Error logs file', action='store_true')), + (['--php'], + dict(help='Mail PHP Error logs file', action='store_true')), + (['--fpm'], + dict(help='Mail PHP5-fpm slow logs file', + action='store_true')), + (['--mysql'], + dict(help='Mail MySQL logs file', action='store_true')), + (['--wp'], + dict(help='Mail Site specific WordPress logs file', + action='store_true')), + (['--access'], + dict(help='Mail Nginx access log file', + action='store_true')), + (['site_name'], + dict(help='Website Name', nargs='?', default=None)), + (['--to'], + dict(help='EMail addresses to send log files', action='append', + dest='to', nargs=1, required=True)), + ] + usage = "ee log mail [] [options]" + + @expose(hide=True) + def default(self): + """Default function of log Mail""" + self.msg = [] + + if self.app.pargs.php: + self.app.pargs.nginx = True + + if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm) + and (not self.app.pargs.mysql) and (not self.app.pargs.access) + and (not self.app.pargs.wp) and (not self.app.pargs.site_name)): + self.app.pargs.nginx = True + self.app.pargs.fpm = True + self.app.pargs.mysql = True + self.app.pargs.access = True + + if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm) + and (not self.app.pargs.mysql) and (not self.app.pargs.access) + and (not self.app.pargs.wp) and (self.app.pargs.site_name)): + self.app.pargs.nginx = True + self.app.pargs.wp = True + self.app.pargs.access = True + self.app.pargs.mysql = True + + if self.app.pargs.nginx and (not self.app.pargs.site_name): + self.msg = self.msg + ["/var/log/nginx/*error.log"] + + if self.app.pargs.access and (not self.app.pargs.site_name): + self.msg = self.msg + ["/var/log/nginx/*access.log"] + + if self.app.pargs.fpm: + open('/var/log/php5/slow.log', 'a').close() + open('/var/log/php5/fpm.log', 'a').close() + self.msg = self.msg + ['/var/log/php5/slow.log', + '/var/log/php5/fpm.log'] + if self.app.pargs.mysql: + # MySQL debug will not work for remote MySQL + if EEVariables.ee_mysql_host is "localhost": + if os.path.isfile('/var/log/mysql/mysql-slow.log'): + self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] + else: + Log.info(self, "MySQL slow-log not found, skipped") + else: + Log.warn(self, "Remote MySQL found, EasyEngine is not able to" + "show MySQL log file") + + if self.app.pargs.site_name: + webroot = "{0}{1}".format(EEVariables.ee_webroot, + self.app.pargs.site_name) + + if not os.path.isdir(webroot): + Log.error(self, "Site not present, quitting") + if self.app.pargs.access: + self.msg = self.msg + ["{0}/{1}/logs/access.log" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] + if self.app.pargs.nginx: + self.msg = self.msg + ["{0}/{1}/logs/error.log" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] + if self.app.pargs.wp: + if os.path.isdir('{0}/htdocs/wp-content'.format(webroot)): + if not os.path.isfile('{0}/logs/debug.log' + .format(webroot)): + if not os.path.isfile('{0}/htdocs/wp-content/debug.log' + .format(webroot)): + open("{0}/htdocs/wp-content/debug.log" + .format(webroot), + encoding='utf-8', mode='a').close() + EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/" + "wp-content/debug.log" + "".format(webroot, + EEVariables + .ee_php_user) + ) + # create symbolic link for debug log + EEFileUtils.create_symlink(self, ["{0}/htdocs/wp-content/" + "debug.log" + .format(webroot), + '{0}/logs/debug.log' + .format(webroot)]) + + self.msg = self.msg + ["{0}/{1}/logs/debug.log" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] + else: + Log.info(self, "Site is not WordPress site, skipping " + "WordPress logs") + + mail_list = [] + for m_list in self.msg: + mail_list = mail_list + glob.glob(m_list) + + for tomail in self.app.pargs.to: + Log.info(self, "Sending mail to {0}".format(tomail[0])) + EESendMail("easyengine", tomail[0], "{0} Log Files" + .format(EEVariables.ee_fqdn), + "Hey Hi,\n Please find attached server log files" + "\n\n\nYour's faithfully,\nEasyEngine", + files=mail_list, port=25, isTls=False) + + def load(app): # register the plugin class.. this only happens if the plugin is enabled handler.register(EELogController) + handler.register(EELogShowController) + handler.register(EELogResetController) + handler.register(EELogGzipController) + handler.register(EELogMailController) # register a hook (function) to run after arguments are parsed. hook.register('post_argument_parsing', ee_log_hook) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index ec1c1a42..22e3d122 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -42,10 +42,13 @@ class EESiteController(CementBaseController): def enable(self): if not self.app.pargs.site_name: try: - self.app.pargs.site_name = input('Enter site name : ') + while not self.app.pargs.site_name: + self.app.pargs.site_name = (input('Enter site name : ') + .strip()) except IOError as e: Log.error(self, 'could not input site name') + self.app.pargs.site_name = self.app.pargs.site_name.strip() # validate domain name (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) @@ -74,9 +77,13 @@ class EESiteController(CementBaseController): def disable(self): if not self.app.pargs.site_name: try: - self.app.pargs.site_name = input('Enter site name : ') + while not self.app.pargs.site_name: + self.app.pargs.site_name = (input('Enter site name : ') + .strip()) + except IOError as e: Log.error(self, 'could not input site name') + self.app.pargs.site_name = self.app.pargs.site_name.strip() (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) # check if site exists if not check_domain_exists(self, ee_domain): @@ -108,13 +115,17 @@ class EESiteController(CementBaseController): def info(self): if not self.app.pargs.site_name: try: - self.app.pargs.site_name = input('Enter site name : ') + while not self.app.pargs.site_name: + self.app.pargs.site_name = (input('Enter site name : ') + .strip()) except IOError as e: Log.error(self, 'could not input site name') + self.app.pargs.site_name = self.app.pargs.site_name.strip() (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) ee_db_name = '' ee_db_user = '' ee_db_pass = '' + hhvm = '' if not check_domain_exists(self, ee_domain): Log.error(self, "site {0} does not exist".format(ee_domain)) @@ -131,14 +142,18 @@ class EESiteController(CementBaseController): ee_db_user = siteinfo.db_user ee_db_pass = siteinfo.db_password ee_db_host = siteinfo.db_host + if sitetype != "html": + hhvm = ("enabled" if siteinfo.is_hhvm else "disabled") + + pagespeed = ("enabled" if siteinfo.is_pagespeed else "disabled") data = dict(domain=ee_domain, webroot=ee_site_webroot, accesslog=access_log, errorlog=error_log, dbname=ee_db_name, dbuser=ee_db_user, - dbpass=ee_db_pass, type=sitetype + " " + cachetype + - " ({0})".format("enabled" - if siteinfo.is_enabled else - "disabled")) + dbpass=ee_db_pass, hhvm=hhvm, pagespeed=pagespeed, + type=sitetype + " " + cachetype + " ({0})" + .format("enabled" if siteinfo.is_enabled else + "disabled")) self.app.render((data), 'siteinfo.mustache') else: Log.error(self, "nginx configuration file does not exist" @@ -146,6 +161,7 @@ class EESiteController(CementBaseController): @expose(help="Monitor example.com logs") def log(self): + self.app.pargs.site_name = self.app.pargs.site_name.strip() (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) ee_site_webroot = getSiteInfo(self, ee_domain).site_path @@ -155,42 +171,17 @@ class EESiteController(CementBaseController): if logfiles: logwatch(self, logfiles) - @expose(help="Edit Nginx configuration of example.com") - 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, 'Unable to read input, Please try again') - (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) - - if not check_domain_exists(self, ee_domain): - Log.error(self, "site {0} does not exist".format(ee_domain)) - if os.path.isfile('/etc/nginx/sites-available/{0}' - .format(ee_domain)): - try: - EEShellExec.invoke_editor(self, '/etc/nginx/sites-available/' - '{0}'.format(ee_domain)) - except CommandExecutionError as e: - Log.error(self, "Failed invoke editor") - if (EEGit.checkfilestatus(self, "/etc/nginx", - '/etc/nginx/sites-available/{0}'.format(ee_domain))): - EEGit.add(self, ["/etc/nginx"], msg="Edit website: {0}" - .format(ee_domain)) - # Reload NGINX - EEService.reload_service(self, 'nginx') - else: - Log.error(self, "nginx configuration file does not exists" - .format(ee_domain)) - @expose(help="Display Nginx configuration of example.com") def show(self): if not self.app.pargs.site_name: try: - self.app.pargs.site_name = input('Enter site name : ') + while not self.app.pargs.site_name: + self.app.pargs.site_name = (input('Enter site name : ') + .strip()) except IOError as e: Log.error(self, 'could not input site name') # TODO Write code for ee site edit command here + self.app.pargs.site_name = self.app.pargs.site_name.strip() (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) if not check_domain_exists(self, ee_domain): @@ -213,10 +204,13 @@ class EESiteController(CementBaseController): def cd(self): if not self.app.pargs.site_name: try: - self.app.pargs.site_name = input('Enter site name : ') + while not self.app.pargs.site_name: + self.app.pargs.site_name = (input('Enter site name : ') + .strip()) except IOError as e: Log.error(self, 'Unable to read input, please try again') + self.app.pargs.site_name = self.app.pargs.site_name.strip() (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) if not check_domain_exists(self, ee_domain): @@ -232,6 +226,79 @@ class EESiteController(CementBaseController): Log.error(self, "unable to change directory") +class EESiteEditController(CementBaseController): + class Meta: + label = 'edit' + stacked_on = 'site' + stacked_type = 'nested' + description = ('Edit Nginx configuration of site') + arguments = [ + (['site_name'], + dict(help='domain name for the site', + nargs='?')), + (['--pagespeed'], + dict(help="edit pagespeed configuration for site", + action='store_true')), + ] + + @expose(hide=True) + def default(self): + if not self.app.pargs.site_name: + try: + while not self.app.pargs.site_name: + self.app.pargs.site_name = (input('Enter site name : ') + .strip()) + except IOError as e: + Log.error(self, 'Unable to read input, Please try again') + + self.app.pargs.site_name = self.app.pargs.site_name.strip() + (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + + if not check_domain_exists(self, ee_domain): + Log.error(self, "site {0} does not exist".format(ee_domain)) + + ee_site_webroot = EEVariables.ee_webroot + ee_domain + + if not self.app.pargs.pagespeed: + if os.path.isfile('/etc/nginx/sites-available/{0}' + .format(ee_domain)): + try: + EEShellExec.invoke_editor(self, '/etc/nginx/sites-availa' + 'ble/{0}'.format(ee_domain)) + except CommandExecutionError as e: + Log.error(self, "Failed invoke editor") + if (EEGit.checkfilestatus(self, "/etc/nginx", + '/etc/nginx/sites-available/{0}'.format(ee_domain))): + EEGit.add(self, ["/etc/nginx"], msg="Edit website: {0}" + .format(ee_domain)) + # Reload NGINX + EEService.reload_service(self, 'nginx') + else: + Log.error(self, "nginx configuration file does not exists" + .format(ee_domain)) + + elif self.app.pargs.pagespeed: + if os.path.isfile('{0}/conf/nginx/pagespeed.conf' + .format(ee_site_webroot)): + try: + EEShellExec.invoke_editor(self, '{0}/conf/nginx/' + 'pagespeed.conf' + .format(ee_site_webroot)) + except CommandExecutionError as e: + Log.error(self, "Failed invoke editor") + if (EEGit.checkfilestatus(self, "{0}/conf/nginx" + .format(ee_site_webroot), + '{0}/conf/nginx/pagespeed.conf'.format(ee_site_webroot))): + EEGit.add(self, ["{0}/conf/nginx".format(ee_site_webroot)], + msg="Edit Pagespped config of site: {0}" + .format(ee_domain)) + # Reload NGINX + EEService.reload_service(self, 'nginx') + else: + Log.error(self, "Pagespeed configuration file does not exists" + .format(ee_domain)) + + class EESiteCreateController(CementBaseController): class Meta: label = 'create' @@ -267,6 +334,10 @@ class EESiteCreateController(CementBaseController): (['--wpsc'], dict(help="create wordpress single/multi site with wpsc cache", action='store_true')), + (['--hhvm'], + dict(help="create HHVM site", action='store_true')), + (['--pagespeed'], + dict(help="create pagespeed site", action='store_true')), ] @expose(hide=True) @@ -282,12 +353,21 @@ class EESiteCreateController(CementBaseController): if not self.app.pargs.site_name: try: - self.app.pargs.site_name = input('Enter site name : ') + while not self.app.pargs.site_name: + # preprocessing before finalize site name + self.app.pargs.site_name = (input('Enter site name : ') + .strip()) except IOError as e: Log.debug(self, str(e)) Log.error(self, "Unable to input site name, Please try again!") + self.app.pargs.site_name = self.app.pargs.site_name.strip() (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + + if not ee_domain.strip(): + Log.error("Invalid domain name, " + "Provide valid domain name") + ee_site_webroot = EEVariables.ee_webroot + ee_domain if check_domain_exists(self, ee_domain): @@ -324,6 +404,23 @@ class EESiteCreateController(CementBaseController): if stype == 'wpsubdir': data['wpsubdir'] = True + if stype == "html" and self.app.pargs.hhvm: + Log.error(self, "Can not create HTML site with HHVM") + + if data and self.app.pargs.hhvm: + data['hhvm'] = True + hhvm = 1 + elif data: + data['hhvm'] = False + hhvm = 0 + + if data and self.app.pargs.pagespeed: + data['pagespeed'] = True + pagespeed = 1 + elif data: + data['pagespeed'] = False + pagespeed = 0 + if not data: self.app.args.print_help() self.app.close(1) @@ -345,7 +442,12 @@ class EESiteCreateController(CementBaseController): Log.error(self, "Check logs for reason " "`tail /var/log/ee/ee.log` & Try Again!!!") - addNewSite(self, ee_domain, stype, cache, ee_site_webroot) + # Update pagespeed config + if self.app.pargs.pagespeed: + operateOnPagespeed(self, data) + + addNewSite(self, ee_domain, stype, cache, ee_site_webroot, + hhvm=hhvm, pagespeed=pagespeed) # Setup database for MySQL site if 'ee_db_name' in data.keys() and not data['wp']: try: @@ -495,11 +597,22 @@ class EESiteUpdateController(CementBaseController): dict(help="update to wpfc cache", action='store_true')), (['--wpsc'], dict(help="update to wpsc cache", action='store_true')), + (['--hhvm'], + dict(help='Use HHVM for site', + action='store' or 'store_const', + choices=('on', 'off'), const='on', nargs='?')), + (['--pagespeed'], + dict(help='Use PageSpeed for site', + action='store' or 'store_const', + choices=('on', 'off'), const='on', nargs='?')) ] @expose(help="Update site type or cache") def default(self): + hhvm = None + pagespeed = None + data = dict() try: stype, cache = detSitePar(vars(self.app.pargs)) @@ -510,10 +623,13 @@ class EESiteUpdateController(CementBaseController): if not self.app.pargs.site_name: try: - self.app.pargs.site_name = input('Enter site name : ') + while not self.app.pargs.site_name: + self.app.pargs.site_name = (input('Enter site name : ') + .strip()) except IOError as e: Log.error(self, 'Unable to input site name, Please try again!') + self.app.pargs.site_name = self.app.pargs.site_name.strip() (ee_domain, ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) ee_site_webroot = EEVariables.ee_webroot + ee_domain @@ -525,6 +641,8 @@ class EESiteUpdateController(CementBaseController): else: oldsitetype = check_site.site_type oldcachetype = check_site.cache_type + old_hhvm = check_site.is_hhvm + old_pagespeed = check_site.is_pagespeed if (self.app.pargs.password and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or @@ -573,12 +691,125 @@ class EESiteUpdateController(CementBaseController): if stype == 'wpsubdir': data['wpsubdir'] = True + if self.app.pargs.pagespeed or self.app.pargs.hhvm: + if not data: + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + currsitetype=oldsitetype, + currcachetype=oldcachetype, + webroot=ee_site_webroot) + + stype = oldsitetype + cache = oldcachetype + + if oldsitetype == 'html': + data['static'] = True + data['wp'] = False + data['multisite'] = False + data['wpsubdir'] = False + elif oldsitetype == 'php' or oldsitetype == 'mysql': + data['static'] = False + data['wp'] = False + data['multisite'] = False + data['wpsubdir'] = False + elif oldsitetype == 'wp': + data['static'] = False + data['wp'] = True + data['multisite'] = False + data['wpsubdir'] = False + elif oldsitetype == 'wpsubdir': + data['static'] = False + data['wp'] = True + data['multisite'] = True + data['wpsubdir'] = True + elif oldsitetype == 'wpsubdomain': + data['static'] = False + data['wp'] = True + data['multisite'] = True + data['wpsubdir'] = False + + if oldcachetype == 'basic': + data['basic'] = True + data['w3tc'] = False + data['wpfc'] = False + data['wpsc'] = False + elif oldcachetype == 'w3tc': + data['basic'] = False + data['w3tc'] = True + data['wpfc'] = False + data['wpsc'] = False + elif oldcachetype == 'wpfc': + data['basic'] = False + data['w3tc'] = False + data['wpfc'] = True + data['wpsc'] = False + elif oldcachetype == 'wpsc': + data['basic'] = False + data['w3tc'] = False + data['wpfc'] = False + data['wpsc'] = True + + if self.app.pargs.hhvm != 'off': + data['hhvm'] = True + hhvm = True + elif self.app.pargs.hhvm == 'off': + data['hhvm'] = False + hhvm = False + + if self.app.pargs.pagespeed != 'off': + data['pagespeed'] = True + pagespeed = True + elif self.app.pargs.pagespeed == 'off': + data['pagespeed'] = False + pagespeed = False + + if self.app.pargs.pagespeed: + if pagespeed is old_pagespeed: + if pagespeed is False: + Log.info(self, "Pagespeed is allready disabled for given " + "site") + elif pagespeed is True: + Log.info(self, "Pagespeed is allready enabled for given " + "site") + + if self.app.pargs.hhvm: + if hhvm is old_hhvm: + if hhvm is False: + Log.info(self, "HHVM is allready disabled for given " + "site") + elif hhvm is True: + Log.info(self, "HHVM is allready enabled for given " + "site") + + if data and (not self.app.pargs.hhvm): + if old_hhvm is True: + data['hhvm'] = True + hhvm = True + else: + data['hhvm'] = False + hhvm = False + + if data and (not self.app.pargs.pagespeed): + if old_pagespeed is True: + data['pagespeed'] = True + pagespeed = True + else: + data['pagespeed'] = False + pagespeed = False + + if self.app.pargs.pagespeed or self.app.pargs.hhvm: + if ((hhvm is old_hhvm) and (pagespeed is old_pagespeed) and + (stype == oldsitetype and cache == oldcachetype)): + self.app.close(0) + if not data: Log.error(self, " Cannot update {0}, Invalid Options" .format(ee_domain)) ee_auth = site_package_check(self, stype) - + data['ee_db_name'] = check_site.db_name + data['ee_db_user'] = check_site.db_user + data['ee_db_pass'] = check_site.db_password + data['ee_db_host'] = check_site.db_host try: sitebackup(self, data) except Exception as e: @@ -594,6 +825,22 @@ class EESiteUpdateController(CementBaseController): Log.error(self, "Update site failed. Check logs for reason " "`tail /var/log/ee/ee.log` & Try Again!!!") + # Update pagespeed config + if self.app.pargs.pagespeed: + operateOnPagespeed(self, data) + + if stype == oldsitetype and cache == oldcachetype: + + # Service Nginx Reload + EEService.reload_service(self, 'nginx') + + updateSiteInfo(self, ee_domain, stype=stype, cache=cache, + hhvm=hhvm, pagespeed=pagespeed) + + Log.info(self, "Successfully updated site" + " http://{0}".format(ee_domain)) + self.app.close(0) + if 'ee_db_name' in data.keys() and not data['wp']: try: data = setupdatabase(self, data) @@ -619,25 +866,25 @@ class EESiteUpdateController(CementBaseController): Log.error(self, "Update site failed. Check logs for reason " "`tail /var/log/ee/ee.log` & Try Again!!!") - if oldsitetype == 'mysql': - config_file = (ee_site_webroot + '/backup/{0}/ee-config.php' - .format(EEVariables.ee_date)) - data['ee_db_name'] = (EEFileUtils.grep(self, config_file, - 'DB_NAME') - .split(',')[1] - .split(')')[0].strip()) - data['ee_db_user'] = (EEFileUtils.grep(self, config_file, - 'DB_USER') - .split(',')[1] - .split(')')[0].strip()) - data['ee_db_pass'] = (EEFileUtils.grep(self, config_file, - 'DB_PASSWORD') - .split(',')[1] - .split(')')[0].strip()) - data['ee_db_host'] = (EEFileUtils.grep(self, config_file, - 'DB_HOST') - .split(',')[1] - .split(')')[0].strip()) + # if oldsitetype == 'mysql': + # # config_file = (ee_site_webroot + '/backup/{0}/ee-config.php' + # # .format(EEVariables.ee_date)) + # # data['ee_db_name'] = (EEFileUtils.grep(self, config_file, + # # 'DB_NAME') + # # .split(',')[1] + # # .split(')')[0].strip()) + # # data['ee_db_user'] = (EEFileUtils.grep(self, config_file, + # # 'DB_USER') + # # .split(',')[1] + # # .split(')')[0].strip()) + # # data['ee_db_pass'] = (EEFileUtils.grep(self, config_file, + # # 'DB_PASSWORD') + # # .split(',')[1] + # # .split(')')[0].strip()) + # # data['ee_db_host'] = (EEFileUtils.grep(self, config_file, + # # 'DB_HOST') + # # .split(',')[1] + # # .split(')')[0].strip()) # Setup WordPress if old sites are html/php/mysql sites if data['wp'] and oldsitetype in ['html', 'php', 'mysql']: @@ -723,9 +970,11 @@ class EESiteUpdateController(CementBaseController): db_name=data['ee_db_name'], db_user=data['ee_db_user'], db_password=data['ee_db_pass'], - db_host=data['ee_db_host']) + db_host=data['ee_db_host'], hhvm=hhvm, + pagespeed=pagespeed) else: - updateSiteInfo(self, ee_domain, stype=stype, cache=cache) + updateSiteInfo(self, ee_domain, stype=stype, cache=cache, + hhvm=hhvm, pagespeed=pagespeed) Log.info(self, "Successfully updated site" " http://{0}".format(ee_domain)) @@ -755,9 +1004,13 @@ class EESiteDeleteController(CementBaseController): def default(self): if not self.app.pargs.site_name: try: - self.app.pargs.site_name = input('Enter site name : ') + while not self.app.pargs.site_name: + self.app.pargs.site_name = (input('Enter site name : ') + .strip()) except IOError as e: Log.error(self, 'could not input site name') + + self.app.pargs.site_name = self.app.pargs.site_name.strip() (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) ee_db_name = '' ee_prompt = '' @@ -883,5 +1136,6 @@ def load(app): handler.register(EESiteUpdateController) handler.register(EESiteDeleteController) handler.register(EESiteListController) + handler.register(EESiteEditController) # register a hook (function) to run after arguments are parsed. hook.register('post_argument_parsing', ee_site_hook) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index d5ee20b9..6dac2414 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -7,6 +7,7 @@ from ee.cli.plugins.sitedb import * from ee.core.aptget import EEAptGet from ee.core.git import EEGit from ee.core.logging import Log +from ee.core.services import EEService import subprocess from subprocess import CalledProcessError import os @@ -88,6 +89,8 @@ def setupdomain(self, data): os.makedirs('{0}/htdocs'.format(ee_site_webroot)) if not os.path.exists('{0}/logs'.format(ee_site_webroot)): os.makedirs('{0}/logs'.format(ee_site_webroot)) + if not os.path.exists('{0}/conf/nginx'.format(ee_site_webroot)): + os.makedirs('{0}/conf/nginx'.format(ee_site_webroot)) EEFileUtils.create_symlink(self, ['/var/log/nginx/{0}.access.log' .format(ee_domain_name), @@ -499,15 +502,16 @@ def sitebackup(self, data): Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") configfiles = glob.glob(ee_site_webroot + '/*-config.php') - - if configfiles and EEFileUtils.isexist(self, configfiles[0]): - ee_db_name = (EEFileUtils.grep(self, configfiles[0], - 'DB_NAME').split(',')[1] - .split(')')[0].strip().replace('\'', '')) + # if configfiles and EEFileUtils.isexist(self, configfiles[0]): + # ee_db_name = (EEFileUtils.grep(self, configfiles[0], + # 'DB_NAME').split(',')[1] + # .split(')')[0].strip().replace('\'', '')) + if data['ee_db_name']: Log.info(self, 'Backing up database \t\t', end='') try: if not EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql" - .format(ee_db_name, backup_path)): + .format(data['ee_db_name'], + backup_path)): Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]") raise SiteError("mysqldump failed to backup database") @@ -529,7 +533,13 @@ def site_package_check(self, stype): stack.app = self.app if stype in ['html', 'php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']: Log.debug(self, "Setting apt_packages variable for Nginx") - if not EEAptGet.is_installed(self, 'nginx-common'): + + if EEVariables.ee_platform_distro == 'Debian': + check_nginx = 'nginx-extras' + else: + check_nginx = 'nginx-custom' + + if not EEAptGet.is_installed(self, check_nginx): apt_packages = apt_packages + EEVariables.ee_nginx if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']: @@ -555,6 +565,28 @@ def site_package_check(self, stype): "wp-cli-{0}.phar" .format(EEVariables.ee_wp_cli), "/usr/bin/wp", "WP-CLI"]] + + if self.app.pargs.hhvm: + Log.debug(self, "Setting apt_packages variable for HHVM") + if not EEAptGet.is_installed(self, 'hhvm'): + apt_packages = apt_packages + EEVariables.ee_hhvm + + # Check if Nginx is allready installed and Pagespeed config there or not + # If not then copy pagespeed config + if self.app.pargs.pagespeed: + if (os.path.isdir('/etc/nginx') and + (not os.path.isfile('/etc/nginx/conf.d/pagespeed.conf'))): + # Pagespeed configuration + data = dict() + Log.debug(self, 'Writting the Pagespeed Global ' + 'configuration to file /etc/nginx/conf.d/' + 'pagespeed.conf') + ee_nginx = open('/etc/nginx/conf.d/pagespeed.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'pagespeed-global.mustache', + out=ee_nginx) + ee_nginx.close() + return(stack.install(apt_packages=apt_packages, packages=packages, disp_msg=False)) @@ -769,6 +801,14 @@ def deleteDB(self, dbname, dbuser, dbhost): def deleteWebRoot(self, webroot): + # do some preprocessing before proceeding + webroot = webroot.strip() + if (webroot == "/var/www/" or webroot == "/var/www" + or webroot == "/var/www/.." or webroot == "/var/www/."): + Log.debug(self, "Tried to remove {0}, but didn't remove it" + .format(webroot)) + return False + if os.path.isdir(webroot): Log.debug(self, "Removing {0}".format(webroot)) EEFileUtils.rm(self, webroot) @@ -786,6 +826,7 @@ def removeNginxConf(self, domain): .format(domain)) EEFileUtils.rm(self, '/etc/nginx/sites-available/{0}' .format(domain)) + EEService.reload_service(self, 'nginx') EEGit.add(self, ["/etc/nginx"], msg="Deleted {0} " .format(domain)) @@ -811,3 +852,40 @@ def doCleanupAction(self, domain='', webroot='', dbname='', dbuser='', if not dbhost: raise SiteError("dbhost not provided") deleteDB(self, dbname, dbuser, dbhost) + + +def operateOnPagespeed(self, data): + + ee_domain_name = data['site_name'] + ee_site_webroot = data['webroot'] + + if data['pagespeed'] is True: + if not os.path.isfile("{0}/conf/nginx/pagespeed.conf.disabled" + .format(ee_site_webroot)): + Log.debug(self, 'Writting the Pagespeed common ' + 'configuration to file {0}/conf/nginx/pagespeed.conf' + 'pagespeed.conf'.format(ee_site_webroot)) + ee_nginx = open('{0}/conf/nginx/pagespeed.conf' + .format(ee_site_webroot), encoding='utf-8', + mode='w') + self.app.render((data), 'pagespeed-common.mustache', + out=ee_nginx) + ee_nginx.close() + else: + EEFileUtils.mvfile(self, "{0}/conf/nginx/pagespeed.conf.disabled" + .format(ee_site_webroot), + '{0}/conf/nginx/pagespeed.conf' + .format(ee_site_webroot)) + + elif data['pagespeed'] is False: + if os.path.isfile("{0}/conf/nginx/pagespeed.conf" + .format(ee_site_webroot)): + EEFileUtils.mvfile(self, "{0}/conf/nginx/pagespeed.conf" + .format(ee_site_webroot), + '{0}/conf/nginx/pagespeed.conf.disabled' + .format(ee_site_webroot)) + + # Add nginx conf folder into GIT + EEGit.add(self, ["{0}/conf/nginx".format(ee_site_webroot)], + msg="Adding Pagespeed config of site: {0}" + .format(ee_domain_name)) diff --git a/ee/cli/plugins/sitedb.py b/ee/cli/plugins/sitedb.py index 996bcdfe..c81b1249 100644 --- a/ee/cli/plugins/sitedb.py +++ b/ee/cli/plugins/sitedb.py @@ -12,13 +12,14 @@ import glob def addNewSite(self, site, stype, cache, path, enabled=True, ssl=False, fs='ext4', db='mysql', db_name=None, db_user=None, db_password=None, - db_host='localhost'): + db_host='localhost', hhvm=0, pagespeed=0): """ Add New Site record information into ee database. """ try: newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db, - db_name, db_user, db_password, db_host) + db_name, db_user, db_password, db_host, hhvm, + pagespeed) db_session.add(newRec) db_session.commit() except Exception as e: @@ -40,7 +41,8 @@ def getSiteInfo(self, site): def updateSiteInfo(self, site, stype='', cache='', webroot='', enabled=True, ssl=False, fs='', db='', db_name=None, - db_user=None, db_password=None, db_host=None): + db_user=None, db_password=None, db_host=None, hhvm=None, + pagespeed=None): """updates site record in database""" try: q = SiteDB.query.filter(SiteDB.sitename == site).first() @@ -79,6 +81,12 @@ def updateSiteInfo(self, site, stype='', cache='', webroot='', if webroot and q.site_path != webroot: q.site_path = webroot + if (hhvm is not None) and (q.is_hhvm is not hhvm): + q.is_hhvm = hhvm + + if (pagespeed is not None) and (q.is_pagespeed is not pagespeed): + q.is_pagespeed = pagespeed + try: q.created_on = func.now() db_session.commit() diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index cebdde53..8b1ec21a 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -58,6 +58,8 @@ class EEStackController(CementBaseController): dict(help='Install PHP stack', action='store_true')), (['--mysql'], dict(help='Install MySQL stack', action='store_true')), + (['--hhvm'], + dict(help='Install HHVM stack', action='store_true')), (['--postfix'], dict(help='Install Postfix stack', action='store_true')), (['--wpcli'], @@ -166,6 +168,16 @@ class EEStackController(CementBaseController): Log.debug(self, 'Adding ppa for PHP') EERepo.add(self, ppa=EEVariables.ee_php_repo) + if set(EEVariables.ee_hhvm).issubset(set(apt_packages)): + Log.info(self, "Adding repository for HHVM, please wait ...") + if EEVariables.ee_platform_codename == 'precise': + Log.debug(self, 'Adding PPA for Boost') + EERepo.add(self, ppa=EEVariables.ee_boost_repo) + Log.debug(self, 'Adding ppa repo for HHVM') + EERepo.add(self, repo_url=EEVariables.ee_hhvm_repo) + Log.debug(self, 'Adding HHVM GPG Key') + EERepo.add_key(self, '0x5a16e7281be7a449') + if set(EEVariables.ee_mail).issubset(set(apt_packages)): Log.debug(self, 'Executing the command debconf-set-selections.') try: @@ -229,7 +241,7 @@ class EEStackController(CementBaseController): self.app.render((data), 'fastcgi.mustache', out=ee_nginx) ee_nginx.close() - data = dict(php="9000", debug="9001") + data = dict(php="9000", debug="9001", hhvm="8000") Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', @@ -261,7 +273,39 @@ class EEStackController(CementBaseController): ee_nginx.close() Log.debug(self, 'Writting the nginx configuration to ' - 'file /etc/nginx/common/ php.conf') + 'file /etc/nginx/common/php-hhvm.conf') + ee_nginx = open('/etc/nginx/common/php-hhvm.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'php-hhvm.mustache', + out=ee_nginx) + ee_nginx.close() + + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/common/w3tc-hhvm.conf') + ee_nginx = open('/etc/nginx/common/w3tc-hhvm.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'w3tc-hhvm.mustache', + out=ee_nginx) + ee_nginx.close() + + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/common/wpfc-hhvm.conf') + ee_nginx = open('/etc/nginx/common/wpfc-hhvm.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'wpfc-hhvm.mustache', + out=ee_nginx) + ee_nginx.close() + + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/common/wpsc-hhvm.conf') + ee_nginx = open('/etc/nginx/common/wpsc-hhvm.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'wpsc-hhvm.mustache', + out=ee_nginx) + ee_nginx.close() + + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/common/php.conf') ee_nginx = open('/etc/nginx/common/php.conf', encoding='utf-8', mode='w') self.app.render((data), 'php.mustache', @@ -308,6 +352,16 @@ class EEStackController(CementBaseController): out=ee_nginx) ee_nginx.close() + # Pagespeed configuration + Log.debug(self, 'Writting the Pagespeed Global ' + 'configuration to file /etc/nginx/conf.d/' + 'pagespeed.conf') + ee_nginx = open('/etc/nginx/conf.d/pagespeed.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'pagespeed-global.mustache', + out=ee_nginx) + ee_nginx.close() + # 22222 port settings Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/sites-available/' @@ -533,6 +587,81 @@ class EEStackController(CementBaseController): EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") EEService.reload_service(self, 'php5-fpm') + if set(EEVariables.ee_hhvm).issubset(set(apt_packages)): + EEFileUtils.searchreplace(self, "/etc/hhvm/server.ini", + "9000", "8000") + EEFileUtils.searchreplace(self, "/etc/nginx/hhvm.conf", + "9000", "8000") + + with open("/etc/hhvm/php.ini", "a") as hhvm_file: + hhvm_file.write("hhvm.log.header = true\n" + "hhvm.log.natives_stack_trace = true\n" + "hhvm.mysql.socket = " + "/var/run/mysqld/mysqld.sock\n" + "hhvm.pdo_mysql.socket = " + "/var/run/mysqld/mysqld.sock\n" + "hhvm.mysqli.socket = " + "/var/run/mysqld/mysqld.sock\n") + + if os.path.isfile("/etc/nginx/conf.d/fastcgi.conf"): + if not EEFileUtils.grep(self, "/etc/nginx/conf.d/" + "fastcgi.conf", + "fastcgi_keep_conn"): + with open("/etc/nginx/conf.d/fastcgi.conf", + "a") as hhvm_file: + hhvm_file.write("fastcgi_keep_conn on;\n") + + if os.path.isfile("/etc/nginx/conf.d/upstream.conf"): + if not EEFileUtils.grep(self, "/etc/nginx/conf.d/" + "upstream.conf", + "hhvm"): + with open("/etc/nginx/conf.d/upstream.conf", + "a") as hhvm_file: + hhvm_file.write("upstream hhvm {\nserver " + "127.0.0.1:8000;\n" + "server 127.0.0.1:9000 backup;\n}" + "\n") + + EEGit.add(self, ["/etc/hhvm"], msg="Adding HHVM into Git") + EEService.restart_service(self, 'hhvm') + EEService.reload_service(self, 'nginx') + + if os.path.isdir("/etc/nginx") and (not + os.path.isfile("/etc/nginx/common/php-hhvm.conf")): + + data = dict() + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/common/php-hhvm.conf') + ee_nginx = open('/etc/nginx/common/php-hhvm.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'php-hhvm.mustache', + out=ee_nginx) + ee_nginx.close() + + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/common/w3tc-hhvm.conf') + ee_nginx = open('/etc/nginx/common/w3tc-hhvm.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'w3tc-hhvm.mustache', + out=ee_nginx) + ee_nginx.close() + + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/common/wpfc-hhvm.conf') + ee_nginx = open('/etc/nginx/common/wpfc-hhvm.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'wpfc-hhvm.mustache', + out=ee_nginx) + ee_nginx.close() + + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/common/wpsc-hhvm.conf') + ee_nginx = open('/etc/nginx/common/wpsc-hhvm.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'wpsc-hhvm.mustache', + out=ee_nginx) + ee_nginx.close() + if set(EEVariables.ee_mysql).issubset(set(apt_packages)): # TODO: Currently we are using, we need to remove it in future # config = configparser.ConfigParser() @@ -1223,7 +1352,8 @@ class EEStackController(CementBaseController): (not self.app.pargs.mail) 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.wpcli) and - (not self.app.pargs.phpmyadmin) and + (not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm) + and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and (not self.app.pargs.mailscanner) and (not self.app.pargs.all)): self.app.pargs.web = True @@ -1235,13 +1365,12 @@ class EEStackController(CementBaseController): self.app.pargs.mail = True if self.app.pargs.web: - Log.debug(self, "Setting apt_packages variable for Nginx ,PHP" - " ,MySQL ") self.app.pargs.nginx = True self.app.pargs.php = True self.app.pargs.mysql = True self.app.pargs.wpcli = True self.app.pargs.postfix = True + self.app.pargs.hhvm = True if self.app.pargs.admin: self.app.pargs.nginx = True @@ -1285,7 +1414,13 @@ class EEStackController(CementBaseController): if self.app.pargs.nginx: Log.debug(self, "Setting apt_packages variable for Nginx") - if not EEAptGet.is_installed(self, 'nginx-common'): + + if EEVariables.ee_platform_distro == 'Debian': + check_nginx = 'nginx-extras' + else: + check_nginx = 'nginx-custom' + + if not EEAptGet.is_installed(self, check_nginx): apt_packages = apt_packages + EEVariables.ee_nginx else: Log.debug(self, "Nginx already installed") @@ -1297,6 +1432,15 @@ class EEStackController(CementBaseController): else: Log.debug(self, "PHP already installed") Log.info(self, "PHP already installed") + + if self.app.pargs.hhvm: + Log.debug(self, "Setting apt packages variable for HHVM") + if not EEAptGet.is_installed(self, 'hhvm'): + apt_packages = apt_packages + EEVariables.ee_hhvm + else: + Log.debug(self, "HHVM already installed") + Log.info(self, "HHVM already installed") + if self.app.pargs.mysql: Log.debug(self, "Setting apt_packages variable for MySQL") if not EEShellExec.cmd_exec(self, "mysqladmin ping"): @@ -1432,7 +1576,7 @@ class EEStackController(CementBaseController): (not self.app.pargs.mail) 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.wpcli) and - (not self.app.pargs.phpmyadmin) and + (not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and (not self.app.pargs.mailscanner) and (not self.app.pargs.all)): self.app.pargs.web = True @@ -1446,6 +1590,7 @@ class EEStackController(CementBaseController): if self.app.pargs.web: self.app.pargs.nginx = True self.app.pargs.php = True + self.app.pargs.hhvm = True self.app.pargs.mysql = True self.app.pargs.wpcli = True self.app.pargs.postfix = True @@ -1476,6 +1621,12 @@ class EEStackController(CementBaseController): if self.app.pargs.php: Log.debug(self, "Removing apt_packages variable of PHP") apt_packages = apt_packages + EEVariables.ee_php + + if self.app.pargs.hhvm: + if EEAptGet.is_installed(self, 'hhvm'): + Log.debug(self, "Removing apt_packages varible of HHVM") + apt_packages = apt_packages + EEVariables.ee_hhvm + if self.app.pargs.mysql: Log.debug(self, "Removing apt_packages variable of MySQL") apt_packages = apt_packages + EEVariables.ee_mysql @@ -1506,16 +1657,28 @@ class EEStackController(CementBaseController): '/usr/bin/pt-query-advisor', '{0}22222/htdocs/db/anemometer' .format(EEVariables.ee_webroot)] + ee_prompt = input('Are you sure you to want to' + ' purge from server.' + 'Package configuration will remain' + ' on server after this operation.\n' + 'Any answer other than ' + '"yes" will be stop this' + ' operation : ') if len(apt_packages): - Log.debug(self, "Removing apt_packages") - Log.info(self, "Uninstalling packages, please wait ...") - EEAptGet.remove(self, apt_packages) - EEAptGet.auto_remove(self) + if ee_prompt == 'YES' or ee_prompt == 'yes': + Log.debug(self, "Removing apt_packages") + Log.info(self, "Removing packages, please wait ...") + EEAptGet.remove(self, apt_packages) + EEAptGet.auto_remove(self) + if len(packages): - EEFileUtils.remove(self, packages) - EEAptGet.auto_remove(self) - Log.info(self, "Successfully removed packages") + if ee_prompt == 'YES' or ee_prompt == 'yes': + EEFileUtils.remove(self, packages) + EEAptGet.auto_remove(self) + + if ee_prompt == 'YES' or ee_prompt == 'yes': + Log.info(self, "Successfully removed packages") @expose(help="Purge packages") def purge(self): @@ -1528,7 +1691,7 @@ class EEStackController(CementBaseController): (not self.app.pargs.mail) 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.wpcli) and - (not self.app.pargs.phpmyadmin) and + (not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and (not self.app.pargs.mailscanner) and (not self.app.pargs.all)): self.app.pargs.web = True @@ -1545,6 +1708,7 @@ class EEStackController(CementBaseController): self.app.pargs.mysql = True self.app.pargs.wpcli = True self.app.pargs.postfix = True + self.app.pargs.hhvm = True if self.app.pargs.admin: self.app.pargs.adminer = True @@ -1572,6 +1736,10 @@ class EEStackController(CementBaseController): if self.app.pargs.php: Log.debug(self, "Purge apt_packages variable PHP") apt_packages = apt_packages + EEVariables.ee_php + if self.app.pargs.hhvm: + if EEAptGet.is_installed(self, 'hhvm'): + Log.debug(self, "Removing apt_packages varible of HHVM") + apt_packages = apt_packages + EEVariables.ee_hhvm if self.app.pargs.mysql: Log.debug(self, "Purge apt_packages variable MySQL") apt_packages = apt_packages + EEVariables.ee_mysql @@ -1604,14 +1772,26 @@ class EEStackController(CementBaseController): .format(EEVariables.ee_webroot) ] + ee_prompt = input('Are you sure you to want to purge ' + 'from server ' + 'alongwith their configuration' + ' packages,\nAny answer other than ' + '"yes" will be stop this ' + 'operation :') + if len(apt_packages): - Log.info(self, "Uninstalling packages, please wait ...") - EEAptGet.remove(self, apt_packages, purge=True) - EEAptGet.auto_remove(self) + if ee_prompt == 'YES' or ee_prompt == 'yes': + Log.info(self, "Purging packages, please wait ...") + EEAptGet.remove(self, apt_packages, purge=True) + EEAptGet.auto_remove(self) + if len(packages): - EEFileUtils.remove(self, packages) - EEAptGet.auto_remove(self) - Log.info(self, "Successfully purged packages") + if ee_prompt == 'YES' or ee_prompt == 'yes': + EEFileUtils.remove(self, packages) + EEAptGet.auto_remove(self) + + if ee_prompt == 'YES' or ee_prompt == 'yes': + Log.info(self, "Successfully purged packages") def load(app): diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index dd184afd..3c80800f 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -38,6 +38,9 @@ class EEStackStatusController(CementBaseController): if self.app.pargs.postfix: Log.debug(self, "postfix service start") services = services + ['postfix'] + if self.app.pargs.hhvm: + services = services + ['hhvm'] + Log.debug(self, "hhvm service start") if self.app.pargs.memcache: Log.debug(self, "memcached service start") services = services + ['memcached'] @@ -45,11 +48,12 @@ class EEStackStatusController(CementBaseController): Log.debug(self, "dovecot service start") services = services + ['dovecot'] if not services and EEVariables.ee_mysql_host is "localhost": - services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] - Log.debug(self, "nginx,php5-fpm,mysql,postfix services start") + services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix', + 'hhvm'] + Log.debug(self, "nginx,php5-fpm,mysql,postfix,hhvm services start") elif not services: - services = services + ['nginx', 'php5-fpm', 'postfix'] - Log.debug(self, "nginx,php5-fpm,postfix services start") + services = services + ['nginx', 'php5-fpm', 'postfix', 'hhvm'] + Log.debug(self, "nginx,php5-fpm,postfix,hhvm services start") for service in services: EEService.start_service(self, service) @@ -74,6 +78,9 @@ class EEStackStatusController(CementBaseController): if self.app.pargs.postfix: Log.debug(self, "postfix service stop") services = services + ['postfix'] + if self.app.pargs.hhvm: + services = services + ['hhvm'] + Log.debug(self, "hhvm service stop") if self.app.pargs.memcache: Log.debug(self, "memcached service stop") services = services + ['memcached'] @@ -81,11 +88,12 @@ class EEStackStatusController(CementBaseController): Log.debug(self, "dovecot service stop") services = services + ['dovecot'] if not services and EEVariables.ee_mysql_host is "localhost": - services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] - Log.debug(self, "nginx,php5-fpm,mysql,postfix services stop") + services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix', + 'hhvm'] + Log.debug(self, "nginx,php5-fpm,mysql,postfix,hhvm services stop") elif not services: - services = services + ['nginx', 'php5-fpm', 'postfix'] - Log.debug(self, "nginx,php5-fpm,postfix services stop") + services = services + ['nginx', 'php5-fpm', 'postfix', 'hhvm'] + Log.debug(self, "nginx,php5-fpm,postfix,hhvm services stop") for service in services: EEService.stop_service(self, service) @@ -109,6 +117,9 @@ class EEStackStatusController(CementBaseController): if self.app.pargs.postfix: Log.debug(self, "postfix service restart") services = services + ['postfix'] + if self.app.pargs.hhvm: + services = services + ['hhvm'] + Log.debug(self, "hhvm service restart") if self.app.pargs.memcache: Log.debug(self, "memcached service restart") services = services + ['memcached'] @@ -116,11 +127,13 @@ class EEStackStatusController(CementBaseController): Log.debug(self, "dovecot service restart") services = services + ['dovecot'] if not services and EEVariables.ee_mysql_host is "localhost": - services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] - Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart") + services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix', + 'hhvm'] + Log.debug(self, "nginx,php5-fpm,mysql,postfix,hhvm services" + "restart") elif not services: - services = services + ['nginx', 'php5-fpm', 'postfix'] - Log.debug(self, "nginx,php5-fpm,postfix services restart") + services = services + ['nginx', 'php5-fpm', 'postfix', 'hhvm'] + Log.debug(self, "nginx,php5-fpm,postfix,hhvm services restart") for service in services: EEService.restart_service(self, service) @@ -144,6 +157,9 @@ class EEStackStatusController(CementBaseController): if self.app.pargs.postfix: services = services + ['postfix'] Log.debug(self, "postfix service status") + if self.app.pargs.hhvm: + services = services + ['hhvm'] + Log.debug(self, "hhvm service status") if self.app.pargs.memcache: Log.debug(self, "memcached service status") services = services + ['memcached'] @@ -151,11 +167,13 @@ class EEStackStatusController(CementBaseController): Log.debug(self, "dovecot service status") services = services + ['dovecot'] if not services and EEVariables.ee_mysql_host is "localhost": - services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] - Log.debug(self, "nginx,php5-fpm,mysql,postfix services status") + services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix', + 'hhvm'] + Log.debug(self, "nginx,php5-fpm,mysql,postfix,hhvm services" + " status") elif not services: - services = services + ['nginx', 'php5-fpm', 'postfix'] - Log.debug(self, "nginx,php5-fpm,postfix services status") + services = services + ['nginx', 'php5-fpm', 'postfix', 'hhvm'] + Log.debug(self, "nginx,php5-fpm,postfix,hhvm services status") for service in services: if EEService.get_service_status(self, service): Log.info(self, "{0:10}: {1}".format(service, "Running")) @@ -180,6 +198,8 @@ class EEStackStatusController(CementBaseController): if self.app.pargs.postfix: Log.debug(self, "postfix service reload") services = services + ['postfix'] + if self.app.pargs.hhvm: + Log.warn(self, "hhvm does not support to reload") if self.app.pargs.memcache: Log.debug(self, "memcached service reload") services = services + ['memcached'] diff --git a/ee/cli/templates/fastcgi.mustache b/ee/cli/templates/fastcgi.mustache index db82c459..6d4bc4ba 100644 --- a/ee/cli/templates/fastcgi.mustache +++ b/ee/cli/templates/fastcgi.mustache @@ -7,3 +7,4 @@ fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_param SERVER_NAME $http_host; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; +fastcgi_keep_conn on; diff --git a/ee/cli/templates/pagespeed-common.mustache b/ee/cli/templates/pagespeed-common.mustache new file mode 100644 index 00000000..5b789c8d --- /dev/null +++ b/ee/cli/templates/pagespeed-common.mustache @@ -0,0 +1,44 @@ +# HTTPS Support +# pagespeed FetchHttps enable; + +# PageSpeed Filters +# CSS Minification +# pagespeed EnableFilters combine_css,rewrite_css; + +# JS Minification +# pagespeed EnableFilters combine_javascript,rewrite_javascript; + +# Images Optimization +#pagespeed EnableFilters lazyload_images; +#pagespeed EnableFilters rewrite_images; +#pagespeed EnableFilters convert_jpeg_to_progressive,convert_png_to_jpeg,convert_jpeg_to_webp,convert_to_webp_lossless; + +# Remove comments from HTML +#pagespeed EnableFilters remove_comments; +# Remove WHITESPACE from HTML +#pagespeed EnableFilters collapse_whitespace; + + +# CDN Support +#pagespeed MapRewriteDomain cdn.example.com www.example.com; + + +########################################################################################################################### +# DO NOT EDIT AFTER THIS LINE # +########################################################################################################################### + +# PageSpeed Admin +location /ngx_pagespeed_statistics { include common/acl.conf; } +location /ngx_pagespeed_global_statistics { include common/acl.conf; } +location /ngx_pagespeed_message { include common/acl.conf; } +location /pagespeed_console { include common/acl.conf; } +location ~ ^/pagespeed_admin { include common/acl.conf; } +location ~ ^/pagespeed_global_admin { include common/acl.conf; } + +# Ensure requests for pagespeed optimized resources go to the pagespeed handler +# and no extraneous headers get set. +location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { + add_header "" ""; +} +location ~ "^/pagespeed_static/" { } +location ~ "^/ngx_pagespeed_beacon$" { } diff --git a/ee/cli/templates/pagespeed-global.mustache b/ee/cli/templates/pagespeed-global.mustache new file mode 100644 index 00000000..bb5ab51e --- /dev/null +++ b/ee/cli/templates/pagespeed-global.mustache @@ -0,0 +1,21 @@ +# Turning the module on and off +pagespeed on; + +# Configuring PageSpeed Filters +pagespeed RewriteLevel PassThrough; + +# Needs to exist and be writable by nginx. Use tmpfs for best performance. +pagespeed MemcachedServers "127.0.0.1:11211"; +pagespeed FileCachePath /var/ngx_pagespeed_cache; + +# PageSpeed Admin +pagespeed StatisticsPath /ngx_pagespeed_statistics; +pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics; +pagespeed MessagesPath /ngx_pagespeed_message; +pagespeed ConsolePath /pagespeed_console; +pagespeed AdminPath /pagespeed_admin; +pagespeed GlobalAdminPath /pagespeed_global_admin; + +# PageSpeed Cache Purge +pagespeed EnableCachePurge on; +pagespeed PurgeMethod PURGE; diff --git a/ee/cli/templates/php-hhvm.mustache b/ee/cli/templates/php-hhvm.mustache new file mode 100644 index 00000000..54f4d2aa --- /dev/null +++ b/ee/cli/templates/php-hhvm.mustache @@ -0,0 +1,10 @@ +# PHP NGINX CONFIGURATION +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +location / { + try_files $uri $uri/ /index.php?$args; +} +location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass hhvm; +} diff --git a/ee/cli/templates/siteinfo.mustache b/ee/cli/templates/siteinfo.mustache index dfe7d917..0381a3f0 100644 --- a/ee/cli/templates/siteinfo.mustache +++ b/ee/cli/templates/siteinfo.mustache @@ -1,6 +1,8 @@ Information about {{domain}}: Nginx configuration {{type}} {{enable}} +{{#pagespeed}}Pagespeed {{pagespeed}}{{/pagespeed}} +{{#hhvm}}HHVM {{hhvm}}{{/hhvm}} access_log {{accesslog}} error_log {{errorlog}} Webroot {{webroot}} diff --git a/ee/cli/templates/upstream.mustache b/ee/cli/templates/upstream.mustache index 8a265179..d53d1a01 100644 --- a/ee/cli/templates/upstream.mustache +++ b/ee/cli/templates/upstream.mustache @@ -7,3 +7,8 @@ upstream debug { # Debug Pool server 127.0.0.1:{{debug}}; } +upstream hhvm { +# HHVM Pool +server 127.0.0.1:{{hhvm}}; +server 127.0.0.1:{{php}} backup; +} diff --git a/ee/cli/templates/virtualconf.mustache b/ee/cli/templates/virtualconf.mustache index cadb946b..b4b065c1 100644 --- a/ee/cli/templates/virtualconf.mustache +++ b/ee/cli/templates/virtualconf.mustache @@ -27,8 +27,9 @@ server { } {{/static}} - {{^static}}include{{/static}} {{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}} + {{^static}}include{{/static}} {{^hhvm}}{{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}} {{/hhvm}}{{#hhvm}}{{#basic}}common/php-hhvm.conf;{{/basic}}{{#w3tc}}common/w3tc-hhvm.conf;{{/w3tc}}{{#wpfc}}common/wpfc-hhvm.conf;{{/wpfc}} {{#wpsc}}common/wpsc-hhvm.conf;{{/wpsc}} {{/hhvm}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}} {{#wp}}include common/wpcommon.conf;{{/wp}} include common/locations.conf; + {{^vma}}{{^rc}}include {{webroot}}/conf/nginx/*.conf;{{/rc}}{{/vma}} } diff --git a/ee/cli/templates/w3tc-hhvm.mustache b/ee/cli/templates/w3tc-hhvm.mustache new file mode 100644 index 00000000..dbaca7c0 --- /dev/null +++ b/ee/cli/templates/w3tc-hhvm.mustache @@ -0,0 +1,31 @@ + +# W3TC NGINX CONFIGURATION +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +set $cache_uri $request_uri; +# POST requests and URL with a query string should always go to php +if ($request_method = POST) { + set $cache_uri 'null cache'; +} +if ($query_string != "") { + set $cache_uri 'null cache'; +} +# Don't cache URL containing the following segments +if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { + set $cache_uri 'null cache'; +} +# Don't use the cache for logged in users or recent commenter +if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { + set $cache_uri 'null cache'; +} +# Use cached or actual file if they exists, Otherwise pass request to WordPress +location / { + try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args; +} +location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ { + try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1; +} +location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass hhvm; +} diff --git a/ee/cli/templates/wpfc-hhvm.mustache b/ee/cli/templates/wpfc-hhvm.mustache new file mode 100644 index 00000000..54255c4f --- /dev/null +++ b/ee/cli/templates/wpfc-hhvm.mustache @@ -0,0 +1,36 @@ +# WPFC NGINX CONFIGURATION +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +set $skip_cache 0; +# POST requests and URL with a query string should always go to php +if ($request_method = POST) { + set $skip_cache 1; +} +if ($query_string != "") { + set $skip_cache 1; +} +# Don't cache URL containing the following segments +if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { + set $skip_cache 1; +} +# Don't use the cache for logged in users or recent commenter +if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { + set $skip_cache 1; +} +# Use cached or actual file if they exists, Otherwise pass request to WordPress +location / { + try_files $uri $uri/ /index.php?$args; +} +location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ { + try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1; +} +location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass hhvm; + fastcgi_cache_bypass $skip_cache; + fastcgi_no_cache $skip_cache; + fastcgi_cache WORDPRESS; +} +location ~ /purge(/.*) { + fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1"; +} diff --git a/ee/cli/templates/wpsc-hhvm.mustache b/ee/cli/templates/wpsc-hhvm.mustache new file mode 100644 index 00000000..29e9ebd9 --- /dev/null +++ b/ee/cli/templates/wpsc-hhvm.mustache @@ -0,0 +1,31 @@ +# WPSC NGINX CONFIGURATION +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +set $cache_uri $request_uri; +# POST requests and URL with a query string should always go to php +if ($request_method = POST) { + set $cache_uri 'null cache'; +} +if ($query_string != "") { + set $cache_uri 'null cache'; +} +# Don't cache URL containing the following segments +if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { + set $cache_uri 'null cache'; +} +# Don't use the cache for logged in users or recent commenter +if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { + set $cache_uri 'null cache'; +} +# Use cached or actual file if they exists, Otherwise pass request to WordPress +location / { + # If we add index.php?$args its break WooCommerce like plugins + # Ref: #330 + try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php; +} +location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass hhvm; + # Following line is needed by WP Super Cache plugin + fastcgi_param SERVER_NAME $http_host; +} diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 115d1797..496e1672 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -218,6 +218,7 @@ class EEFileUtils(): for line in open(fnm, encoding='utf-8'): if sstr in line: return line + return False except OSError as e: Log.debug(self, "{0}".format(e.strerror)) Log.error(self, "Unable to Search string {0} in {1}" diff --git a/ee/core/sendmail.py b/ee/core/sendmail.py new file mode 100644 index 00000000..21d6cadf --- /dev/null +++ b/ee/core/sendmail.py @@ -0,0 +1,33 @@ +import smtplib +import os +from email.mime.multipart import MIMEMultipart +from email.mime.base import MIMEBase +from email.mime.text import MIMEText +from email.utils import COMMASPACE, formatdate +from email import encoders + + +def EESendMail(send_from, send_to, subject, text, files, server="localhost", + port=587, username='', password='', isTls=True): + msg = MIMEMultipart() + msg['From'] = send_from + msg['To'] = send_to + msg['Date'] = formatdate(localtime=True) + msg['Subject'] = subject + + msg.attach(MIMEText(text)) + + for f in files: + part = MIMEBase('application', "octet-stream") + part.set_payload(open(f, "rb").read()) + encoders.encode_base64(part) + part.add_header('Content-Disposition', 'attachment; filename="{0}"' + .format(os.path.basename(f))) + msg.attach(part) + + smtp = smtplib.SMTP(server, port) + if isTls: + smtp.starttls() + + smtp.sendmail(send_from, send_to, msg.as_string()) + smtp.quit() diff --git a/ee/core/variables.py b/ee/core/variables.py index f2787fff..ad4bb914 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.10" + ee_version = "3.1.0" # EasyEngine packages versions ee_wp_cli = "0.18.0" @@ -73,7 +73,7 @@ class EEVariables(): elif ee_platform_distro == 'debian': ee_nginx_repo = ("deb http://packages.dotdeb.org {codename} all" .format(codename=ee_platform_codename)) - ee_nginx = ["nginx-full", "nginx-common"] + ee_nginx = ["nginx-extras", "nginx-common"] # PHP repo and packages if ee_platform_distro == 'Ubuntu': @@ -116,6 +116,20 @@ class EEVariables(): "arj", "zoo", "nomarch", "lzop", "cabextract", "p7zip", "rpm", "unrar-free"] + # HHVM repo details + # 12.04 requires boot repository + if ee_platform_distro == 'Ubuntu': + if ee_platform_codename == "precise": + ee_boost_repo = ("ppa:mapnik/boost") + + ee_hhvm_repo = ("deb http://dl.hhvm.com/ubuntu {codename} main" + .format(codename=ee_platform_codename)) + else: + ee_hhvm_repo = ("deb http://dl.hhvm.com/debian {codename} main" + .format(codename=ee_platform_codename)) + + ee_hhvm = ["hhvm"] + # Repo path ee_repo_file = "ee-repo.list" ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file) diff --git a/install b/install index 2c3ce1ce..ce09d564 100644 --- a/install +++ b/install @@ -48,7 +48,7 @@ fi # Define variables for later use ee_branch=$1 readonly ee_version_old="2.2.3" -readonly ee_version_new="3.0.10" +readonly ee_version_new="3.1.0" readonly ee_log_dir=/var/log/ee/ readonly ee_install_log=/var/log/ee/install.log readonly ee_linux_distro=$(lsb_release -i | awk '{print $3}') @@ -89,9 +89,9 @@ function ee_install_dep() { ee_lib_echo "Installing required packages, please wait..." if [ "$ee_linux_distro" == "Ubuntu" ]; then - apt-get -y install gcc gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar python-software-properties software-properties-common || ee_lib_error "Unable to install pre depedencies, exit status " 1 + apt-get -y install gcc curl gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar python-software-properties software-properties-common || ee_lib_error "Unable to install pre depedencies, exit status " 1 elif [ "$ee_linux_distro" == "Debian" ]; then - apt-get -y install gcc gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar python-software-properties || ee_lib_error "Unable to pre depedencies, exit status " 1 + apt-get -y install gcc curl gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar python-software-properties || ee_lib_error "Unable to pre depedencies, exit status " 1 fi # Generating Locale @@ -222,7 +222,6 @@ function secure_ee_db() chmod -R 600 /var/lib/ee/ } - # Install EasyEngine 3.x function ee_install() { diff --git a/setup.py b/setup.py index 2d831432..27683658 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.10', + version='3.1.0', description=long_description, long_description=long_description, classifiers=[],