diff --git a/.travis.yml b/.travis.yml index 66350828..4d829c83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ before_install: - rm -rf ~/.gnupg before_script: + - sudo rm -rf /etc/mysql/ - sudo bash -c 'echo example.com > /etc/hostname' - sudo service hostname restart - sudo apt-get -qq purge mysql* graphviz* @@ -22,7 +23,7 @@ before_script: script: - unset LANG - - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig + - sudo bash -c 'echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > /home/travis/.gitconfig' - sudo echo "Travis Banch = $TRAVIS_BRANCH" - sudo apt-get install -y --force-yes git python3-setuptools python3-dev python3-apt - sudo bash install $TRAVIS_BRANCH diff --git a/config/bash_completion.d/ee_auto.rc b/config/bash_completion.d/ee_auto.rc index b238cfa6..208bc167 100644 --- a/config/bash_completion.d/ee_auto.rc +++ b/config/bash_completion.d/ee_auto.rc @@ -35,7 +35,7 @@ _ee_complete() "stack") COMPREPLY=( $(compgen \ - -W "install purge reload remove restart start status stop migrate" \ + -W "upgrade install purge reload remove restart start status stop migrate" \ -- $cur) ) ;; @@ -74,7 +74,12 @@ _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 --hhvm" \ + -W "--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --all --mailscanner --hhvm" \ + -- $cur) ) + ;; + "upgrade" ) + COMPREPLY=( $(compgen \ + -W "--web --mail --nginx --php --mysql --postfix --all --hhvm --php56 --no-prompt" \ -- $cur) ) ;; "start" | "stop" | "reload" | "restart" | "status") diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 68bc3b77..7d5f20b7 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -180,6 +180,17 @@ class EEDebugController(CementBaseController): ";zend_extension", "zend_extension") + # Fix slow log is not enabled default in PHP5.6 + config = configparser.ConfigParser() + config.read('/etc/php5/fpm/pool.d/debug.conf') + config['debug']['slowlog'] = '/var/log/php5/slow.log' + config['debug']['request_slowlog_timeout'] = '10s' + with open('/etc/php5/fpm/pool.d/debug.conf', + encoding='utf-8', mode='w') as confifile: + Log.debug(self, "Writting debug.conf configuration into " + "/etc/php5/fpm/pool.d/debug.conf") + config.write(confifile) + self.trigger_php = True self.trigger_nginx = True else: @@ -505,7 +516,7 @@ class EEDebugController(CementBaseController): "'ee debug --import-slow-log'"): if not cron_time == 0: Log.info(self, "setting up crontab entry," - " please wait ...") + " please wait...") EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l " "2> /dev/null | {{ cat; echo -e" " \\\"#EasyEngine start MySQL " @@ -518,7 +529,7 @@ class EEDebugController(CementBaseController): else: if not cron_time == 0: Log.info(self, "updating crontab entry," - " please wait ...") + " please wait...") if not EEShellExec.cmd_exec(self, "/bin/bash -c " "\"crontab " "-l | sed '/EasyEngine " @@ -533,7 +544,7 @@ class EEDebugController(CementBaseController): Log.error(self, "failed to update crontab entry") else: Log.info(self, "removing crontab entry," - " please wait ...") + " please wait...") if not EEShellExec.cmd_exec(self, "/bin/bash -c " "\"crontab " "-l | sed '/EasyEngine " diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 5a38387d..5ee261fb 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -686,7 +686,7 @@ class EESiteUpdateController(CementBaseController): for site in sites: pargs.site_name = site.sitename Log.info(self, Log.ENDC + Log.BOLD + "Updating site {0}," - " please wait ..." + " please wait..." .format(pargs.site_name)) self.doupdatesite(pargs) print("\n") diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 5ca8db80..f51cdcb8 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -31,7 +31,7 @@ class SiteError(Exception): def pre_run_checks(self): # Check nginx configuration - Log.info(self, "Running pre-update checks, please wait ...") + Log.info(self, "Running pre-update checks, please wait...") try: Log.debug(self, "checking NGINX configuration ...") FNULL = open('/dev/null', 'w') @@ -78,7 +78,7 @@ def setupdomain(self, data): finally: # Check nginx -t and return status over it try: - Log.debug(self, "Checking generated nginx conf, please wait ...") + Log.debug(self, "Checking generated nginx conf, please wait...") FNULL = open('/dev/null', 'w') ret = subprocess.check_call(["nginx", "-t"], stdout=FNULL, stderr=subprocess.STDOUT) @@ -466,7 +466,7 @@ def setupwordpressnetwork(self, data): def installwp_plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] - Log.info(self, "Installing plugin {0}, please wait ..." + Log.info(self, "Installing plugin {0}, please wait..." .format(plugin_name)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) try: @@ -490,7 +490,7 @@ def installwp_plugin(self, plugin_name, data): def uninstallwp_plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] - Log.debug(self, "Uninstalling plugin {0}, please wait ..." + Log.debug(self, "Uninstalling plugin {0}, please wait..." .format(plugin_name)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) try: diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index f13d33a0..cd0d624f 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -27,6 +27,7 @@ import grp import codecs from ee.cli.plugins.stack_services import EEStackStatusController from ee.cli.plugins.stack_migrate import EEStackMigrateController +from ee.cli.plugins.stack_upgrade import EEStackUpgradeController from ee.core.logging import Log @@ -95,7 +96,7 @@ class EEStackController(CementBaseController): Log.error(self, "Failed to intialize postfix package") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): - Log.info(self, "Adding repository for MySQL, please wait ...") + Log.info(self, "Adding repository for MySQL, please wait...") mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au" "\nPin-Priority: 1000\n") with open('/etc/apt/preferences.d/' @@ -149,7 +150,7 @@ class EEStackController(CementBaseController): config.write(configfile) if set(EEVariables.ee_nginx).issubset(set(apt_packages)): - Log.info(self, "Adding repository for NGINX, please wait ...") + Log.info(self, "Adding repository for NGINX, please wait...") if EEVariables.ee_platform_distro == 'debian': Log.debug(self, 'Adding Dotdeb/nginx GPG key') EERepo.add(self, repo_url=EEVariables.ee_nginx_repo) @@ -158,7 +159,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, please wait ...") + 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) @@ -169,7 +170,7 @@ class EEStackController(CementBaseController): 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 ...") + 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) @@ -469,6 +470,21 @@ class EEStackController(CementBaseController): Log.debug(self, 'Creating directory /var/log/php5/') os.makedirs('/var/log/php5/') + # For debian install xdebug + + if EEVariables.ee_platform_distro == "debian": + EEShellExec.cmd_exec(self, "pecl install xdebug") + + with open("/etc/php5/mods-available/xdebug.ini", + encoding='utf-8', mode='a') as myfile: + myfile.write("zend_extension=/usr/lib/php5/20131226/" + "xdebug.so\n") + + EEFileUtils.create_symlink(self, ["/etc/php5/" + "mods-available/xdebug.ini", + "/etc/php5/fpm/conf.d" + "/20-xedbug.ini"]) + # Parse etc/php5/fpm/php.ini config = configparser.ConfigParser() Log.debug(self, "configuring php file /etc/php5/fpm/php.ini") @@ -477,7 +493,7 @@ class EEStackController(CementBaseController): config['PHP']['post_max_size'] = '100M' config['PHP']['upload_max_filesize'] = '100M' config['PHP']['max_execution_time'] = '300' - config['PHP']['date.timezone'] = time.tzname[time.daylight] + config['PHP']['date.timezone'] = EEVariables.ee_timezone with open('/etc/php5/fpm/php.ini', encoding='utf-8', mode='w') as configfile: Log.debug(self, "Writting php configuration into " @@ -529,6 +545,8 @@ class EEStackController(CementBaseController): config.read('/etc/php5/fpm/pool.d/debug.conf') config['debug']['listen'] = '127.0.0.1:9001' config['debug']['rlimit_core'] = 'unlimited' + config['debug']['slowlog'] = '/var/log/php5/slow.log' + config['debug']['request_slowlog_timeout'] = '10s' with open('/etc/php5/fpm/pool.d/debug.conf', encoding='utf-8', mode='w') as confifile: Log.debug(self, "writting PHP5 configuration into " @@ -590,7 +608,7 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_hhvm).issubset(set(apt_packages)): EEShellExec.cmd_exec(self, "update-rc.d hhvm defaults") - + EEFileUtils.searchreplace(self, "/etc/hhvm/server.ini", "9000", "8000") EEFileUtils.searchreplace(self, "/etc/nginx/hhvm.conf", @@ -1008,10 +1026,22 @@ class EEStackController(CementBaseController): shutil.move('/tmp/webgrind-master/', '{0}22222/htdocs/php/webgrind' .format(EEVariables.ee_webroot)) - EEShellExec.cmd_exec(self, "sed -i \"s\'/usr/local/bin/dot\'" - "/usr/bin/dot\'\" {0}22222/htdocs/" - "php/webgrind/config.php" - .format(EEVariables.ee_webroot)) + + EEFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" + "config.php" + .format(EEVariables.ee_webroot), + "/usr/local/bin/dot", "/usr/bin/dot") + EEFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" + "config.php" + .format(EEVariables.ee_webroot), + "Europe/Copenhagen", + EEVariables.ee_timezone) + + EEFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" + "config.php" + .format(EEVariables.ee_webroot), + "90", "100") + Log.debug(self, "Setting Privileges of webroot permission to " "{0}22222/htdocs/php/webgrind/ file " .format(EEVariables.ee_webroot)) @@ -1552,9 +1582,9 @@ class EEStackController(CementBaseController): self.pre_pref(apt_packages) if len(apt_packages): EESwap.add(self) - Log.info(self, "Updating apt-cache, please wait ...") + Log.info(self, "Updating apt-cache, please wait...") EEAptGet.update(self) - Log.info(self, "Installing packages, please wait ...") + Log.info(self, "Installing packages, please wait...") EEAptGet.install(self, apt_packages) if len(packages): Log.debug(self, "Downloading following: {0}".format(packages)) @@ -1672,7 +1702,7 @@ class EEStackController(CementBaseController): if len(apt_packages): if ee_prompt == 'YES' or ee_prompt == 'yes': Log.debug(self, "Removing apt_packages") - Log.info(self, "Removing packages, please wait ...") + Log.info(self, "Removing packages, please wait...") EEAptGet.remove(self, apt_packages) EEAptGet.auto_remove(self) @@ -1785,7 +1815,7 @@ class EEStackController(CementBaseController): if len(apt_packages): if ee_prompt == 'YES' or ee_prompt == 'yes': - Log.info(self, "Purging packages, please wait ...") + Log.info(self, "Purging packages, please wait...") EEAptGet.remove(self, apt_packages, purge=True) EEAptGet.auto_remove(self) @@ -1803,6 +1833,7 @@ def load(app): handler.register(EEStackController) handler.register(EEStackStatusController) handler.register(EEStackMigrateController) + handler.register(EEStackUpgradeController) # 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 index e5cfa38c..e200036b 100644 --- a/ee/cli/plugins/stack_migrate.py +++ b/ee/cli/plugins/stack_migrate.py @@ -31,7 +31,7 @@ class EEStackMigrateController(CementBaseController): EEMysql.backupAll(self) # Add MariaDB repo - Log.info(self, "Adding repository for MariaDB, please wait ...") + Log.info(self, "Adding repository for MariaDB, please wait...") mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au" "\nPin-Priority: 1000\n") @@ -87,9 +87,9 @@ class EEStackMigrateController(CementBaseController): apt_packages = apt_packages + ["dovecot-mysql", "postfix-mysql", "libclass-dbi-mysql-perl"] - Log.info(self, "Updating apt-cache, please wait ...") + Log.info(self, "Updating apt-cache, please wait...") EEAptGet.update(self) - Log.info(self, "Installing MariaDB, please wait ...") + Log.info(self, "Installing MariaDB, please wait...") EEAptGet.remove(self, ["mysql-common", "libmysqlclient18"]) EEAptGet.auto_remove(self) EEAptGet.install(self, apt_packages) diff --git a/ee/cli/plugins/stack_upgrade.py b/ee/cli/plugins/stack_upgrade.py new file mode 100644 index 00000000..1759da12 --- /dev/null +++ b/ee/cli/plugins/stack_upgrade.py @@ -0,0 +1,194 @@ +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook +from ee.core.logging import Log +from ee.core.variables import EEVariables +from ee.core.aptget import EEAptGet +from ee.core.apt_repo import EERepo +from ee.core.services import EEService +from ee.core.fileutils import EEFileUtils +from ee.core.shellexec import EEShellExec +import configparser +import os + + +class EEStackUpgradeController(CementBaseController): + class Meta: + label = 'upgrade' + stacked_on = 'stack' + stacked_type = 'nested' + description = ('Upgrade stack safely') + arguments = [ + (['--all'], + dict(help='Upgrade all stack', action='store_true')), + (['--web'], + dict(help='Upgrade web stack', action='store_true')), + (['--admin'], + dict(help='Upgrade admin tools stack', action='store_true')), + (['--mail'], + dict(help='Upgrade mail server stack', action='store_true')), + (['--mailscanner'], + dict(help='Upgrade mail scanner stack', action='store_true')), + (['--nginx'], + dict(help='Upgrade Nginx stack', action='store_true')), + (['--php'], + dict(help='Upgrade PHP stack', action='store_true')), + (['--mysql'], + dict(help='Upgrade MySQL stack', action='store_true')), + (['--hhvm'], + dict(help='Upgrade HHVM stack', action='store_true')), + (['--postfix'], + dict(help='Upgrade Postfix stack', action='store_true')), + (['--php56'], + dict(help="Upgrade to PHP5.6 from PHP5.5", + action='store_true')), + (['--no-prompt'], + dict(help="Upgrade Packages without any prompt", + action='store_true')), + ] + + @expose(hide=True) + def upgrade_php56(self): + if EEVariables.ee_platform_distro == "Ubuntu": + if os.path.isfile("/etc/apt/sources.list.d/ondrej-php5-5_6-{0}." + "list".format(EEVariables.ee_platform_codename)): + Log.error(self, "Unable to find PHP 5.5") + else: + if not(os.path.isfile(EEVariables.ee_repo_file_path) and + EEFileUtils.grep(self, EEVariables.ee_repo_file_path, + "php55")): + Log.error(self, "Unable to find PHP 5.5") + + Log.info(self, "During PHP update process non nginx-cached" + " parts of your site may remain down") + + # Check prompt + if (not self.app.pargs.no_prompt): + start_upgrade = input("Do you want to continue:[y/N]") + if start_upgrade != "Y" and start_upgrade != "y": + Log.error(self, "Not starting PHP package update") + + if EEVariables.ee_platform_distro == "Ubuntu": + EERepo.remove(self, ppa="ppa:ondrej/php5") + else: + EEAptGet.remove(self, ["php5-xdebug"]) + EEFileUtils.searchreplace(self, EEVariables.ee_repo_file_path, + "php55", "php56") + + Log.info(self, "Updating apt-cache, please wait...") + EEAptGet.update(self) + Log.info(self, "Installing packages, please wait ...") + EEAptGet.install(self, EEVariables.ee_php) + + if EEVariables.ee_platform_distro == "debian": + EEShellExec.cmd_exec(self, "pecl install xdebug") + + with open("/etc/php5/mods-available/xdebug.ini", + encoding='utf-8', mode='a') as myfile: + myfile.write(";zend_extension=/usr/lib/php5/20131226/" + "xdebug.so\n") + + EEFileUtils.create_symlink(self, ["/etc/php5/mods-available/" + "xdebug.ini", "/etc/php5/fpm/conf.d" + "/20-xedbug.ini"]) + + Log.info(self, "Successfully upgraded from PHP 5.5 to PHP 5.6") + + @expose(hide=True) + def default(self): + # All package update + if ((not self.app.pargs.php56)): + + apt_packages = [] + + Log.info(self, "During package update process non nginx-cached" + " parts of your site may remain down") + # Check prompt + if (not self.app.pargs.no_prompt): + start_upgrade = input("Do you want to continue:[y/N]") + if start_upgrade != "Y" and start_upgrade != "y": + Log.error(self, "Not starting package update") + + if ((not self.app.pargs.web) and (not self.app.pargs.nginx) and + (not self.app.pargs.php) and (not self.app.pargs.mysql) and + (not self.app.pargs.postfix) and (not self.app.pargs.hhvm) and + (not self.app.pargs.mailscanner) and (not self.app.pargs.all)): + self.app.pargs.web = True + + if self.app.pargs.all: + self.app.pargs.web = True + self.app.pargs.mail = True + + if self.app.pargs.web: + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + self.app.pargs.postfix = True + self.app.pargs.hhvm = True + + if self.app.pargs.mail: + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + self.app.pargs.postfix = True + + if EEAptGet.is_installed(self, 'dovecot-core'): + apt_packages = apt_packages + EEVariables.ee_mail + self.app.pargs.mailscanner = True + else: + Log.info(self, "Mail server is not installed") + + if self.app.pargs.nginx: + if EEVariables.ee_platform_distro == 'debian': + check_nginx = 'nginx-extras' + else: + check_nginx = 'nginx-custom' + + if EEAptGet.is_installed(self, check_nginx): + apt_packages = apt_packages + EEVariables.ee_nginx + else: + Log.info(self, "Nginx is not already installed") + + if self.app.pargs.php: + if EEAptGet.is_installed(self, 'php5-fpm'): + apt_packages = apt_packages + EEVariables.ee_php + else: + Log.info(self, "PHP is not installed") + + if self.app.pargs.hhvm: + if EEAptGet.is_installed(self, 'hhvm'): + apt_packages = apt_packages + EEVariables.ee_hhvm + else: + Log.info(self, "HHVM is not installed") + + if self.app.pargs.mysql: + if EEAptGet.is_installed(self, 'mariadb-server'): + apt_packages = apt_packages + EEVariables.ee_mysql + else: + Log.info(self, "MySQL is not installed") + + if self.app.pargs.postfix: + if EEAptGet.is_installed(self, 'postfix'): + apt_packages = apt_packages + EEVariables.ee_postfix + else: + Log.info(self, "Postfix is not installed") + + if self.app.pargs.mailscanner: + if EEAptGet.is_installed(self, 'amavisd-new'): + apt_packages = (apt_packages + EEVariables.ee_mailscanner) + else: + Log.info(self, "MailScanner is not installed") + + if len(apt_packages): + # apt-get update + EEAptGet.update(self) + + # Update packages + Log.info(self, "Updating packages, please wait...") + EEAptGet.install(self, apt_packages) + Log.info(self, "Successfully updated packages") + + # PHP 5.6 to 5.6 + elif (self.app.pargs.php56): + self.upgrade_php56() + else: + self.app.args.print_help() diff --git a/ee/cli/plugins/sync.py b/ee/cli/plugins/sync.py index 2b8d6dd1..c260402f 100644 --- a/ee/cli/plugins/sync.py +++ b/ee/cli/plugins/sync.py @@ -28,7 +28,7 @@ class EESyncController(CementBaseController): 1. reads database information from wp/ee-config.php 2. updates records into ee database accordingly. """ - Log.info(self, "Synchronizing ee database, please wait ....") + Log.info(self, "Synchronizing ee database, please wait...") sites = getAllsites(self) if not sites: pass diff --git a/ee/cli/plugins/update.py b/ee/cli/plugins/update.py index 28d383e0..8680d68e 100644 --- a/ee/cli/plugins/update.py +++ b/ee/cli/plugins/update.py @@ -28,7 +28,7 @@ class EEUpdateController(CementBaseController): "/tmp/{0}".format(filename), "update script"]]) try: - Log.info(self, "updating EasyEngine, please wait ...") + Log.info(self, "updating EasyEngine, please wait...") os.system("bash /tmp/{0}".format(filename)) except OSError as e: Log.debug(self, str(e)) diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index a32794b5..ecfd4cfc 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -1,6 +1,7 @@ """EasyEngine packages repository operations""" from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables +from ee.core.logging import Log import os @@ -54,16 +55,31 @@ class EERepo(): "'{ppa_name}'" .format(ppa_name=ppa)) - def remove(self, ppa=None): + def remove(self, ppa=None, repo_url=None): """ This function used to remove ppa's If ppa is provided adds repo file to /etc/apt/sources.list.d/ command. """ - EEShellExec.cmd_exec(self, "add-apt-repository -y " - "--remove '{ppa_name}'" - .format(ppa_name=repo_url)) + if ppa: + EEShellExec.cmd_exec(self, "add-apt-repository -y " + "--remove '{ppa_name}'" + .format(ppa_name=ppa)) + elif repo_url: + repo_file_path = ("/etc/apt/sources.list.d/" + + EEVariables().ee_repo_file) + + try: + repofile = open(repo_file_path, "w+") + repofile.write(repofile.read().replace(repo_url, "")) + repofile.close() + except IOError as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "File I/O error.") + except Exception as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to remove repo") def add_key(self, keyids, keyserver=None): """ diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 5eff0cf7..a4071a4a 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -32,32 +32,60 @@ class EEAptGet(): Log.error(self, "Error while installing packages, " "apt-get exited with error") - def dist_upgrade(): + def check_upgrade(self): """ Similar to `apt-get upgrade` """ try: - apt_cache = apt.cache.Cache() - apt_cache.update() - apt_cache.open(None) - apt_cache.upgrade(True) - 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)) - except FetchFailedException as e: - Log.debug(self, 'SystemError: ' + str(e)) - Log.error(self, 'Unable to Fetch update') + check_update = subprocess.Popen(['apt-get upgrade -s | grep ' + '\"^Inst\" | wc -l'], + stdout=subprocess.PIPE, + shell=True).communicate()[0] + if check_update == b'0\n': + Log.error(self, "No package updates available") + Log.info(self, "Following package updates are available:") + subprocess.Popen("apt-get -s dist-upgrade | grep \"^Inst\"", + shell=True, executable="/bin/bash", + stdout=sys.stdout).communicate() + + except Exception as e: + Log.error(self, "Unable to check for packages upgrades") + + def dist_upgrade(self): + """ + Similar to `apt-get upgrade` + """ + try: + with open('/var/log/ee/ee.log', 'a') as f: + proc = subprocess.Popen("DEBIAN_FRONTEND=noninteractive " + "apt-get dist-upgrade -o " + "Dpkg::Options::=\"--force-confdef\"" + " -o " + "Dpkg::Options::=\"--force-confold\"" + " -y ", + shell=True, stdin=None, + stdout=f, stderr=f, + executable="/bin/bash") + proc.wait() + + if proc.returncode == 0: + return True + else: + Log.error(self, "Unable to run apt-get dist_upgrade") + except Exception as e: + Log.error(self, "Error while installing packages, " + "apt-get exited with error") def install(self, packages): 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}" + proc = subprocess.Popen("DEBIAN_FRONTEND=noninteractive " + "apt-get install -o " + "Dpkg::Options::=\"--force-confdef\"" + " -o " + "Dpkg::Options::=\"--force-confold\"" + " -y {0}" .format(all_packages), shell=True, stdin=None, stdout=f, stderr=f, executable="/bin/bash") diff --git a/ee/core/variables.py b/ee/core/variables.py index ac2e51ab..8cbea03d 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -12,10 +12,10 @@ class EEVariables(): """Intialization of core variables""" # EasyEngine version - ee_version = "3.1.1" + ee_version = "3.1.2" # EasyEngine packages versions - ee_wp_cli = "0.18.0" + ee_wp_cli = "0.19.0" ee_adminer = "4.2.1" ee_roundcube = "1.1.1" ee_vimbadmin = "3.0.11" @@ -28,6 +28,15 @@ class EEVariables(): ee_platform_version = platform.linux_distribution()[1] ee_platform_codename = os.popen("lsb_release -sc | tr -d \'\\n\'").read() + # Get timezone of system + if os.path.isfile('/etc/timezone'): + with open("/etc/timezone", "r") as tzfile: + ee_timezone = tzfile.read().replace('\n', '') + if ee_timezone == "Etc/UTC": + ee_timezone = "UTC" + else: + ee_timezone = "UTC" + # Get FQDN of system ee_fqdn = socket.getfqdn() @@ -77,14 +86,17 @@ class EEVariables(): # PHP repo and packages if ee_platform_distro == 'Ubuntu': - ee_php_repo = "ppa:ondrej/php5" + ee_php_repo = "ppa:ondrej/php5-5.6" elif ee_platform_codename == 'wheezy': - ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php55 all" + ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php56 all" .format(codename=ee_platform_codename)) ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap", - "php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline", + "php5-mcrypt", "php5-common", "php5-readline", "php5-mysql", "php5-cli", "php5-memcache", "php5-imagick", - "memcached", "graphviz"] + "memcached", "graphviz", "php-pear", "php5-dev"] + + if ee_platform_distro == 'Ubuntu': + ee_php = ee_php + ["php5-xdebug"] # MySQL repo and packages if ee_platform_distro == 'Ubuntu': diff --git a/install b/install index 81c862b5..5041992f 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.1.1" +readonly ee_version_new="3.1.2" 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}') @@ -301,9 +301,9 @@ function ee_update_latest() fi # Fix HHVM autostart on reboot - dpkg -l | grep hhvm &>> /dev/null + dpkg --get-selections | grep -v deinstall | grep hhvm &>> /dev/null if [ $? -eq 0 ]; then - sudo update-rc.d hhvm defaults &>> /dev/null + update-rc.d hhvm defaults &>> /dev/null fi } @@ -372,3 +372,11 @@ else fi fi ee sync | tee -ai $EE_INSTALL_LOG + +echo +ee_lib_echo "For EasyEngine (ee) auto completion, run the following command" +echo +ee_lib_echo_info "source /etc/bash_completion.d/ee_auto.rc" +echo +ee_lib_echo "EasyEngine (ee) installed successfully" +ee_lib_echo "EasyEngine (ee) help: http://docs.rtcamp.com/easyengine/" diff --git a/setup.py b/setup.py index 9c58ca4b..082ffa24 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.1.1', + version='3.1.2', description=long_description, long_description=long_description, classifiers=[], @@ -97,13 +97,3 @@ setup(name='ee', """, namespace_packages=[], ) - -print("""\033[94m -For EasyEngine (ee) auto completion, run the following command -\033[92m -source /etc/bash_completion.d/ee_auto.rc -\033[94m -EasyEngine (ee) installed successfully -EasyEngine (ee) help: http://docs.rtcamp.com/easyengine/ -\033[0m -""")