diff --git a/.travis.yml b/.travis.yml index 2c09927d..46c38ee8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ script: - 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 - - sudo python3 setup.py install + - sudo bash install $TRAVIS_BRANCH - sudo ee --help - sudo ee stack install - sudo ee stack install --web @@ -64,10 +64,10 @@ script: - sudo ee site create site12.in --wpfc --wpsubdomain - sudo ee site create site12.net --wpfc --wpsubdomain - - sudo ee debug - - sudo ee debug --stop + - sudo ee debug --all + - sudo ee debug --all=off - sudo ee debug site12.net - - sudo ee debug site12.net --stop + - sudo ee debug site12.net --all=off - sudo ee site create 1.com --html - sudo ee site create 2.com --php - sudo ee site create 3.com --mysql @@ -88,6 +88,11 @@ script: - sudo ee site update site9.com --wpsubdomain --w3tc - sudo ee site update site9.com --wpsubdomain --wpsc + - sudo ee site create www.site-1.com --wp + - sudo ee site create www.subsite.site-1.com --wpfc + - sudo ee site update www.subsite.site-1.com --wp + - sudo ee site delete www.subsite.site-1.com --all --no-prompt + - 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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 20a1eab6..6d391bc4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,13 @@ -# Contribute to EasyEngine (ee) +# Community Guidelines -This guide details how to use issues and pull requests to improve EasyEngine (ee). +This guide details how to get involve in EasyEngine commmunity. Please read this carefully. -## How to report issue: -Github issue-tracker is used **only** for report bugs and feature request. -Please attach the output of following command when open a new issue/bug +## How to get help? + +Please attach the output of following command when open a new support request. + ```bash lsb_release -a ee -v @@ -14,13 +15,22 @@ ee info wp --allow-root --info ``` -### EasyEngine chat: -Developer & contributor discussion: https://gitter.im/rtCamp/easyengine +### Where to create issue? + +For free support, please use - http://community.rtcamp.com/c/easyengine + +For premium support, please check - https://rtcamp.com/products/easyengine-premium-support/ +Please do NOT clutter github issue tracker here with support requests. It hampers development speed of this project. -### EasyEngine support request: -For support-request please use - http://community.rtcamp.com/c/easyengine +### Pull Requests -### Pull Requests: When submitting your code please follow this coding standerds - http://docs.rtcamp.com/easyengine/dev/python/ + + +### EasyEngine Chat + +Developer & contributor discussion: https://gitter.im/rtCamp/easyengine + +Please do NOT use chat for technical support. Chat is limited to developer & contributor disucssion related to EasyEngine future. diff --git a/README.md b/README.md index 41162820..c99093a3 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,7 @@ -IMPORTANT -============================================ - -#### We are looking for [Python Developers] (https://rtcamp.com/careers/python-developer/) to join our team. We offer work from home, so you can join EasyEngine team anywhere! _[Why Python?] (https://rtcamp.com/blog/easyengine-3-roadmap/#whypython)_ - ---- - -[![Stories in Ready](https://badge.waffle.io/rtcamp/easyengine.png?label=ready&title=Ready)](https://waffle.io/rtcamp/easyengine) -[![Stories in Progress](https://badge.waffle.io/rtcamp/easyengine.png?label=in%20progress&title=In%20Progress)](https://waffle.io/rtcamp/easyengine) - -EasyEngine Logo - [![Travis Build Status](https://travis-ci.org/rtCamp/easyengine.svg "Travis Build Status")] (https://travis-ci.org/rtCamp/easyengine) +[![Join the chat at https://gitter.im/rtCamp/easyengine](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rtCamp/easyengine?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +EasyEngine Logo EasyEngine (ee) is a python tool, which makes it easy to manage your wordpress sites running on nginx web-server. @@ -92,5 +83,13 @@ ee site create example.com --mysql # create example.com with php & mysql supp [![Donate](https://cloud.githubusercontent.com/assets/4115/5297691/c7b50292-7bd7-11e4-987b-2dc21069e756.png)] (https://rtcamp.com/donate/?project=easyengine) +## Careers + +We are looking for [Python Developers] (https://rtcamp.com/careers/python-developer/) to join our team. + +We offer work from home, so you can join EasyEngine team anywhere! _[Why Python?] (https://rtcamp.com/blog/easyengine-3-roadmap/#whypython)_ + +--- + ## License [MIT] (http://opensource.org/licenses/MIT) diff --git a/config/bash_completion.d/ee_auto.rc b/config/bash_completion.d/ee_auto.rc index d7238ba7..8f8608bd 100644 --- a/config/bash_completion.d/ee_auto.rc +++ b/config/bash_completion.d/ee_auto.rc @@ -29,13 +29,13 @@ _ee_complete() # IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE "debug") COMPREPLY=( $(compgen \ - -W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --start --nginx --php --fpm --mysql -i --interactive --stop " \ + -W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql -i --interactive --all --nginx=off --php=off --fpm=off --mysql=off --all=off " \ -- $cur) ) ;; "stack") COMPREPLY=( $(compgen \ - -W "install purge reload remove restart start status stop" \ + -W "install purge reload remove restart start status stop migrate" \ -- $cur) ) ;; @@ -59,7 +59,7 @@ _ee_complete() "log") COMPREPLY=( $(compgen \ - -W "--mysql --php --nginx --all" \ + -W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --mysql --php --nginx --all" \ -- $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" \ + -W "--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot --all" \ -- $cur) ) ;; "start" | "stop" | "reload" | "restart" | "status") @@ -82,7 +82,11 @@ _ee_complete() -W "--nginx --php --mysql --postfix --memcache --dovecot" \ -- $cur) ) ;; - + "migrate") + COMPREPLY=( $(compgen \ + -W "--mariadb" \ + -- $cur) ) + ;; "list") COMPREPLY=( $(compgen \ -W "--enabled --disabled" \ @@ -106,13 +110,22 @@ _ee_complete() esac if [ ${COMP_WORDS[1]} == "debug" ] && ([ "$prev" != "--start" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]); then - retlist="--start --stop --wp --rewrite -i" + 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 case "$mprev" in # HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE @@ -141,9 +154,16 @@ _ee_complete() case "$prev" in "--wp" | "--wpsubdir" | "--wpsubdomain") - COMPREPLY=( $(compgen \ - -W "--w3tc --wpfc --wpsc" \ - -- $cur) ) + if [ ${COMP_WORDS[1]} != "debug" ]; then + retlist="--w3tc --wpfc --wpsc" + else + retlist="--wp=off --rewrite --rewrite=off -i --interactive" + fi + + ret="${retlist[@]/$prev}" + COMPREPLY=( $(compgen \ + -W "$(echo $ret)" \ + -- $cur) ) ;; "--web" | "--admin" | "--mail" | "--nginx" | "--php" | "--mysql" | "--postfix" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--memcache" | "--dovecot") diff --git a/ee/cli/ext/ee_outputhandler.py b/ee/cli/ext/ee_outputhandler.py new file mode 100644 index 00000000..89e397d4 --- /dev/null +++ b/ee/cli/ext/ee_outputhandler.py @@ -0,0 +1,20 @@ +# 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) +import os +from cement.utils import fs +from cement.ext.ext_mustache import MustacheOutputHandler + + +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 diff --git a/ee/cli/main.py b/ee/cli/main.py index ef828f51..f3b89d88 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -13,10 +13,9 @@ 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 cement.ext.ext_argparse import ArgParseArgumentHandler from ee.core import exc - +from ee.cli.ext.ee_outputhandler import EEOutputHandler # Application default. Should update config/ee.conf to reflect any # changes, or additions here. @@ -31,22 +30,12 @@ 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' - -# 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 EEArgHandler(ArgParseArgumentHandler): class Meta: - label = 'ee_output_handler' + label = 'ee_args_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 + def error(self, message): + super(EEArgHandler, self).error("unknown args") class EEApp(foundation.CementApp): @@ -72,6 +61,8 @@ class EEApp(foundation.CementApp): # default output handler output_handler = EEOutputHandler + arg_handler = EEArgHandler + debug = TOGGLE_DEBUG diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 5440bb2b..58c267b6 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -14,6 +14,27 @@ import glob import signal import subprocess +usage = """ +Usage: ee debug {} {arguments} + +arguments usage: +--all --all=on start debugging all server parameters. +--all=off stop debugging all server parameters +--nginx --nginx=on start debugging nginx server configuration for site +--nginx=off stop debugging nginx server configuration for site +--rewrite --rewrite=on start debugging nginx rewrite rules for site +--rewrite=off stop debugging nginx rewrite rules for site +--php --php=on start debugging server php configuration +--php=off stop debugging server php configuration +--fpm --fpm=on start debugging fastcgi configuration +--fpm=off stop debugging fastcgi configuration +--mysql --mysql=on start debugging mysql server +--mysql=off stop debugging mysql server +--wp --wp=on start wordpress debugging +--wp=off stop wordpress debugging + +""" + def debug_plugin_hook(app): # do something with the ``app`` object here. @@ -32,17 +53,34 @@ class EEDebugController(CementBaseController): (['--start'], dict(help='Start debug', action='store_true')), (['--nginx'], - dict(help='Debug Nginx', action='store_true')), + dict(help='start/stop debugging nginx server ' + 'configuration for site', + action='store' or 'store_const', + choices=('on', 'off'), const='on', nargs='?')), (['--php'], - dict(help='Debug PHP', action='store_true')), + dict(help='start/stop debugging server php configuration', + action='store' or 'store_const', + choices=('on', 'off'), const='on', nargs='?')), (['--fpm'], - dict(help='Debug FastCGI', action='store_true')), + dict(help='start/stop debugging fastcgi configuration', + action='store' or 'store_const', + choices=('on', 'off'), const='on', nargs='?')), (['--mysql'], - dict(help='Debug MySQL', action='store_true')), + dict(help='start/stop debugging mysql server', + action='store' or 'store_const', + choices=('on', 'off'), const='on', nargs='?')), (['--wp'], - dict(help='Debug WordPress sites', action='store_true')), + dict(help='start/stop wordpress debugging for site', + action='store' or 'store_const', choices=('on', 'off'), + const='on', nargs='?')), (['--rewrite'], - dict(help='Debug Nginx rewrite rules', action='store_true')), + dict(help='start/stop debugging nginx rewrite rules for site', + action='store' or 'store_const', choices=('on', 'off'), + const='on', nargs='?')), + (['--all'], + dict(help='start/stop debugging all server parameters', + action='store' or 'store_const', choices=('on', 'off'), + const='on', nargs='?')), (['-i', '--interactive'], dict(help='Interactive debug', action='store_true')), (['--import-slow-log-interval'], @@ -56,7 +94,7 @@ class EEDebugController(CementBaseController): def debug_nginx(self): """Start/Stop Nginx debug""" # start global debug - if self.start and not self.app.pargs.site_name: + if (self.app.pargs.nginx == 'on' and not self.app.pargs.site_name): try: debug_address = (self.app.config.get('stack', 'ip-address') .split()) @@ -79,7 +117,7 @@ class EEDebugController(CementBaseController): self.msg = self.msg + ["/var/log/nginx/*.error.log"] # stop global debug - elif not self.start and not self.app.pargs.site_name: + elif (self.app.pargs.nginx == 'off' and not self.app.pargs.site_name): if "debug_connection " in open('/etc/nginx/nginx.conf', encoding='utf-8').read(): Log.info(self, "Disabling Nginx debug connections") @@ -90,7 +128,7 @@ class EEDebugController(CementBaseController): Log.info(self, "Nginx debug connection already disabled") # start site specific debug - elif self.start and self.app.pargs.site_name: + elif (self.app.pargs.nginx == 'on'and self.app.pargs.site_name): config_path = ("/etc/nginx/sites-available/{0}" .format(self.app.pargs.site_name)) if os.path.isfile(config_path): @@ -115,7 +153,7 @@ class EEDebugController(CementBaseController): .format(self.app.pargs.site_name)) # stop site specific debug - elif not self.start and self.app.pargs.site_name: + elif (self.app.pargs.nginx == 'off' and self.app.pargs.site_name): config_path = ("/etc/nginx/sites-available/{0}" .format(self.app.pargs.site_name)) if os.path.isfile(config_path): @@ -139,7 +177,7 @@ class EEDebugController(CementBaseController): def debug_php(self): """Start/Stop PHP debug""" # PHP global debug start - if self.start: + if (self.app.pargs.php == 'on' and not self.app.pargs.site_name): if not (EEShellExec.cmd_exec(self, "sed -n \"/upstream php" "{/,/}/p \" /etc/nginx/" "conf.d/upstream.conf " @@ -160,7 +198,7 @@ class EEDebugController(CementBaseController): self.msg = self.msg + ['/var/log/php5/slow.log'] # PHP global debug stop - else: + elif (self.app.pargs.php == 'off' and not self.app.pargs.site_name): if EEShellExec.cmd_exec(self, " sed -n \"/upstream php {/,/}/p\" " "/etc/nginx/conf.d/upstream.conf " "| grep 9001"): @@ -181,7 +219,7 @@ class EEDebugController(CementBaseController): def debug_fpm(self): """Start/Stop PHP5-FPM debug""" # PHP5-FPM start global debug - if self.start: + if (self.app.pargs.php == 'on'and not self.app.pargs.site_name): if not EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " "/etc/php5/fpm/php-fpm.conf"): Log.info(self, "Setting up PHP5-FPM log_level = debug") @@ -202,7 +240,7 @@ class EEDebugController(CementBaseController): self.msg = self.msg + ['/var/log/php5/fpm.log'] # PHP5-FPM stop global debug - else: + elif (self.app.pargs.php == 'on' and not self.app.pargs.site_name): if EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " "/etc/php5/fpm/php-fpm.conf"): Log.info(self, "Disabling PHP5-FPM log_level = debug") @@ -225,7 +263,7 @@ class EEDebugController(CementBaseController): def debug_mysql(self): """Start/Stop MySQL debug""" # MySQL start global debug - if self.start: + if (self.app.pargs.mysql == 'on' and not self.app.pargs.site_name): if not EEShellExec.cmd_exec(self, "mysql -e \"show variables like" " \'slow_query_log\';\" | " "grep ON"): @@ -258,7 +296,7 @@ class EEDebugController(CementBaseController): self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] # MySQL stop global debug - else: + elif (self.app.pargs.mysql == 'off' and not self.app.pargs.site_name): if EEShellExec.cmd_exec(self, "mysql -e \"show variables like \'" "slow_query_log\';\" | grep ON"): Log.info(self, "Disabling MySQL slow log") @@ -276,7 +314,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_wp(self): """Start/Stop WordPress debug""" - if self.start and self.app.pargs.site_name: + if (self.app.pargs.wp == 'on' and self.app.pargs.site_name): wp_config = ("{0}/{1}/wp-config.php" .format(EEVariables.ee_webroot, self.app.pargs.site_name)) @@ -316,7 +354,7 @@ class EEDebugController(CementBaseController): Log.info(self, "{0} domain not valid" .format(self.app.pargs.site_name)) - elif not self.start and self.app.pargs.site_name: + elif (self.app.pargs.wp == 'off' and self.app.pargs.site_name): wp_config = ("{0}{1}/wp-config.php" .format(EEVariables.ee_webroot, self.app.pargs.site_name)) @@ -347,7 +385,7 @@ class EEDebugController(CementBaseController): def debug_rewrite(self): """Start/Stop Nginx rewrite rules debug""" # Start Nginx rewrite debug globally - if self.start and not self.app.pargs.site_name: + if (self.app.pargs.rewrite == 'on' and not self.app.pargs.site_name): if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" " "/etc/nginx/nginx.conf"): Log.info(self, "Setting up Nginx rewrite logs") @@ -361,7 +399,8 @@ class EEDebugController(CementBaseController): self.msg = self.msg + ['/var/log/nginx/*.error.log'] # Stop Nginx rewrite debug globally - elif not self.start and not self.app.pargs.site_name: + elif (self.app.pargs.rewrite == 'off' + and not self.app.pargs.site_name): if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" " "/etc/nginx/nginx.conf"): Log.info(self, "Disabling Nginx rewrite logs") @@ -371,7 +410,7 @@ class EEDebugController(CementBaseController): else: Log.info(self, "Nginx rewrite logs already disabled") # Start Nginx rewrite for site - elif self.start and self.app.pargs.site_name: + elif (self.app.pargs.rewrite == 'on' and self.app.pargs.site_name): config_path = ("/etc/nginx/sites-available/{0}" .format(self.app.pargs.site_name)) if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" @@ -394,7 +433,7 @@ class EEDebugController(CementBaseController): self.app.pargs.site_name)] # Stop Nginx rewrite for site - elif not self.start and self.app.pargs.site_name: + elif (self.app.pargs.rewrite == 'off' and self.app.pargs.site_name): config_path = ("/etc/nginx/sites-available/{0}" .format(self.app.pargs.site_name)) if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" @@ -442,32 +481,48 @@ class EEDebugController(CementBaseController): @expose(hide=True) def default(self): """Default function of debug""" - self.start = True + # self.start = True self.interactive = False self.msg = [] self.trigger_nginx = False self.trigger_php = False - if self.app.pargs.stop: - self.start = False - 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 (not self.app.pargs.all) and (not self.app.pargs.site_name)): - 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 self.app.pargs.stop or self.app.pargs.start: + print("--start/stop option is deprecated in ee3.0.5", usage) + else: + print(usage) + + if self.app.pargs.all == 'on': + if self.app.pargs.site_name: + self.app.pargs.wp = 'on' + self.app.pargs.nginx = 'on' + self.app.pargs.php = 'on' + self.app.pargs.fpm = 'on' + self.app.pargs.mysql = 'on' + self.app.pargs.rewrite = 'on' + + if self.app.pargs.all == 'off': + if self.app.pargs.site_name: + self.app.pargs.wp = 'off' + self.app.pargs.nginx = 'off' + self.app.pargs.php = 'off' + self.app.pargs.fpm = 'off' + self.app.pargs.mysql = 'off' + self.app.pargs.rewrite = 'off' 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.app.pargs.nginx = True - self.app.pargs.wp = True - self.app.pargs.rewrite = True + print(usage) + # self.app.pargs.nginx = 'on' + # self.app.pargs.wp = 'on' + # self.app.pargs.rewrite = 'on' if self.app.pargs.nginx: self.debug_nginx() diff --git a/ee/cli/plugins/log.py b/ee/cli/plugins/log.py index aa253cbd..6b5b3038 100644 --- a/ee/cli/plugins/log.py +++ b/ee/cli/plugins/log.py @@ -5,6 +5,8 @@ from cement.core import handler, hook from ee.core.logging import Log 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 import os import glob @@ -24,11 +26,22 @@ class EELogController(CementBaseController): (['--all'], dict(help='Show All logs file', action='store_true')), (['--nginx'], - dict(help='Show Nginx logs file', action='store_true')), + dict(help='Show Nginx Error logs file', action='store_true')), (['--php'], - dict(help='Show PHP logs file', action='store_true')), + dict(help='Show PHP Error logs file', action='store_true')), + (['--fpm'], + dict(help='Show PHP5-fpm slow logs file', + action='store_true')), (['--mysql'], dict(help='Show MySQL logs file', action='store_true')), + (['--wp'], + dict(help='Show Site specific WordPress logs file', + action='store_true')), + (['--access'], + dict(help='Show Nginx access log file', + action='store_true')), + (['site_name'], + dict(help='Website Name', nargs='?', default=None)) ] @expose(hide=True) @@ -36,15 +49,32 @@ class EELogController(CementBaseController): """Default function of debug""" self.msg = [] - if ((not self.app.pargs.nginx) and (not self.app.pargs.php) - and (not self.app.pargs.mysql)): + 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.php = True + self.app.pargs.wp = True + self.app.pargs.access = True self.app.pargs.mysql = True - if self.app.pargs.nginx: + 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.php: + + 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', @@ -62,6 +92,40 @@ class EELogController(CementBaseController): Log.warn(self, "Remote MySQL found, EasyEngine is not able to" "show MySQL log file") + if self.app.pargs.site_name: + 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: + 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' + .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)] watch_list = [] for w_list in self.msg: watch_list = watch_list + glob.glob(w_list) diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index c7007bb9..09df15f2 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -4,6 +4,7 @@ from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables from ee.core.logging import Log from ee.core.git import EEGit +from ee.core.services import EEService import string import random import sys @@ -103,7 +104,7 @@ class EESecureController(CementBaseController): .format(port=self.app.pargs.user_input)) EEGit.add(self, ["/etc/nginx"], msg="Adding changed secure port into Git") - + EEService.reload_service(self, 'nginx') Log.info(self, "Successfully port changed {port}" .format(port=self.app.pargs.user_input)) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 1d3cbaa5..8e86dfb6 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -522,7 +522,7 @@ class EESiteCreateController(CementBaseController): .format(ee_wp_creds['wp_pass']), log=False) display_cache_settings(self, data) - addNewSite(self, ee_www_domain, stype, cache, ee_site_webroot) + addNewSite(self, ee_domain, stype, cache, ee_site_webroot) Log.info(self, "Successfully created site" " http://{0}".format(ee_domain)) @@ -982,7 +982,7 @@ class EESiteUpdateController(CementBaseController): " {0}".format(ee_wp_creds['wp_user'])) Log.info(self, Log.ENDC + "WordPress admin password : {0}" .format(ee_wp_creds['wp_pass']) + "\n\n") - updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache) + updateSiteInfo(self, ee_domain, stype=stype, cache=cache) Log.info(self, "Successfully updated site" " http://{0}".format(ee_domain)) @@ -1071,6 +1071,8 @@ class EESiteDeleteController(CementBaseController): if (ee_nginx_prompt == 'Y' or ee_nginx_prompt == 'y'): Log.debug(self, "Removing Nginx configuration") + EEFileUtils.rm(self, '/etc/nginx/sites-enabled/{0}' + .format(ee_domain)) EEFileUtils.rm(self, '/etc/nginx/sites-available/{0}' .format(ee_domain)) EEGit.add(self, ["/etc/nginx"], diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 95347ec7..b2bfb952 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -26,6 +26,7 @@ import pwd import grp import codecs from ee.cli.plugins.stack_services import EEStackStatusController +from ee.cli.plugins.stack_migrate import EEStackMigrateController from ee.core.logging import Log @@ -86,29 +87,34 @@ class EEStackController(CementBaseController): " $(hostname -f)\" | debconf-set-selections") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): - Log.info(self, "Adding repository for MySQL") + Log.info(self, "Adding repository for MySQL, please wait ...") + mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au" + "\nPin-Priority: 1000\n") + with open('/etc/apt/preferences.d/' + 'MariaDB.pref', 'w') as mysql_pref_file: + mysql_pref_file.write(mysql_pref) EERepo.add(self, repo_url=EEVariables.ee_mysql_repo) Log.debug(self, 'Adding key for {0}' .format(EEVariables.ee_mysql_repo)) - EERepo.add_key(self, '1C4CBDCDCD2EFD2A', + EERepo.add_key(self, '0xcbcb082a1bb943db', keyserver="keyserver.ubuntu.com") chars = ''.join(random.sample(string.ascii_letters, 8)) Log.debug(self, "Pre-seeding MySQL") - Log.debug(self, "echo \"percona-server-server-5.6 " - "percona-server-server/root_password " + Log.debug(self, "echo \"mariadb-server-10.0 " + "mysql-server/root_password " "password \" | " "debconf-set-selections") - EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " - "percona-server-server/root_password " + EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 " + "mysql-server/root_password " "password {chars}\" | " "debconf-set-selections".format(chars=chars), log=False) - Log.debug(self, "echo \"percona-server-server-5.6 " - "percona-server-server/root_password_again " + Log.debug(self, "echo \"mariadb-server-10.0 " + "mysql-server/root_password_again " "password \" | " "debconf-set-selections") - EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " - "percona-server-server/root_password_again " + EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 " + "mysql-server/root_password_again " "password {chars}\" | " "debconf-set-selections".format(chars=chars), log=False) @@ -125,7 +131,7 @@ class EEStackController(CementBaseController): config.write(configfile) if set(EEVariables.ee_nginx).issubset(set(apt_packages)): - Log.info(self, "Adding repository for Nginx") + Log.info(self, "Adding repository for NGINX, please wait ...") if EEVariables.ee_platform_distro == 'debian': Log.debug(self, 'Adding Dotdeb/nginx GPG key') EERepo.add(self, repo_url=EEVariables.ee_nginx_repo) @@ -134,7 +140,7 @@ class EEStackController(CementBaseController): Log.debug(self, 'Adding ppa of Nginx') if set(EEVariables.ee_php).issubset(set(apt_packages)): - Log.info(self, "Adding repository for PHP") + Log.info(self, "Adding repository for PHP, please wait ...") if EEVariables.ee_platform_distro == 'debian': Log.debug(self, 'Adding repo_url of php for debian') EERepo.add(self, repo_url=EEVariables.ee_php_repo) @@ -146,7 +152,8 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_mail).issubset(set(apt_packages)): if EEVariables.ee_platform_codename == 'squeeze': - Log.info(self, "Adding repository for dovecot ") + Log.info(self, "Adding repository for dovecot, " + "please wait ...") EERepo.add(self, repo_url=EEVariables.ee_dovecot_repo) Log.debug(self, 'Executing the command debconf-set-selections.') EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core/" @@ -539,6 +546,15 @@ class EEStackController(CementBaseController): "/dovecot.pem") # Custom Dovecot configuration by EasyEngine + data = dict() + Log.debug(self, "Writting configuration into file" + "/etc/dovecot/conf.d/auth-sql.conf.ext ") + ee_dovecot = open('/etc/dovecot/conf.d/auth-sql.conf.ext', + encoding='utf-8', mode='w') + self.app.render((data), 'auth-sql-conf.mustache', + out=ee_dovecot) + ee_dovecot.close() + data = dict(email=EEVariables.ee_email) Log.debug(self, "Writting configuration into file" "/etc/dovecot/conf.d/99-ee.conf ") @@ -1308,8 +1324,9 @@ class EEStackController(CementBaseController): self.pre_pref(apt_packages) if len(apt_packages): EESwap.add(self) - Log.info(self, "Updating apt-cache") + Log.info(self, "Updating apt-cache, please wait ...") EEAptGet.update(self) + Log.info(self, "Installing packages, please wait ...") EEAptGet.install(self, apt_packages) if len(packages): Log.debug(self, "Downloading following: {0}".format(packages)) @@ -1412,6 +1429,7 @@ class EEStackController(CementBaseController): 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 len(packages): @@ -1507,6 +1525,7 @@ class EEStackController(CementBaseController): ] if len(apt_packages): + Log.info(self, "Uninstalling packages, please wait ...") EEAptGet.remove(self, apt_packages, purge=True) EEAptGet.auto_remove(self) if len(packages): @@ -1519,6 +1538,7 @@ def load(app): # register the plugin class.. this only happens if the plugin is enabled handler.register(EEStackController) handler.register(EEStackStatusController) + handler.register(EEStackMigrateController) # register a hook (function) to run after arguments are parsed. hook.register('post_argument_parsing', ee_stack_hook) diff --git a/ee/cli/plugins/stack_migrate.py b/ee/cli/plugins/stack_migrate.py new file mode 100644 index 00000000..e5cfa38c --- /dev/null +++ b/ee/cli/plugins/stack_migrate.py @@ -0,0 +1,124 @@ +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook +from ee.core.mysql import EEMysql +from ee.core.logging import Log +from ee.core.variables import EEVariables +from ee.core.aptget import EEAptGet +from ee.core.shellexec import EEShellExec +from ee.core.apt_repo import EERepo +from ee.core.services import EEService +import configparser +import os + + +class EEStackMigrateController(CementBaseController): + class Meta: + label = 'migrate' + stacked_on = 'stack' + stacked_type = 'nested' + description = ('Migrate stack safely') + arguments = [ + (['--mariadb'], + dict(help="Migrate database to MariaDB", + action='store_true')), + # (['--PHP'], + # dict(help="update to html site", action='store_true')), + ] + + @expose(hide=True) + def migrate_mariadb(self): + # Backup all database + EEMysql.backupAll(self) + + # Add MariaDB repo + Log.info(self, "Adding repository for MariaDB, please wait ...") + + mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au" + "\nPin-Priority: 1000\n") + with open('/etc/apt/preferences.d/' + 'MariaDB.pref', 'w') as mysql_pref_file: + mysql_pref_file.write(mysql_pref) + + EERepo.add(self, repo_url=EEVariables.ee_mysql_repo) + Log.debug(self, 'Adding key for {0}' + .format(EEVariables.ee_mysql_repo)) + EERepo.add_key(self, '0xcbcb082a1bb943db', + keyserver="keyserver.ubuntu.com") + + config = configparser.ConfigParser() + config.read(os.path.expanduser("~")+'/.my.cnf') + try: + chars = config['client']['password'] + except Exception as e: + Log.error(self, "Error: process exited with error %s" + % e) + + Log.debug(self, "Pre-seeding MariaDB") + Log.debug(self, "echo \"mariadb-server-10.0 " + "mysql-server/root_password " + "password \" | " + "debconf-set-selections") + EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 " + "mysql-server/root_password " + "password {chars}\" | " + "debconf-set-selections" + .format(chars=chars), + log=False) + Log.debug(self, "echo \"mariadb-server-10.0 " + "mysql-server/root_password_again " + "password \" | " + "debconf-set-selections") + EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 " + "mysql-server/root_password_again " + "password {chars}\" | " + "debconf-set-selections" + .format(chars=chars), + log=False) + + # Install MariaDB + apt_packages = EEVariables.ee_mysql + + # If PHP is installed then install php5-mysql + if EEAptGet.is_installed(self, "php5-fpm"): + apt_packages = apt_packages + ["php5-mysql"] + + # If mail server is installed then install dovecot-sql and postfix-sql + if EEAptGet.is_installed(self, "dovecot-core"): + apt_packages = apt_packages + ["dovecot-mysql", "postfix-mysql", + "libclass-dbi-mysql-perl"] + + Log.info(self, "Updating apt-cache, please wait ...") + EEAptGet.update(self) + Log.info(self, "Installing MariaDB, please wait ...") + EEAptGet.remove(self, ["mysql-common", "libmysqlclient18"]) + EEAptGet.auto_remove(self) + EEAptGet.install(self, apt_packages) + + # Restart dovecot and postfix if installed + if EEAptGet.is_installed(self, "dovecot-core"): + EEService.restart_service(self, 'dovecot') + EEService.restart_service(self, 'postfix') + + @expose(hide=True) + def default(self): + if ((not self.app.pargs.mariadb)): + self.app.args.print_help() + if self.app.pargs.mariadb: + if EEVariables.ee_mysql_host is not "localhost": + Log.error(self, "Remote MySQL found, EasyEngine will not " + "install MariaDB") + + if EEShellExec.cmd_exec(self, "mysqladmin ping") and (not + EEAptGet.is_installed(self, 'mariadb-server')): + + Log.info(self, "If your database size is big, " + "migration may take some time.") + Log.info(self, "During migration non nginx-cached parts of " + "your site may remain down") + start_migrate = input("Type \"mariadb\" to continue:") + if start_migrate != "mariadb": + Log.error(self, "Not starting migration") + self.migrate_mariadb() + else: + Log.error(self, "Your current MySQL is not alive or " + "you allready installed MariaDB") diff --git a/ee/core/aptget.py b/ee/core/aptget.py index c9ea0b35..5eff0cf7 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -2,6 +2,7 @@ import apt import apt_pkg import sys +import subprocess from ee.core.logging import Log from sh import apt_get from sh import ErrorReturnCode @@ -15,23 +16,21 @@ class EEAptGet(): Similar to `apt-get upgrade` """ try: - apt_cache = apt.cache.Cache() - import sys - orig_out = sys.stdout - sys.stdout = open(self.app.config.get('log.logging', 'file'), - encoding='utf-8', mode='a') - apt_cache.update(apt.progress.text.AcquireProgress()) - sys.stdout = orig_out - # success = (apt_cache.commit( - # apt.progress.text.AcquireProgress(), - # apt.progress.base.InstallProgress())) - # #apt_cache.close() - # return success - except AttributeError as e: - Log.error(self, 'AttributeError: ' + str(e)) + with open('/var/log/ee/ee.log', 'a') as f: + proc = subprocess.Popen('apt-get update', + shell=True, + stdin=None, stdout=f, stderr=f, + executable="/bin/bash") + proc.wait() + + if proc.returncode == 0: + return True + else: + Log.error(self, "Unable to run apt-get update") + except Exception as e: - Log.debug(self, 'SystemError: ' + str(e)) - Log.error(self, 'Unable to Fetch update') + Log.error(self, "Error while installing packages, " + "apt-get exited with error") def dist_upgrade(): """ @@ -54,112 +53,48 @@ class EEAptGet(): Log.error(self, 'Unable to Fetch update') def install(self, packages): - """ - Similar to `apt-get install` - """ - apt_pkg.init() - # #apt_pkg.PkgSystemLock() - global apt_cache - apt_cache = apt.cache.Cache() + all_packages = ' '.join(packages) + try: + with open('/var/log/ee/ee.log', 'a') as f: + proc = subprocess.Popen("apt-get install -o Dpkg::Options::=--" + "force-confold -y {0}" + .format(all_packages), shell=True, + stdin=None, stdout=f, stderr=f, + executable="/bin/bash") + proc.wait() - def install_package(self, package_name): - pkg = apt_cache[package_name.strip()] - if package_name.strip() in apt_cache: - if pkg.is_installed: - # apt_pkg.PkgSystemUnLock() - Log.debug(self, 'Trying to install a package that ' - 'is already installed (' + - package_name.strip() + ')') - # apt_cache.close() - return False - else: - try: - # print(pkg.name) - pkg.mark_install() - except Exception as e: - Log.debug(self, str(e)) - Log.error(self, str(e)) + if proc.returncode == 0: + return True else: - # apt_cache.close() - Log.error(self, 'Unknown package selected (' + - package_name.strip() + ')') + Log.error(self, "Unable to run apt-get install") - for package in packages: - if not install_package(self, package): - continue - - if apt_cache.install_count > 0: - try: - # apt_pkg.PkgSystemUnLock() - orig_out = sys.stdout - sys.stdout = open(self.app.config.get('log.logging', 'file'), - encoding='utf-8', mode='a') - result = apt_cache.commit(apt.progress.text.AcquireProgress(), - apt.progress.base.InstallProgress()) - sys.stdout = orig_out - # apt_cache.close() - return result - except SystemError as e: - Log.debug(self, 'SystemError: ' + str(e)) - Log.error(self, 'SystemError: ' + str(e)) - # apt_cache.close() - except Exception as e: - Log.debug(self, str(e)) - Log.error(self, str(e)) + except Exception as e: + Log.error(self, "Error while installing packages, " + "apt-get exited with error") def remove(self, packages, auto=False, purge=False): - """ - Similar to `apt-get remove/purge` - purge packages if purge=True - """ - apt_pkg.init() - # apt_pkg.PkgSystemLock() - global apt_cache - apt_cache = apt.cache.Cache() - - def remove_package(self, package_name, purge=False): - pkg = apt_cache[package_name.strip()] - if package_name.strip() in apt_cache: - if not pkg.is_installed: - # apt_pkg.PkgSystemUnLock() - Log.debug(self, 'Trying to uninstall a package ' - 'that is not installed (' + - package_name.strip() + ')') - return False + all_packages = ' '.join(packages) + try: + with open('/var/log/ee/ee.log', 'a') as f: + if purge: + proc = subprocess.Popen('apt-get purge -y {0}' + .format(all_packages), shell=True, + stdin=None, stdout=f, stderr=f, + executable="/bin/bash") else: - try: - # print(pkg.name) - pkg.mark_delete(purge) - except SystemError as e: - Log.debug(self, 'SystemError: ' + str(e)) - return False + proc = subprocess.Popen('apt-get remove -y {0}' + .format(all_packages), shell=True, + stdin=None, stdout=f, stderr=f, + executable="/bin/bash") + proc.wait() + if proc.returncode == 0: + return True else: - # apt_cache.close() - Log.error(self, 'Unknown package selected (' + - package_name.strip() + ')') - - for package in packages: - if not remove_package(self, package, purge=purge): - continue + Log.error(self, "Unable to run apt-get remove/purge") - if apt_cache.delete_count > 0: - try: - # apt_pkg.PkgSystemUnLock() - orig_out = sys.stdout - sys.stdout = open(self.app.config.get('log.logging', 'file'), - encoding='utf-8', mode='a') - result = apt_cache.commit(apt.progress.text.AcquireProgress(), - apt.progress.base.InstallProgress()) - sys.stdout = orig_out - # apt_cache.close() - return result - except SystemError as e: - Log.debug(self, 'SystemError: ' + str(e)) - return False - except Exception as e: - Log.debug(self, str(e)) - Log.error(self, str(e)) - # apt_cache.close() + except Exception as e: + Log.error(self, "Error while installing packages, " + "apt-get exited with error") def auto_clean(self): """ diff --git a/ee/core/domainvalidate.py b/ee/core/domainvalidate.py index a9400c9a..2b1fe4a5 100644 --- a/ee/core/domainvalidate.py +++ b/ee/core/domainvalidate.py @@ -18,7 +18,7 @@ def ValidateDomain(url): final_domain = '' if www_domain_name[0] == 'www': final_domain = '.'.join(www_domain_name[1:]) - return final_domain else: final_domain = domain_name - return (final_domain, domain_name) + + return (final_domain, domain_name) diff --git a/ee/core/mysql.py b/ee/core/mysql.py index daf10aec..7c523bf1 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -3,7 +3,9 @@ import pymysql import configparser from os.path import expanduser import sys +import os from ee.core.logging import Log +from ee.core.variables import EEVariables class EEMysql(): @@ -60,7 +62,42 @@ class EEMysql(): else: Log.error(self, '{0}'.format(errormsg)) + def backupAll(self): + import subprocess + try: + Log.info(self, "Backing up database at location: " + "/var/ee-mysqlbackup") + # Setup Nginx common directory + if not os.path.exists('/var/ee-mysqlbackup'): + Log.debug(self, 'Creating directory' + '/var/ee-mysqlbackup') + os.makedirs('/var/ee-mysqlbackup') -# def __del__(self): -# self.cur.close() -# self.conn.close() + db = subprocess.check_output(["mysql -Bse \'show databases\'"], + universal_newlines=True, + shell=True).split('\n') + for dbs in db: + if dbs == "": + continue + Log.info(self, "Backing up {0} database".format(dbs)) + p1 = subprocess.Popen("mysqldump {0}" + " --max_allowed_packet=1024M" + " --single-transaction".format(dbs), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, shell=True) + p2 = subprocess.Popen("gzip -c > /var/ee-mysqlbackup/{0}{1}.s" + "ql.gz".format(dbs, EEVariables.ee_date), + stdin=p1.stdout, + shell=True) + + # Allow p1 to receive a SIGPIPE if p2 exits + p1.stdout.close() + output = p1.stderr.read() + p1.wait() + if p1.returncode == 0: + Log.debug(self, "done") + else: + Log.error(self, output.decode("utf-8")) + except Exception as e: + Log.error(self, "Error: process exited with status %s" + % e) diff --git a/ee/core/variables.py b/ee/core/variables.py index 6df38377..0ed5c8f4 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.4" + ee_version = "3.0.5" # EasyEngine packages versions ee_wp_cli = "0.18.0" @@ -78,21 +78,24 @@ class EEVariables(): # PHP repo and packages if ee_platform_distro == 'Ubuntu': ee_php_repo = "ppa:ondrej/php5" - elif ee_platform_codename == 'squeeze': - ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php54 all" - .format(codename=ee_platform_codename)) elif ee_platform_codename == 'wheezy': ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php55 all" .format(codename=ee_platform_codename)) ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap", "php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline", - "php5-mysql", "php5-cli", "php5-memcache", "memcached", - "graphviz"] + "php5-mysql", "php5-cli", "php5-memcache", "php5-imagick", + "memcached", "graphviz"] # MySQL repo and packages - ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main" - .format(codename=ee_platform_codename)) - ee_mysql = ["percona-server-server-5.6", "mysqltuner", "percona-toolkit"] + if ee_platform_distro == 'Ubuntu': + ee_mysql_repo = ("deb http://mirror.aarnet.edu.au/pub/MariaDB/repo/" + "10.0/ubuntu {codename} main" + .format(codename=ee_platform_codename)) + elif ee_platform_distro == 'debian': + ee_mysql_repo = ("deb http://mirror.aarnet.edu.au/pub/MariaDB/repo/" + "10.0/debian {codename} main" + .format(codename=ee_platform_codename)) + ee_mysql = ["mariadb-server", "mysqltuner", "percona-toolkit"] # Postfix repo and packages ee_postfix_repo = "" diff --git a/install b/install index 55334045..40479df7 100644 --- a/install +++ b/install @@ -4,13 +4,15 @@ # This script is designed to install latest EasyEngine or # to update current EasyEngine from 2.x to 3.x -old_ee_version="2.2.3" -new_ee_version="3.0.4" -branch=$1 +# Checking permissions +if [[ $EUID -ne 0 ]]; then + ee_lib_echo_fail "Sudo privilege required..." + ee_lib_echo_fail "Uses: wget -qO ee rt.cx/ee && sudo bash ee" + exit 100 +fi # Define echo function # Blue color - function ee_lib_echo() { echo $(tput setaf 4)$@$(tput sgr0) @@ -33,26 +35,75 @@ function ee_lib_error() exit $2 } -function install_dep() -{ +# Execute: apt-get update +ee_lib_echo "Executing apt-get update, please wait..." +apt-get update &>> /dev/null - # Install Python3 on users system - ee_lib_echo "Installing pre depedencies" - if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - apt-get -y install gcc python-software-properties software-properties-common python3 python3-apt python3-setuptools python3-dev sqlite3 git || ee_lib_error "Unable to install pre depedencies, exit status " 1 - elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then - apt-get -y install gcc graphviz python-software-properties python3 python3-apt python3-setuptools python3-dev sqlite3 git || ee_lib_error "Unable to pre depedencies, exit status " 1 +# Checking lsb_release package +if [ ! -x /usr/bin/lsb_release ]; then + ee_lib_echo "Installing lsb-release, please wait..." + apt-get -y install lsb-release &>> /dev/null +fi + +# Define variables for later use +ee_branch=$1 +readonly ee_version_old="2.2.3" +readonly ee_version_new="3.0.5" +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}') +readonly ee_debian_version=$(lsb_release -sc) + +# Checking linux distro +if [ "$ee_linux_distro" != "Ubuntu" ] && [ "$ee_linux_distro" != "Debian" ]; then + ee_lib_echo_fail "EasyEngine (ee) is made for Ubuntu and Debian only as of now" + ee_lib_echo_fail "You are free to fork EasyEngine (ee): https://github.com/rtCamp/easyengine/fork" + ee_lib_echo_fail "EasyEngine (ee) only support Ubuntu 12.04/14.04 and Debian 7.x" + exit 100 +fi + +# EasyEngine (ee) only support all Ubuntu/Debian distro except the distro reached EOL +lsb_release -d | egrep -e "12.04|14.04|wheezy" &>> /dev/null +if [ "$?" -ne "0" ]; then + ee_lib_echo_fail "EasyEngine (ee) only support Ubuntu 12.04/14.04 and Debian 7.x" + exit 100 +fi + +# Pre checks to avoid later screw ups +# Checking EasyEngine (ee) log directory +if [ ! -d $ee_log_dir ]; then + + ee_lib_echo "Creating EasyEngine log directory, please wait..." + mkdir -p $ee_log_dir || ee_lib_error "Unable to create log directory $ee_log_dir, exit status " $? + + # Create EasyEngine log files + touch /var/log/ee/{ee.log,install.log} + + # Keep EasyEngine log folder accessible to root only + chmod -R 700 /var/log/ee || ee_lib_error "Unable to change permissions for EasyEngine log folder, exit status " $? +fi + +# Install Python3, Git, Tar and python-software-properties required packages +# Generate Locale +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 + 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 fi # Generating Locale locale-gen en &>> /dev/null } -function sync_db() +# Sqlite query to create table `sites` into ee.db +# which will be used by EasyEngine 3.x +function ee_sync_db() { mkdir -p /var/lib/ee - # Sqlite query to create table `sites` into ee.db which will be used by ee.3.0 echo "CREATE TABLE sites ( id INTEGER PRIMARY KEY AUTOINCREMENT, sitename UNIQUE, @@ -66,259 +117,213 @@ function sync_db() storage_db CHAR );" | sqlite3 /var/lib/ee/ee.db + # Check site is enable/live or disable for site in $(ls /etc/nginx/sites-available/ | grep -v default); do - if [ -f /etc/nginx/sites-available/$site ]; then - ENABLE_STATUS='1' + if [ -f /etc/nginx/sites-enabled/$site ]; then + ee_site_status='1' else - ENABLE_STATUS='0' + ee_site_status='0' fi + # Find out information about current NGINX configuration - EE_SITE_CURRENT_TYPE=$(head -n1 /etc/nginx/sites-available/$site | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) + ee_site_current_type=$(head -n1 /etc/nginx/sites-available/$site | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) + # Detect current website type and cache - if [ "$EE_SITE_CURRENT_TYPE" = "HTML" ]; then - EE_SITE_CURRENT="html" - EE_SITE_CURRENT_CACHE="basic" - elif [ "$EE_SITE_CURRENT_TYPE" = "PHP" ]; then - EE_SITE_CURRENT="php" - EE_SITE_CURRENT_CACHE="basic" - elif [ "$EE_SITE_CURRENT_TYPE" = "MYSQL" ]; then - EE_SITE_CURRENT="mysql" - EE_SITE_CURRENT_CACHE="basic" + if [ "$ee_site_current_type" = "HTML" ]; then + ee_site_current="html" + ee_site_current_cache="basic" + elif [ "$ee_site_current_type" = "PHP" ]; then + ee_site_current="php" + ee_site_current_cache="basic" + elif [ "$ee_site_current_type" = "MYSQL" ]; then + ee_site_current="mysql" + ee_site_current_cache="basic" # Single WordPress - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE BASIC" ]; then - EE_SITE_CURRENT="wp" - EE_SITE_CURRENT_CACHE="basic" + elif [ "$ee_site_current_type" = "WPSINGLE BASIC" ]; then + ee_site_current="wp" + ee_site_current_cache="basic" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE WP SUPER CACHE" ]; then - EE_SITE_CURRENT="wp" - EE_SITE_CURRENT_CACHE="wpsc" + elif [ "$ee_site_current_type" = "WPSINGLE WP SUPER CACHE" ]; then + ee_site_current="wp" + ee_site_current_cache="wpsc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE W3 TOTAL CACHE" ]; then - EE_SITE_CURRENT="wp" - EE_SITE_CURRENT_CACHE="w3tc" + elif [ "$ee_site_current_type" = "WPSINGLE W3 TOTAL CACHE" ]; then + ee_site_current="wp" + ee_site_current_cache="w3tc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FASTCGI" ]; then - EE_SITE_CURRENT="wp" - EE_SITE_CURRENT_CACHE="wpfc" + elif [ "$ee_site_current_type" = "WPSINGLE FAST CGI" ] || [ "$ee_site_current_type" = "WPSINGLE FASTCGI" ]; then + ee_site_current="wp" + ee_site_current_cache="wpfc" # WordPress subdirectory - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR BASIC" ]; then - EE_SITE_CURRENT="wpsubdir" - EE_SITE_CURRENT_CACHE="basic" + elif [ "$ee_site_current_type" = "WPSUBDIR BASIC" ]; then + ee_site_current="wpsubdir" + ee_site_current_cache="basic" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR WP SUPER CACHE" ]; then - EE_SITE_CURRENT="wpsubdir" - EE_SITE_CURRENT_CACHE="wpsc" + elif [ "$ee_site_current_type" = "WPSUBDIR WP SUPER CACHE" ]; then + ee_site_current="wpsubdir" + ee_site_current_cache="wpsc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR W3 TOTAL CACHE" ]; then - EE_SITE_CURRENT="wpsubdir" - EE_SITE_CURRENT_CACHE="w3tc" + elif [ "$ee_site_current_type" = "WPSUBDIR W3 TOTAL CACHE" ]; then + ee_site_current="wpsubdir" + ee_site_current_cache="w3tc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FASTCGI" ]; then - EE_SITE_CURRENT="wpsubdir" - EE_SITE_CURRENT_CACHE="wpfc" + elif [ "$ee_site_current_type" = "WPSUBDIR FAST CGI" ] || [ "$ee_site_current_type" = "WPSUBDIR FASTCGI" ]; then + ee_site_current="wpsubdir" + ee_site_current_cache="wpfc" # WordPress subdomain - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN BASIC" ]; then - EE_SITE_CURRENT="wpsubdomain" - EE_SITE_CURRENT_CACHE="basic" + elif [ "$ee_site_current_type" = "WPSUBDOMAIN BASIC" ]; then + ee_site_current="wpsubdomain" + ee_site_current_cache="basic" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN WP SUPER CACHE" ]; then - EE_SITE_CURRENT="wpsubdomain" - EE_SITE_CURRENT_CACHE="wpsc" + elif [ "$ee_site_current_type" = "WPSUBDOMAIN WP SUPER CACHE" ]; then + ee_site_current="wpsubdomain" + ee_site_current_cache="wpsc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then - EE_SITE_CURRENT="wpsubdomain" - EE_SITE_CURRENT_CACHE="w3tc" + elif [ "$ee_site_current_type" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then + ee_site_current="wpsubdomain" + ee_site_current_cache="w3tc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FASTCGI" ]; then - EE_SITE_CURRENT="wpsubdomain" - EE_SITE_CURRENT_CACHE="wpfc" + elif [ "$ee_site_current_type" = "WPSUBDOMAIN FAST CGI" ] || [ "$ee_site_current_type" = "WPSUBDOMAIN FASTCGI" ]; then + ee_site_current="wpsubdomain" + ee_site_current_cache="wpfc" fi - WEBROOT="/var/www/$site" + ee_webroot="/var/www/$site" # Insert query to insert old site information into ee.db echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db) - VALUES (\"$site\", \"$EE_SITE_CURRENT\", \"$EE_SITE_CURRENT_CACHE\", \"$WEBROOT\", \"$ENABLE_STATUS\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/ee/ee.db + VALUES (\"$site\", \"$ee_site_current\", \"$ee_site_current_cache\", \"$ee_webroot\", \"$ee_site_status\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/ee/ee.db done } -function install_ee3() +# Install EasyEngine 3.x +function ee_install() { # Remove old clone of EasyEngine (ee) if any rm -rf /tmp/easyengine &>> /dev/null - # Clone EE 3.0 Python branch - ee_lib_echo "Cloning EasyEngine 3" - if [ "$branch" = "" ]; then - branch=stable + # Clone EE 3.0 Python ee_branch + ee_lib_echo "Cloning EasyEngine, please wait..." + if [ "$ee_branch" = "" ]; then + ee_branch=stable fi - git clone -b $branch https://github.com/rtCamp/easyengine.git /tmp/easyengine --quiet > /dev/null || ee_lib_error "Unable to clone EasyEngine, exit status" 1 + git clone -b $ee_branch https://github.com/rtCamp/easyengine.git /tmp/easyengine --quiet > /dev/null \ + || ee_lib_error "Unable to clone EasyEngine, exit status" $? cd /tmp/easyengine - ee_lib_echo "Installing EasyEngine 3" - python3 setup.py install || ee_lib_error "Unable to install EasyEngine 3.0, exit status " 1 - + ee_lib_echo "Installing EasyEngine, please wait..." + python3 setup.py install || ee_lib_error "Unable to install EasyEngine, exit status " $? } -function update_to_ee3() +# Update EasyEngine configuration +# Remove EasyEngine 2.x +function ee_update() { # Preserve old configuration - ee_lib_echo "Updating EasyEngine 3 configuration" + ee_lib_echo "Updating EasyEngine configuration, please wait..." if [ -f /etc/nginx/nginx.conf ]; then - sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $new_ee_version\";/" /etc/nginx/nginx.conf &>> /dev/null + sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $ee_version_new\";/" /etc/nginx/nginx.conf &>> /dev/null fi - 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 }') - wp_user=$(grep 'user ' /etc/easyengine/ee.conf | grep -v db-user |awk '{ print $3 }') - wp_pass=$(grep password /etc/easyengine/ee.conf | awk '{ print $3 }') - wp_email=$(grep email /etc/easyengine/ee.conf | awk '{ print $3 }') - ip_addr=$(grep ip-address /etc/easyengine/ee.conf |awk -F'=' '{ print $2 }') - - sed -i "s/ip-address.*/ip-address = ${ip_addr}/" /etc/ee/ee.conf && \ - sed -i "s/grant-host.*/grant-host = ${grant_host}/" /etc/ee/ee.conf && \ + ee_grant_host=$(grep grant-host /etc/easyengine/ee.conf | awk '{ print $3 }' | head -1 ) + ee_db_name=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }') + ee_db_user=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }') + ee_wp_prefix=$(grep prefix /etc/easyengine/ee.conf | awk '{ print $3 }') + ee_wp_user=$(grep 'user ' /etc/easyengine/ee.conf | grep -v db-user |awk '{ print $3 }') + ee_wp_pass=$(grep password /etc/easyengine/ee.conf | awk '{ print $3 }') + ee_wp_email=$(grep email /etc/easyengine/ee.conf | awk '{ print $3 }') + ee_ip_addr=$(grep ip-address /etc/easyengine/ee.conf |awk -F'=' '{ print $2 }') + + sed -i "s/ip-address.*/ip-address = ${ee_ip_addr}/" /etc/ee/ee.conf && \ + sed -i "s/grant-host.*/grant-host = ${ee_grant_host}/" /etc/ee/ee.conf && \ sed -i "s/db-name.*/db-name = ${db-name}/" /etc/ee/ee.conf && \ - sed -i "s/db-user.*/db-user = ${db_user}/" /etc/ee/ee.conf && \ - sed -i "s/prefix.*/prefix = ${wp_prefix}/" /etc/ee/ee.conf && \ - sed -i "s/^user.*/user = ${wp_user}/" /etc/ee/ee.conf && \ - sed -i "s/password.*/password = ${wp_password}/" /etc/ee/ee.conf && \ - sed -i "s/email.*/email = ${wp_email}/" /etc/ee/ee.conf || ee_lib_error "Unable to update configuration, exit status " 1 + sed -i "s/db-user.*/db-user = ${ee_db_user}/" /etc/ee/ee.conf && \ + sed -i "s/prefix.*/prefix = ${ee_wp_prefix}/" /etc/ee/ee.conf && \ + sed -i "s/^user.*/user = ${ee_wp_user}/" /etc/ee/ee.conf && \ + sed -i "s/password.*/password = ${ee_wp_password}/" /etc/ee/ee.conf && \ + sed -i "s/email.*/email = ${ee_wp_email}/" /etc/ee/ee.conf || ee_lib_error "Unable to update configuration, exit status " $? # Remove old EasyEngine - ee_lib_echo "Removing EasyEngine 2" + ee_lib_echo "Removing EasyEngine 2.x" rm -rf /etc/bash_completion.d/ee /etc/easyengine/ /usr/share/easyengine/ /usr/local/lib/easyengine /usr/local/sbin/easyengine /usr/local/sbin/ee /var/log/easyengine # Softlink to fix command not found error - ln -s /usr/local/bin/ee /usr/local/sbin/ee || ee_lib_error "Unable to create softlink to old EasyEngine, exit status " 1 - + ln -s /usr/local/bin/ee /usr/local/sbin/ee || ee_lib_error "Unable to create softlink to old EasyEngine, exit status " $? } -function update_to_ee_latest() +function ee_update_latest() { - ee_lib_echo "Updating Nginx configuration" + ee_lib_echo "Updating Nginx configuration, please wait..." if [ -f /etc/nginx/ee-nginx.conf ]; then - sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $new_ee_version\";/" /etc/nginx/nginx.conf &>> /dev/null + sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $ee_version_new\";/" /etc/nginx/nginx.conf &>> /dev/null elif [ -f /etc/nginx/nginx.conf ]; then - sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $new_ee_version\";/" /etc/nginx/nginx.conf &>> /dev/null + sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $ee_version_new\";/" /etc/nginx/nginx.conf &>> /dev/null fi } -function git_init() +# Do git intialisation +function ee_git_init() { - # Do git intialisation on EasyEngine adn Nginx configuration + # Nginx under git version control if [ -d /etc/nginx ];then cd /etc/nginx if [ ! -d /etc/nginx/.git ]; then - git init > /dev/null + git init &>> /dev/null fi git add . git commit -am "Updated Nginx" > /dev/null fi + # EasyEngine under git version control cd /etc/ee if [ ! -d /etc/ee/.git ]; then git init > /dev/null fi git add . - git commit -am "Installed/Updated to EasyEngine 3" > /dev/null + git commit -am "Installed/Updated to EasyEngine 3.x" &>> /dev/null } -# Checking permissions -if [[ $EUID -ne 0 ]]; then - ee_lib_echo_fail "Sudo privilege required..." - ee_lib_echo_fail "Uses: wget -qO ee rt.cx/ee && sudo bash ee" - exit 1 -fi - -# Execute: apt-get update -ee_lib_echo "Executing apt-get update" -apt-get update &>> /dev/null - -# Checking lsb_release package -if [ ! -x /usr/bin/lsb_release ]; then - ee_lib_echo "Installing lsb-release, please wait..." - apt-get -y install lsb-release &>> /dev/null -fi - -# Define variables for later use -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}') -readonly EE_DEBIAN_VERSION=$(lsb_release -sc) - -# Checking linux distro -if [ "$EE_LINUX_DISTRO" != "Ubuntu" ] && [ "$EE_LINUX_DISTRO" != "Debian" ]; then - ee_lib_echo_fail "EasyEngine (ee) is made for Ubuntu and Debian only as of now" - ee_lib_echo_fail "You are free to fork EasyEngine (ee): https://github.com/rtCamp/easyengine/fork" - ee_lib_echo_fail "EasyEngine (ee) only support Ubuntu 12.04/14.04 and Debian 7.x" - exit 100 -fi - -# EasyEngine (ee) only support all Ubuntu/Debian distro except the distro reached EOL -lsb_release -d | egrep -e "12.04|14.04|wheezy" &>> /dev/null -if [ "$?" -ne "0" ]; then - exit 100 -fi - - -# Pre checks to avoid later screw ups -# Checking EasyEngine (ee) log directory -if [ ! -d $EE_LOG_DIR ]; then - - ee_lib_echo "Creating EasyEngine log directory, please wait..." - mkdir -p $EE_LOG_DIR || ee_lib_error "Creating log directory failed, exit status " 1 - - # Create EasyEngine log files - touch /var/log/ee/{ee.log,install.log} - - # Keep EasyEngine log folder accessible to root only - chmod -R 700 /var/log/ee || ee_lib_error "Unable to setup log directory permissions , exit status " 1 -fi - +# Update EasyEngine if [ -f /usr/local/sbin/easyengine ]; then # Check old EasyEngine version - ee version | grep ${old_ee_version} &>> /dev/null + ee version | grep ${ee_version_old} &>> /dev/null if [[ $? -ne 0 ]]; then - ee_lib_echo "EasyEngine $old_ee_version not found on your system" | tee -ai $EE_INSTALL_LOG - ee_lib_echo "Updating your EasyEngine to $old_ee_version for compability" | tee -ai $EE_INSTALL_LOG - wget -q https://raw.githubusercontent.com/rtCamp/easyengine/old-stable/bin/update && bash update | tee -ai $EE_INSTALL_LOG + ee_lib_echo "EasyEngine $ee_version_old not found on your system" | tee -ai $ee_install_log + ee_lib_echo "Updating your EasyEngine to $ee_version_old for compability" | tee -ai $ee_install_log + wget -q https://raw.githubusercontent.com/rtCamp/easyengine/old-stable/bin/update && bash update | tee -ai $ee_install_log if [[ $? -ne 0 ]]; then - ee_lib_echo_info "Unbale to update EasyEngine2 to $old_ee_version" - exit 1 + ee_lib_echo_fail "Unbale to update EasyEngine to $ee_version_old, exit status = " $? fi fi - install_dep | tee -ai $EE_INSTALL_LOG - sync_db | tee -ai $EE_INSTALL_LOG - install_ee3 | tee -ai $EE_INSTALL_LOG - update_to_ee3 | tee -ai $EE_INSTALL_LOG - git_init | tee -ai $EE_INSTALL_LOG + ee_install_dep | tee -ai $ee_install_log + ee_sync_db | tee -ai $ee_install_log + ee_install | tee -ai $ee_install_log + ee_update | tee -ai $ee_install_log + ee_git_init | tee -ai $ee_install_log elif [ ! -f /usr/local/bin/ee ]; then - install_dep | tee -ai $EE_INSTALL_LOG - install_ee3 | tee -ai $EE_INSTALL_LOG - git_init | tee -ai $EE_INSTALL_LOG + ee_install_dep | tee -ai $ee_install_log + ee_install | tee -ai $ee_install_log + ee_git_init | tee -ai $ee_install_log else - ee -v 2>&1 | grep $new_ee_version &>> /dev/null + ee -v 2>&1 | grep $ee_version_new &>> /dev/null if [[ $? -ne 0 ]];then - read -p "Update EasyEngine to $new_ee_version (y/n): " ee_ans + read -p "Update EasyEngine to $ee_version_new (y/n): " ee_ans if [ "$ee_ans" = "y" ] || [ "$ee_ans" = "Y" ]; then - install_dep | tee -ai $EE_INSTALL_LOG - update_to_ee_latest | tee -ai $EE_INSTALL_LOG - install_ee3 | tee -ai $EE_INSTALL_LOG - git_init | tee -ai $EE_INSTALL_LOG + ee_install_dep | tee -ai $ee_install_log + ee_update_latest | tee -ai $ee_install_log + ee_install | tee -ai $ee_install_log + ee_git_init | tee -ai $ee_install_log service nginx reload &>> /dev/null fi else - ee_lib_echo_fail "You already have EasyEngine $new_ee_version" | tee -ai $EE_INSTALL_LOG - exit 1 + ee_lib_echo_fail "You already have EasyEngine $ee_version_new, exit status = " $? | tee -ai $ee_install_log fi fi diff --git a/setup.py b/setup.py index fc4b3538..ad938244 100644 --- a/setup.py +++ b/setup.py @@ -54,15 +54,15 @@ except Exception as e: os.system("git config --global user.email {0}".format(ee_email)) setup(name='ee', - version='3.0.4', + version='3.0.5', description=long_description, long_description=long_description, classifiers=[], keywords='', author='rtCamp Soultions Pvt. LTD', - author_email='sys@rtcamp.com', + author_email='ee@rtcamp.com', url='http://rtcamp.com/easyengine', - license='GPL', + license='MIT', packages=find_packages(exclude=['ez_setup', 'examples', 'tests', 'templates']), include_package_data=True,