Browse Source

Merge branch 'master' of github.com:rtCamp/easyengine

bugfixes
harshadyeola 10 years ago
parent
commit
9a2fa3be49
  1. 3
      .travis.yml
  2. 9
      config/bash_completion.d/ee_auto.rc
  3. 17
      ee/cli/plugins/debug.py
  4. 2
      ee/cli/plugins/site.py
  5. 8
      ee/cli/plugins/site_functions.py
  6. 59
      ee/cli/plugins/stack.py
  7. 6
      ee/cli/plugins/stack_migrate.py
  8. 194
      ee/cli/plugins/stack_upgrade.py
  9. 2
      ee/cli/plugins/sync.py
  10. 2
      ee/cli/plugins/update.py
  11. 24
      ee/core/apt_repo.py
  12. 62
      ee/core/aptget.py
  13. 24
      ee/core/variables.py
  14. 14
      install
  15. 12
      setup.py

3
.travis.yml

@ -14,6 +14,7 @@ before_install:
- rm -rf ~/.gnupg - rm -rf ~/.gnupg
before_script: before_script:
- sudo rm -rf /etc/mysql/
- sudo bash -c 'echo example.com > /etc/hostname' - sudo bash -c 'echo example.com > /etc/hostname'
- sudo service hostname restart - sudo service hostname restart
- sudo apt-get -qq purge mysql* graphviz* - sudo apt-get -qq purge mysql* graphviz*
@ -22,7 +23,7 @@ before_script:
script: script:
- unset LANG - 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 echo "Travis Banch = $TRAVIS_BRANCH"
- sudo apt-get install -y --force-yes git python3-setuptools python3-dev python3-apt - sudo apt-get install -y --force-yes git python3-setuptools python3-dev python3-apt
- sudo bash install $TRAVIS_BRANCH - sudo bash install $TRAVIS_BRANCH

9
config/bash_completion.d/ee_auto.rc

@ -35,7 +35,7 @@ _ee_complete()
"stack") "stack")
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "install purge reload remove restart start status stop migrate" \ -W "upgrade install purge reload remove restart start status stop migrate" \
-- $cur) ) -- $cur) )
;; ;;
@ -74,7 +74,12 @@ _ee_complete()
# HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE # HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE
"install" | "purge" | "remove" ) "install" | "purge" | "remove" )
COMPREPLY=( $(compgen \ 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) ) -- $cur) )
;; ;;
"start" | "stop" | "reload" | "restart" | "status") "start" | "stop" | "reload" | "restart" | "status")

17
ee/cli/plugins/debug.py

@ -180,6 +180,17 @@ class EEDebugController(CementBaseController):
";zend_extension", ";zend_extension",
"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_php = True
self.trigger_nginx = True self.trigger_nginx = True
else: else:
@ -505,7 +516,7 @@ class EEDebugController(CementBaseController):
"'ee debug --import-slow-log'"): "'ee debug --import-slow-log'"):
if not cron_time == 0: if not cron_time == 0:
Log.info(self, "setting up crontab entry," Log.info(self, "setting up crontab entry,"
" please wait ...") " please wait...")
EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l " EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
"2> /dev/null | {{ cat; echo -e" "2> /dev/null | {{ cat; echo -e"
" \\\"#EasyEngine start MySQL " " \\\"#EasyEngine start MySQL "
@ -518,7 +529,7 @@ class EEDebugController(CementBaseController):
else: else:
if not cron_time == 0: if not cron_time == 0:
Log.info(self, "updating crontab entry," Log.info(self, "updating crontab entry,"
" please wait ...") " please wait...")
if not EEShellExec.cmd_exec(self, "/bin/bash -c " if not EEShellExec.cmd_exec(self, "/bin/bash -c "
"\"crontab " "\"crontab "
"-l | sed '/EasyEngine " "-l | sed '/EasyEngine "
@ -533,7 +544,7 @@ class EEDebugController(CementBaseController):
Log.error(self, "failed to update crontab entry") Log.error(self, "failed to update crontab entry")
else: else:
Log.info(self, "removing crontab entry," Log.info(self, "removing crontab entry,"
" please wait ...") " please wait...")
if not EEShellExec.cmd_exec(self, "/bin/bash -c " if not EEShellExec.cmd_exec(self, "/bin/bash -c "
"\"crontab " "\"crontab "
"-l | sed '/EasyEngine " "-l | sed '/EasyEngine "

2
ee/cli/plugins/site.py

@ -686,7 +686,7 @@ class EESiteUpdateController(CementBaseController):
for site in sites: for site in sites:
pargs.site_name = site.sitename pargs.site_name = site.sitename
Log.info(self, Log.ENDC + Log.BOLD + "Updating site {0}," Log.info(self, Log.ENDC + Log.BOLD + "Updating site {0},"
" please wait ..." " please wait..."
.format(pargs.site_name)) .format(pargs.site_name))
self.doupdatesite(pargs) self.doupdatesite(pargs)
print("\n") print("\n")

8
ee/cli/plugins/site_functions.py

@ -31,7 +31,7 @@ class SiteError(Exception):
def pre_run_checks(self): def pre_run_checks(self):
# Check nginx configuration # Check nginx configuration
Log.info(self, "Running pre-update checks, please wait ...") Log.info(self, "Running pre-update checks, please wait...")
try: try:
Log.debug(self, "checking NGINX configuration ...") Log.debug(self, "checking NGINX configuration ...")
FNULL = open('/dev/null', 'w') FNULL = open('/dev/null', 'w')
@ -78,7 +78,7 @@ def setupdomain(self, data):
finally: finally:
# Check nginx -t and return status over it # Check nginx -t and return status over it
try: try:
Log.debug(self, "Checking generated nginx conf, please wait ...") Log.debug(self, "Checking generated nginx conf, please wait...")
FNULL = open('/dev/null', 'w') FNULL = open('/dev/null', 'w')
ret = subprocess.check_call(["nginx", "-t"], stdout=FNULL, ret = subprocess.check_call(["nginx", "-t"], stdout=FNULL,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
@ -466,7 +466,7 @@ def setupwordpressnetwork(self, data):
def installwp_plugin(self, plugin_name, data): def installwp_plugin(self, plugin_name, data):
ee_site_webroot = data['webroot'] ee_site_webroot = data['webroot']
Log.info(self, "Installing plugin {0}, please wait ..." Log.info(self, "Installing plugin {0}, please wait..."
.format(plugin_name)) .format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
try: try:
@ -490,7 +490,7 @@ def installwp_plugin(self, plugin_name, data):
def uninstallwp_plugin(self, plugin_name, data): def uninstallwp_plugin(self, plugin_name, data):
ee_site_webroot = data['webroot'] ee_site_webroot = data['webroot']
Log.debug(self, "Uninstalling plugin {0}, please wait ..." Log.debug(self, "Uninstalling plugin {0}, please wait..."
.format(plugin_name)) .format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
try: try:

59
ee/cli/plugins/stack.py

@ -27,6 +27,7 @@ import grp
import codecs import codecs
from ee.cli.plugins.stack_services import EEStackStatusController from ee.cli.plugins.stack_services import EEStackStatusController
from ee.cli.plugins.stack_migrate import EEStackMigrateController from ee.cli.plugins.stack_migrate import EEStackMigrateController
from ee.cli.plugins.stack_upgrade import EEStackUpgradeController
from ee.core.logging import Log from ee.core.logging import Log
@ -95,7 +96,7 @@ class EEStackController(CementBaseController):
Log.error(self, "Failed to intialize postfix package") Log.error(self, "Failed to intialize postfix package")
if set(EEVariables.ee_mysql).issubset(set(apt_packages)): 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" mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au"
"\nPin-Priority: 1000\n") "\nPin-Priority: 1000\n")
with open('/etc/apt/preferences.d/' with open('/etc/apt/preferences.d/'
@ -149,7 +150,7 @@ class EEStackController(CementBaseController):
config.write(configfile) config.write(configfile)
if set(EEVariables.ee_nginx).issubset(set(apt_packages)): 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': if EEVariables.ee_platform_distro == 'debian':
Log.debug(self, 'Adding Dotdeb/nginx GPG key') Log.debug(self, 'Adding Dotdeb/nginx GPG key')
EERepo.add(self, repo_url=EEVariables.ee_nginx_repo) EERepo.add(self, repo_url=EEVariables.ee_nginx_repo)
@ -158,7 +159,7 @@ class EEStackController(CementBaseController):
Log.debug(self, 'Adding ppa of Nginx') Log.debug(self, 'Adding ppa of Nginx')
if set(EEVariables.ee_php).issubset(set(apt_packages)): 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': if EEVariables.ee_platform_distro == 'debian':
Log.debug(self, 'Adding repo_url of php for debian') Log.debug(self, 'Adding repo_url of php for debian')
EERepo.add(self, repo_url=EEVariables.ee_php_repo) EERepo.add(self, repo_url=EEVariables.ee_php_repo)
@ -169,7 +170,7 @@ class EEStackController(CementBaseController):
EERepo.add(self, ppa=EEVariables.ee_php_repo) EERepo.add(self, ppa=EEVariables.ee_php_repo)
if set(EEVariables.ee_hhvm).issubset(set(apt_packages)): 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': if EEVariables.ee_platform_codename == 'precise':
Log.debug(self, 'Adding PPA for Boost') Log.debug(self, 'Adding PPA for Boost')
EERepo.add(self, ppa=EEVariables.ee_boost_repo) EERepo.add(self, ppa=EEVariables.ee_boost_repo)
@ -469,6 +470,21 @@ class EEStackController(CementBaseController):
Log.debug(self, 'Creating directory /var/log/php5/') Log.debug(self, 'Creating directory /var/log/php5/')
os.makedirs('/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 # Parse etc/php5/fpm/php.ini
config = configparser.ConfigParser() config = configparser.ConfigParser()
Log.debug(self, "configuring php file /etc/php5/fpm/php.ini") 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']['post_max_size'] = '100M'
config['PHP']['upload_max_filesize'] = '100M' config['PHP']['upload_max_filesize'] = '100M'
config['PHP']['max_execution_time'] = '300' 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', with open('/etc/php5/fpm/php.ini',
encoding='utf-8', mode='w') as configfile: encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php configuration into " Log.debug(self, "Writting php configuration into "
@ -529,6 +545,8 @@ class EEStackController(CementBaseController):
config.read('/etc/php5/fpm/pool.d/debug.conf') config.read('/etc/php5/fpm/pool.d/debug.conf')
config['debug']['listen'] = '127.0.0.1:9001' config['debug']['listen'] = '127.0.0.1:9001'
config['debug']['rlimit_core'] = 'unlimited' 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', with open('/etc/php5/fpm/pool.d/debug.conf',
encoding='utf-8', mode='w') as confifile: encoding='utf-8', mode='w') as confifile:
Log.debug(self, "writting PHP5 configuration into " Log.debug(self, "writting PHP5 configuration into "
@ -590,7 +608,7 @@ class EEStackController(CementBaseController):
if set(EEVariables.ee_hhvm).issubset(set(apt_packages)): if set(EEVariables.ee_hhvm).issubset(set(apt_packages)):
EEShellExec.cmd_exec(self, "update-rc.d hhvm defaults") EEShellExec.cmd_exec(self, "update-rc.d hhvm defaults")
EEFileUtils.searchreplace(self, "/etc/hhvm/server.ini", EEFileUtils.searchreplace(self, "/etc/hhvm/server.ini",
"9000", "8000") "9000", "8000")
EEFileUtils.searchreplace(self, "/etc/nginx/hhvm.conf", EEFileUtils.searchreplace(self, "/etc/nginx/hhvm.conf",
@ -1008,10 +1026,22 @@ class EEStackController(CementBaseController):
shutil.move('/tmp/webgrind-master/', shutil.move('/tmp/webgrind-master/',
'{0}22222/htdocs/php/webgrind' '{0}22222/htdocs/php/webgrind'
.format(EEVariables.ee_webroot)) .format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "sed -i \"s\'/usr/local/bin/dot\'"
"/usr/bin/dot\'\" {0}22222/htdocs/" EEFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/"
"php/webgrind/config.php" "config.php"
.format(EEVariables.ee_webroot)) .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 " Log.debug(self, "Setting Privileges of webroot permission to "
"{0}22222/htdocs/php/webgrind/ file " "{0}22222/htdocs/php/webgrind/ file "
.format(EEVariables.ee_webroot)) .format(EEVariables.ee_webroot))
@ -1552,9 +1582,9 @@ class EEStackController(CementBaseController):
self.pre_pref(apt_packages) self.pre_pref(apt_packages)
if len(apt_packages): if len(apt_packages):
EESwap.add(self) EESwap.add(self)
Log.info(self, "Updating apt-cache, please wait ...") Log.info(self, "Updating apt-cache, please wait...")
EEAptGet.update(self) EEAptGet.update(self)
Log.info(self, "Installing packages, please wait ...") Log.info(self, "Installing packages, please wait...")
EEAptGet.install(self, apt_packages) EEAptGet.install(self, apt_packages)
if len(packages): if len(packages):
Log.debug(self, "Downloading following: {0}".format(packages)) Log.debug(self, "Downloading following: {0}".format(packages))
@ -1672,7 +1702,7 @@ class EEStackController(CementBaseController):
if len(apt_packages): if len(apt_packages):
if ee_prompt == 'YES' or ee_prompt == 'yes': if ee_prompt == 'YES' or ee_prompt == 'yes':
Log.debug(self, "Removing apt_packages") 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.remove(self, apt_packages)
EEAptGet.auto_remove(self) EEAptGet.auto_remove(self)
@ -1785,7 +1815,7 @@ class EEStackController(CementBaseController):
if len(apt_packages): if len(apt_packages):
if ee_prompt == 'YES' or ee_prompt == 'yes': 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.remove(self, apt_packages, purge=True)
EEAptGet.auto_remove(self) EEAptGet.auto_remove(self)
@ -1803,6 +1833,7 @@ def load(app):
handler.register(EEStackController) handler.register(EEStackController)
handler.register(EEStackStatusController) handler.register(EEStackStatusController)
handler.register(EEStackMigrateController) handler.register(EEStackMigrateController)
handler.register(EEStackUpgradeController)
# register a hook (function) to run after arguments are parsed. # register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', ee_stack_hook) hook.register('post_argument_parsing', ee_stack_hook)

6
ee/cli/plugins/stack_migrate.py

@ -31,7 +31,7 @@ class EEStackMigrateController(CementBaseController):
EEMysql.backupAll(self) EEMysql.backupAll(self)
# Add MariaDB repo # 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" mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au"
"\nPin-Priority: 1000\n") "\nPin-Priority: 1000\n")
@ -87,9 +87,9 @@ class EEStackMigrateController(CementBaseController):
apt_packages = apt_packages + ["dovecot-mysql", "postfix-mysql", apt_packages = apt_packages + ["dovecot-mysql", "postfix-mysql",
"libclass-dbi-mysql-perl"] "libclass-dbi-mysql-perl"]
Log.info(self, "Updating apt-cache, please wait ...") Log.info(self, "Updating apt-cache, please wait...")
EEAptGet.update(self) EEAptGet.update(self)
Log.info(self, "Installing MariaDB, please wait ...") Log.info(self, "Installing MariaDB, please wait...")
EEAptGet.remove(self, ["mysql-common", "libmysqlclient18"]) EEAptGet.remove(self, ["mysql-common", "libmysqlclient18"])
EEAptGet.auto_remove(self) EEAptGet.auto_remove(self)
EEAptGet.install(self, apt_packages) EEAptGet.install(self, apt_packages)

194
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()

2
ee/cli/plugins/sync.py

@ -28,7 +28,7 @@ class EESyncController(CementBaseController):
1. reads database information from wp/ee-config.php 1. reads database information from wp/ee-config.php
2. updates records into ee database accordingly. 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) sites = getAllsites(self)
if not sites: if not sites:
pass pass

2
ee/cli/plugins/update.py

@ -28,7 +28,7 @@ class EEUpdateController(CementBaseController):
"/tmp/{0}".format(filename), "/tmp/{0}".format(filename),
"update script"]]) "update script"]])
try: try:
Log.info(self, "updating EasyEngine, please wait ...") Log.info(self, "updating EasyEngine, please wait...")
os.system("bash /tmp/{0}".format(filename)) os.system("bash /tmp/{0}".format(filename))
except OSError as e: except OSError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))

24
ee/core/apt_repo.py

@ -1,6 +1,7 @@
"""EasyEngine packages repository operations""" """EasyEngine packages repository operations"""
from ee.core.shellexec import EEShellExec from ee.core.shellexec import EEShellExec
from ee.core.variables import EEVariables from ee.core.variables import EEVariables
from ee.core.logging import Log
import os import os
@ -54,16 +55,31 @@ class EERepo():
"'{ppa_name}'" "'{ppa_name}'"
.format(ppa_name=ppa)) .format(ppa_name=ppa))
def remove(self, ppa=None): def remove(self, ppa=None, repo_url=None):
""" """
This function used to remove ppa's This function used to remove ppa's
If ppa is provided adds repo file to If ppa is provided adds repo file to
/etc/apt/sources.list.d/ /etc/apt/sources.list.d/
command. command.
""" """
EEShellExec.cmd_exec(self, "add-apt-repository -y " if ppa:
"--remove '{ppa_name}'" EEShellExec.cmd_exec(self, "add-apt-repository -y "
.format(ppa_name=repo_url)) "--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): def add_key(self, keyids, keyserver=None):
""" """

62
ee/core/aptget.py

@ -32,32 +32,60 @@ class EEAptGet():
Log.error(self, "Error while installing packages, " Log.error(self, "Error while installing packages, "
"apt-get exited with error") "apt-get exited with error")
def dist_upgrade(): def check_upgrade(self):
""" """
Similar to `apt-get upgrade` Similar to `apt-get upgrade`
""" """
try: try:
apt_cache = apt.cache.Cache() check_update = subprocess.Popen(['apt-get upgrade -s | grep '
apt_cache.update() '\"^Inst\" | wc -l'],
apt_cache.open(None) stdout=subprocess.PIPE,
apt_cache.upgrade(True) shell=True).communicate()[0]
success = (apt_cache.commit( if check_update == b'0\n':
apt.progress.text.AcquireProgress(), Log.error(self, "No package updates available")
apt.progress.base.InstallProgress())) Log.info(self, "Following package updates are available:")
# apt_cache.close() subprocess.Popen("apt-get -s dist-upgrade | grep \"^Inst\"",
return success shell=True, executable="/bin/bash",
except AttributeError as e: stdout=sys.stdout).communicate()
Log.error(self, 'AttributeError: ' + str(e))
except FetchFailedException as e: except Exception as e:
Log.debug(self, 'SystemError: ' + str(e)) Log.error(self, "Unable to check for packages upgrades")
Log.error(self, 'Unable to Fetch update')
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): def install(self, packages):
all_packages = ' '.join(packages) all_packages = ' '.join(packages)
try: try:
with open('/var/log/ee/ee.log', 'a') as f: with open('/var/log/ee/ee.log', 'a') as f:
proc = subprocess.Popen("apt-get install -o Dpkg::Options::=--" proc = subprocess.Popen("DEBIAN_FRONTEND=noninteractive "
"force-confold -y {0}" "apt-get install -o "
"Dpkg::Options::=\"--force-confdef\""
" -o "
"Dpkg::Options::=\"--force-confold\""
" -y {0}"
.format(all_packages), shell=True, .format(all_packages), shell=True,
stdin=None, stdout=f, stderr=f, stdin=None, stdout=f, stderr=f,
executable="/bin/bash") executable="/bin/bash")

24
ee/core/variables.py

@ -12,10 +12,10 @@ class EEVariables():
"""Intialization of core variables""" """Intialization of core variables"""
# EasyEngine version # EasyEngine version
ee_version = "3.1.1" ee_version = "3.1.2"
# EasyEngine packages versions # EasyEngine packages versions
ee_wp_cli = "0.18.0" ee_wp_cli = "0.19.0"
ee_adminer = "4.2.1" ee_adminer = "4.2.1"
ee_roundcube = "1.1.1" ee_roundcube = "1.1.1"
ee_vimbadmin = "3.0.11" ee_vimbadmin = "3.0.11"
@ -28,6 +28,15 @@ class EEVariables():
ee_platform_version = platform.linux_distribution()[1] ee_platform_version = platform.linux_distribution()[1]
ee_platform_codename = os.popen("lsb_release -sc | tr -d \'\\n\'").read() 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 # Get FQDN of system
ee_fqdn = socket.getfqdn() ee_fqdn = socket.getfqdn()
@ -77,14 +86,17 @@ class EEVariables():
# PHP repo and packages # PHP repo and packages
if ee_platform_distro == 'Ubuntu': if ee_platform_distro == 'Ubuntu':
ee_php_repo = "ppa:ondrej/php5" ee_php_repo = "ppa:ondrej/php5-5.6"
elif ee_platform_codename == 'wheezy': 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)) .format(codename=ee_platform_codename))
ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap", 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", "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 # MySQL repo and packages
if ee_platform_distro == 'Ubuntu': if ee_platform_distro == 'Ubuntu':

14
install

@ -48,7 +48,7 @@ fi
# Define variables for later use # Define variables for later use
ee_branch=$1 ee_branch=$1
readonly ee_version_old="2.2.3" 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_log_dir=/var/log/ee/
readonly ee_install_log=/var/log/ee/install.log readonly ee_install_log=/var/log/ee/install.log
readonly ee_linux_distro=$(lsb_release -i | awk '{print $3}') readonly ee_linux_distro=$(lsb_release -i | awk '{print $3}')
@ -301,9 +301,9 @@ function ee_update_latest()
fi fi
# Fix HHVM autostart on reboot # 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 if [ $? -eq 0 ]; then
sudo update-rc.d hhvm defaults &>> /dev/null update-rc.d hhvm defaults &>> /dev/null
fi fi
} }
@ -372,3 +372,11 @@ else
fi fi
fi fi
ee sync | tee -ai $EE_INSTALL_LOG 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/"

12
setup.py

@ -54,7 +54,7 @@ except Exception as e:
os.system("git config --global user.email {0}".format(ee_email)) os.system("git config --global user.email {0}".format(ee_email))
setup(name='ee', setup(name='ee',
version='3.1.1', version='3.1.2',
description=long_description, description=long_description,
long_description=long_description, long_description=long_description,
classifiers=[], classifiers=[],
@ -97,13 +97,3 @@ setup(name='ee',
""", """,
namespace_packages=[], 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
""")

Loading…
Cancel
Save