Browse Source

updated log messages

bugfixes
shital.rtcamp 10 years ago
parent
commit
56eb2d20cb
  1. 2
      config/ee.conf
  2. 1
      ee/cli/plugins/secure.py
  3. 4
      ee/cli/plugins/site_functions.py
  4. 156
      ee/cli/plugins/stack.py
  5. 10
      ee/cli/plugins/stack_services.py
  6. 3
      ee/core/download.py
  7. 6
      ee/core/fileutils.py
  8. 11
      tests/cli/97_test_site_update.py

2
config/ee.conf

@ -27,7 +27,7 @@ file = /var/log/ee/ee.log
level = debug level = debug
### Whether or not to log to console ### Whether or not to log to console
to_console = true to_console = false
### Whether or not to rotate the log file when it reaches `max_bytes` ### Whether or not to rotate the log file when it reaches `max_bytes`
rotate = true rotate = true

1
ee/cli/plugins/secure.py

@ -98,7 +98,6 @@ class EEsecureController(CementBaseController):
ip = ['127.0.0.1'] ip = ['127.0.0.1']
self.app.config.set('mysql', 'grant-host', "hello") self.app.config.set('mysql', 'grant-host', "hello")
exist_ip_list = self.app.config.get('stack', 'ip-address').split() exist_ip_list = self.app.config.get('stack', 'ip-address').split()
print(exist_ip_list)
for check_ip in user_list_ip: for check_ip in user_list_ip:
if check_ip not in exist_ip_list: if check_ip not in exist_ip_list:
newlist.extend(exist_ip_list) newlist.extend(exist_ip_list)

4
ee/cli/plugins/site_functions.py

@ -363,12 +363,12 @@ def site_package_check(self, stype):
apt_packages = apt_packages + EEVariables.ee_mysql apt_packages = apt_packages + EEVariables.ee_mysql
if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']: if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PostFix") Log.debug(self, "Setting apt_packages variable for Postfix")
if not EEAptGet.is_installed(self, 'postfix'): if not EEAptGet.is_installed(self, 'postfix'):
apt_packages = apt_packages + EEVariables.ee_postfix apt_packages = apt_packages + EEVariables.ee_postfix
if stype in ['wp', 'wpsubdir', 'wpsubdomain']: if stype in ['wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting packages variable for WPCLI") Log.debug(self, "Setting packages variable for WP-CLI")
if not EEShellExec.cmd_exec(self, "which wp"): if not EEShellExec.cmd_exec(self, "which wp"):
packages = packages + [["https://github.com/wp-cli/wp-cli/" packages = packages + [["https://github.com/wp-cli/wp-cli/"
"releases/download/v0.17.1/" "releases/download/v0.17.1/"

156
ee/cli/plugins/stack.py

@ -62,20 +62,15 @@ class EEStackController(CementBaseController):
dict(help='Install Utils stack', action='store_true')), dict(help='Install Utils stack', action='store_true')),
] ]
@expose(hide=True)
def package_check(self, packages=[]):
# Function for packages check
pass
@expose(hide=True) @expose(hide=True)
def default(self): def default(self):
# TODO Default action for ee stack command # TODO Default action for ee stack command
Log.info(self, "Inside EEStackController.default().") self.app.args.print_help()
@expose(hide=True) @expose(hide=True)
def pre_pref(self, apt_packages): def pre_pref(self, apt_packages):
if set(EEVariables.ee_postfix).issubset(set(apt_packages)): if set(EEVariables.ee_postfix).issubset(set(apt_packages)):
Log.info(self, "Pre-seeding postfix variables ... ") Log.info(self, "Pre-seeding Postfix")
EEShellExec.cmd_exec(self, "echo \"postfix postfix" EEShellExec.cmd_exec(self, "echo \"postfix postfix"
"/main_mailer_type string \'Internet Site\'\"" "/main_mailer_type string \'Internet Site\'\""
" | debconf-set-selections") " | debconf-set-selections")
@ -83,12 +78,13 @@ class EEStackController(CementBaseController):
" $(hostname -f)\" | debconf-set-selections") " $(hostname -f)\" | debconf-set-selections")
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 ... ") Log.info(self, "Adding repository for MySQL")
EERepo.add(self, repo_url=EEVariables.ee_mysql_repo) EERepo.add(self, repo_url=EEVariables.ee_mysql_repo)
Log.debug(self, 'Adding key of MySQL.') Log.debug(self, 'Adding key for {0}'
.format(EEVariables.ee_mysql_repo))
EERepo.add_key(self, '1C4CBDCDCD2EFD2A') EERepo.add_key(self, '1C4CBDCDCD2EFD2A')
chars = ''.join(random.sample(string.ascii_letters, 8)) chars = ''.join(random.sample(string.ascii_letters, 8))
Log.info(self, "Pre-seeding MySQL variables ... ") Log.info(self, "Pre-seeding MySQL")
EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 "
"percona-server-server/root_password " "percona-server-server/root_password "
"password {chars}\" | " "password {chars}\" | "
@ -104,21 +100,21 @@ class EEStackController(CementBaseController):
""".format(chars=chars) """.format(chars=chars)
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read_string(mysql_config) config.read_string(mysql_config)
Log.debug(self, 'writting configartion into MySQL file.') Log.debug(self, 'Writting configuration into MySQL file')
with open(os.path.expanduser("~")+'/.my.cnf', 'w') as configfile: with open(os.path.expanduser("~")+'/.my.cnf', 'w') as configfile:
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 ... ") Log.info(self, "Adding repository for Nginx")
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)
else: else:
Log.debug(self, 'Adding ppa of Nginx')
EERepo.add(self, ppa=EEVariables.ee_nginx_repo) EERepo.add(self, ppa=EEVariables.ee_nginx_repo)
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 ... ") Log.info(self, "Adding repository for PHP")
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)
@ -130,7 +126,7 @@ class EEStackController(CementBaseController):
if set(EEVariables.ee_mail).issubset(set(apt_packages)): if set(EEVariables.ee_mail).issubset(set(apt_packages)):
if EEVariables.ee_platform_codename == 'squeeze': if EEVariables.ee_platform_codename == 'squeeze':
Log.info(self, "Adding repository for dovecot ... ") Log.info(self, "Adding repository for dovecot ")
EERepo.add(self, repo_url=EEVariables.ee_dovecot_repo) EERepo.add(self, repo_url=EEVariables.ee_dovecot_repo)
Log.debug(self, 'Executing the command debconf-set-selections.') Log.debug(self, 'Executing the command debconf-set-selections.')
EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core/" EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core/"
@ -161,13 +157,13 @@ class EEStackController(CementBaseController):
[('worker_connections', '4096'), [('worker_connections', '4096'),
('multi_accept', 'on')]}, position=4) ('multi_accept', 'on')]}, position=4)
nc.set([('http',), 'keepalive_timeout'], '30') nc.set([('http',), 'keepalive_timeout'], '30')
Log.debug(self, "Writting nginx configration to " Log.debug(self, "Writting nginx configuration to "
"file /etc/nginx/nginx.conf ") "file /etc/nginx/nginx.conf ")
nc.savef('/etc/nginx/nginx.conf') nc.savef('/etc/nginx/nginx.conf')
# Custom Nginx configuration by EasyEngine # Custom Nginx configuration by EasyEngine
data = dict(version=EEVariables.ee_version) data = dict(version=EEVariables.ee_version)
Log.debug(self, 'writting the nginx configration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/ee-nginx.conf ') 'file /etc/nginx/conf.d/ee-nginx.conf ')
ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w') ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w')
self.app.render((data), 'nginx-core.mustache', self.app.render((data), 'nginx-core.mustache',
@ -175,20 +171,20 @@ class EEStackController(CementBaseController):
ee_nginx.close() ee_nginx.close()
data = dict() data = dict()
Log.debug(self, 'writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/blockips.conf') 'file /etc/nginx/conf.d/blockips.conf')
ee_nginx = open('/etc/nginx/conf.d/blockips.conf', 'w') ee_nginx = open('/etc/nginx/conf.d/blockips.conf', 'w')
self.app.render((data), 'blockips.mustache', out=ee_nginx) self.app.render((data), 'blockips.mustache', out=ee_nginx)
ee_nginx.close() ee_nginx.close()
Log.debug(self, 'writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/fastcgi.conf') 'file /etc/nginx/conf.d/fastcgi.conf')
ee_nginx = open('/etc/nginx/conf.d/fastcgi.conf', 'w') ee_nginx = open('/etc/nginx/conf.d/fastcgi.conf', 'w')
self.app.render((data), 'fastcgi.mustache', out=ee_nginx) self.app.render((data), 'fastcgi.mustache', out=ee_nginx)
ee_nginx.close() ee_nginx.close()
data = dict(php="9000", debug="9001") data = dict(php="9000", debug="9001")
Log.debug(self, 'writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/upstream.conf ') 'file /etc/nginx/conf.d/upstream.conf ')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w')
self.app.render((data), 'upstream.mustache', out=ee_nginx) self.app.render((data), 'upstream.mustache', out=ee_nginx)
@ -201,56 +197,56 @@ class EEStackController(CementBaseController):
os.makedirs('/etc/nginx/common') os.makedirs('/etc/nginx/common')
data = dict() data = dict()
Log.debug(self, 'Writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/acl.conf') 'file /etc/nginx/common/acl.conf')
ee_nginx = open('/etc/nginx/common/acl.conf', 'w') ee_nginx = open('/etc/nginx/common/acl.conf', 'w')
self.app.render((data), 'acl.mustache', self.app.render((data), 'acl.mustache',
out=ee_nginx) out=ee_nginx)
ee_nginx.close() ee_nginx.close()
Log.debug(self, 'Writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/locations.conf') 'file /etc/nginx/common/locations.conf')
ee_nginx = open('/etc/nginx/common/locations.conf', 'w') ee_nginx = open('/etc/nginx/common/locations.conf', 'w')
self.app.render((data), 'locations.mustache', self.app.render((data), 'locations.mustache',
out=ee_nginx) out=ee_nginx)
ee_nginx.close() ee_nginx.close()
Log.debug(self, 'Writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/ php.conf') 'file /etc/nginx/common/ php.conf')
ee_nginx = open('/etc/nginx/common/php.conf', 'w') ee_nginx = open('/etc/nginx/common/php.conf', 'w')
self.app.render((data), 'php.mustache', self.app.render((data), 'php.mustache',
out=ee_nginx) out=ee_nginx)
ee_nginx.close() ee_nginx.close()
Log.debug(self, 'Writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/w3tc.conf') 'file /etc/nginx/common/w3tc.conf')
ee_nginx = open('/etc/nginx/common/w3tc.conf', 'w') ee_nginx = open('/etc/nginx/common/w3tc.conf', 'w')
self.app.render((data), 'w3tc.mustache', self.app.render((data), 'w3tc.mustache',
out=ee_nginx) out=ee_nginx)
ee_nginx.close() ee_nginx.close()
Log.debug(self, 'Writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpcommon.conf') 'file /etc/nginx/common/wpcommon.conf')
ee_nginx = open('/etc/nginx/common/wpcommon.conf', 'w') ee_nginx = open('/etc/nginx/common/wpcommon.conf', 'w')
self.app.render((data), 'wpcommon.mustache', self.app.render((data), 'wpcommon.mustache',
out=ee_nginx) out=ee_nginx)
ee_nginx.close() ee_nginx.close()
Log.debug(self, 'Writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpfc.conf') 'file /etc/nginx/common/wpfc.conf')
ee_nginx = open('/etc/nginx/common/wpfc.conf', 'w') ee_nginx = open('/etc/nginx/common/wpfc.conf', 'w')
self.app.render((data), 'wpfc.mustache', self.app.render((data), 'wpfc.mustache',
out=ee_nginx) out=ee_nginx)
ee_nginx.close() ee_nginx.close()
Log.debug(self, 'Writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsc.conf') 'file /etc/nginx/common/wpsc.conf')
ee_nginx = open('/etc/nginx/common/wpsc.conf', 'w') ee_nginx = open('/etc/nginx/common/wpsc.conf', 'w')
self.app.render((data), 'wpsc.mustache', self.app.render((data), 'wpsc.mustache',
out=ee_nginx) out=ee_nginx)
ee_nginx.close() ee_nginx.close()
Log.debug(self, 'Writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsubdir.conf') 'file /etc/nginx/common/wpsubdir.conf')
ee_nginx = open('/etc/nginx/common/wpsubdir.conf', 'w') ee_nginx = open('/etc/nginx/common/wpsubdir.conf', 'w')
self.app.render((data), 'wpsubdir.mustache', self.app.render((data), 'wpsubdir.mustache',
@ -258,7 +254,7 @@ class EEStackController(CementBaseController):
ee_nginx.close() ee_nginx.close()
# 22222 port settings # 22222 port settings
Log.debug(self, 'Writting the nginx configration to' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/sites-available/' 'file /etc/nginx/sites-available/'
'22222.conf') '22222.conf')
ee_nginx = open('/etc/nginx/sites-available/22222.conf', ee_nginx = open('/etc/nginx/sites-available/22222.conf',
@ -285,9 +281,13 @@ class EEStackController(CementBaseController):
'22222.conf']) '22222.conf'])
# Create log and cert folder and softlinks # Create log and cert folder and softlinks
if not os.path.exists('/var/www/22222/logs'): if not os.path.exists('/var/www/22222/logs'):
Log.debug(self, "Creating directory "
"/var/www/22222/logs ")
os.makedirs('/var/www/22222/logs') os.makedirs('/var/www/22222/logs')
if not os.path.exists('/var/www/22222/cert'): if not os.path.exists('/var/www/22222/cert'):
Log.debug(self, "Creating directory "
"/var/www/22222/cert")
os.makedirs('/var/www/22222/cert') os.makedirs('/var/www/22222/cert')
EEFileUtils.create_symlink(self, ['/var/log/nginx/' EEFileUtils.create_symlink(self, ['/var/log/nginx/'
@ -337,7 +337,7 @@ class EEStackController(CementBaseController):
# Parse etc/php5/fpm/php.ini # Parse etc/php5/fpm/php.ini
config = configparser.ConfigParser() config = configparser.ConfigParser()
Log.debug(self, "configring php file /etc/php5/fpm/php.ini") Log.debug(self, "configuring php file /etc/php5/fpm/php.ini")
config.read('/etc/php5/fpm/php.ini') config.read('/etc/php5/fpm/php.ini')
config['PHP']['expose_php'] = 'Off' config['PHP']['expose_php'] = 'Off'
config['PHP']['post_max_size'] = '100M' config['PHP']['post_max_size'] = '100M'
@ -345,8 +345,8 @@ class EEStackController(CementBaseController):
config['PHP']['max_execution_time'] = '300' config['PHP']['max_execution_time'] = '300'
config['PHP']['date.timezone'] = time.tzname[time.daylight] config['PHP']['date.timezone'] = time.tzname[time.daylight]
with open('/etc/php5/fpm/php.ini', 'w') as configfile: with open('/etc/php5/fpm/php.ini', 'w') as configfile:
Log.debug(self, "writting configration of php in to" Log.debug(self, "Writting php configuration into "
"file /etc/php5/fpm/php.ini") "/etc/php5/fpm/php.ini")
config.write(configfile) config.write(configfile)
# Prase /etc/php5/fpm/php-fpm.conf # Prase /etc/php5/fpm/php-fpm.conf
@ -354,7 +354,7 @@ class EEStackController(CementBaseController):
config.read('/etc/php5/fpm/php-fpm.conf') config.read('/etc/php5/fpm/php-fpm.conf')
config['global']['error_log'] = '/var/log/php5/fpm.log' config['global']['error_log'] = '/var/log/php5/fpm.log'
with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile:
Log.debug(self, "writting php5 configartion into " Log.debug(self, "writting php5 configuration into "
"/etc/php5/fpm/php-fpm.conf") "/etc/php5/fpm/php-fpm.conf")
config.write(configfile) config.write(configfile)
@ -372,7 +372,7 @@ class EEStackController(CementBaseController):
config['www']['pm'] = 'ondemand' config['www']['pm'] = 'ondemand'
config['www']['listen'] = '127.0.0.1:9000' config['www']['listen'] = '127.0.0.1:9000'
with open('/etc/php5/fpm/pool.d/www.conf', 'w') as configfile: with open('/etc/php5/fpm/pool.d/www.conf', 'w') as configfile:
Log.debug(self, "writting PHP5 configartion into " Log.debug(self, "writting PHP5 configuration into "
"/etc/php5/fpm/pool.d/www.conf") "/etc/php5/fpm/pool.d/www.conf")
config.write(configfile) config.write(configfile)
@ -385,7 +385,7 @@ 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'
with open('/etc/php5/fpm/pool.d/debug.conf', 'w') as confifile: with open('/etc/php5/fpm/pool.d/debug.conf', 'w') as confifile:
Log.debug(self, "writting PHP5 configartion into " Log.debug(self, "writting PHP5 configuration into "
"/etc/php5/fpm/pool.d/debug.conf") "/etc/php5/fpm/pool.d/debug.conf")
config.write(confifile) config.write(confifile)
@ -425,7 +425,7 @@ class EEStackController(CementBaseController):
EEService.reload_service(self, 'mysql') EEService.reload_service(self, 'mysql')
if set(EEVariables.ee_mail).issubset(set(apt_packages)): if set(EEVariables.ee_mail).issubset(set(apt_packages)):
Log.debug(self, "Executing mail commands") Log.debug(self, "Adding user")
EEShellExec.cmd_exec(self, "adduser --uid 5000 --home /var" EEShellExec.cmd_exec(self, "adduser --uid 5000 --home /var"
"/vmail --disabled-password --gecos ''" "/vmail --disabled-password --gecos ''"
" vmail") " vmail")
@ -436,14 +436,14 @@ class EEStackController(CementBaseController):
"pem -keyout /etc/ssl/private/dovecot.pem" "pem -keyout /etc/ssl/private/dovecot.pem"
.format(HOSTNAME=EEVariables.ee_fqdn, .format(HOSTNAME=EEVariables.ee_fqdn,
EMAIL=EEVariables.ee_email)) EMAIL=EEVariables.ee_email))
Log.debug(self, "Adding Privillages to file " Log.debug(self, "Setting Privileges to "
"/etc/ssl/private/dovecot.pem ") "/etc/ssl/private/dovecot.pem file ")
EEShellExec.cmd_exec(self, "chmod 0600 /etc/ssl/private" EEShellExec.cmd_exec(self, "chmod 0600 /etc/ssl/private"
"/dovecot.pem") "/dovecot.pem")
# Custom Dovecot configuration by EasyEngine # Custom Dovecot configuration by EasyEngine
data = dict() data = dict()
Log.debug(self, "Writting configration into file" Log.debug(self, "Writting configuration into file"
"/etc/dovecot/conf.d/99-ee.conf ") "/etc/dovecot/conf.d/99-ee.conf ")
ee_dovecot = open('/etc/dovecot/conf.d/99-ee.conf', 'w') ee_dovecot = open('/etc/dovecot/conf.d/99-ee.conf', 'w')
self.app.render((data), 'dovecot.mustache', out=ee_dovecot) self.app.render((data), 'dovecot.mustache', out=ee_dovecot)
@ -520,7 +520,7 @@ class EEStackController(CementBaseController):
# Custom sieve configuration by EasyEngine # Custom sieve configuration by EasyEngine
data = dict() data = dict()
Log.debug(self, "Writting configaration of EasyEngine into" Log.debug(self, "Writting configuration of EasyEngine into "
"file /var/lib/dovecot/sieve/default.sieve") "file /var/lib/dovecot/sieve/default.sieve")
ee_sieve = open('/var/lib/dovecot/sieve/default.sieve', 'w') ee_sieve = open('/var/lib/dovecot/sieve/default.sieve', 'w')
self.app.render((data), 'default-sieve.mustache', self.app.render((data), 'default-sieve.mustache',
@ -528,7 +528,7 @@ class EEStackController(CementBaseController):
ee_sieve.close() ee_sieve.close()
# Compile sieve rules # Compile sieve rules
Log.debug(self, "Privillages to dovecot ") Log.debug(self, "Setting Privileges to dovecot ")
# EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib" # EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib"
# "/dovecot") # "/dovecot")
EEFileUtils.chown(self, "/var/lig/dovecot", "vmail", "vmail", EEFileUtils.chown(self, "/var/lig/dovecot", "vmail", "vmail",
@ -565,13 +565,13 @@ class EEStackController(CementBaseController):
EEShellExec.cmd_exec(self, "adduser clamav amavis") EEShellExec.cmd_exec(self, "adduser clamav amavis")
Log.debug(self, "Adding new user amavis clamav") Log.debug(self, "Adding new user amavis clamav")
EEShellExec.cmd_exec(self, "adduser amavis clamav") EEShellExec.cmd_exec(self, "adduser amavis clamav")
Log.debug(self, "Privillages to file /var/lib/amavis/tmp ") Log.debug(self, "Setting Privileges to /var/lib/amavis/tmp ")
EEShellExec.cmd_exec(self, "chmod -R 775 /var/lib/amavis/tmp") EEShellExec.cmd_exec(self, "chmod -R 775 /var/lib/amavis/tmp")
# Update ClamAV database # Update ClamAV database
Log.debug(self, "Updating database") Log.debug(self, "Updating database")
EEShellExec.cmd_exec(self, "freshclam") EEShellExec.cmd_exec(self, "freshclam")
Log.debug(self, "Restarting service clamav-daemon") Log.debug(self, "Restarting clamav-daemon service")
EEShellExec.cmd_exec(self, "service clamav-daemon restart") EEShellExec.cmd_exec(self, "service clamav-daemon restart")
EEGit.add(self, ["/etc/amavis"], msg="Adding Amvis into Git") EEGit.add(self, ["/etc/amavis"], msg="Adding Amvis into Git")
EEService.reload_service(self, 'dovecot') EEService.reload_service(self, 'dovecot')
@ -580,7 +580,7 @@ class EEStackController(CementBaseController):
if len(packages): if len(packages):
if any('/usr/bin/wp' == x[1] for x in packages): if any('/usr/bin/wp' == x[1] for x in packages):
Log.debug(self, "Privillages to /usr/bin/wp ") Log.debug(self, "Setting Privileges to /usr/bin/wp file ")
EEShellExec.cmd_exec(self, "chmod +x /usr/bin/wp") EEShellExec.cmd_exec(self, "chmod +x /usr/bin/wp")
if any('/tmp/pma.tar.gz' == x[1] if any('/tmp/pma.tar.gz' == x[1]
for x in packages): for x in packages):
@ -593,8 +593,8 @@ class EEStackController(CementBaseController):
os.makedirs('/var/www/22222/htdocs/db') os.makedirs('/var/www/22222/htdocs/db')
shutil.move('/tmp/phpmyadmin-STABLE/', shutil.move('/tmp/phpmyadmin-STABLE/',
'/var/www/22222/htdocs/db/pma/') '/var/www/22222/htdocs/db/pma/')
Log.debug(self, 'Privillages to www-data:www-data ' Log.debug(self, 'Setting Privileges of www-data:www-data to '
'/var/www/22222/htdocs/db/pma ') '/var/www/22222/htdocs/db/pma file ')
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/db/pma') # '/var/www/22222/htdocs/db/pma')
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '/var/www/22222',
@ -606,8 +606,8 @@ class EEStackController(CementBaseController):
" /var/www/22222/htdocs/cache/memcache ") " /var/www/22222/htdocs/cache/memcache ")
EEExtract.extract(self, '/tmp/memcache.tar.gz', EEExtract.extract(self, '/tmp/memcache.tar.gz',
'/var/www/22222/htdocs/cache/memcache') '/var/www/22222/htdocs/cache/memcache')
Log.debug(self, "Privillages to" Log.debug(self, "Setting Privileges to "
" /var/www/22222/htdocs/cache/memcache") "/var/www/22222/htdocs/cache/memcache file")
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/cache/memcache') # '/var/www/22222/htdocs/cache/memcache')
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '/var/www/22222',
@ -625,8 +625,8 @@ class EEStackController(CementBaseController):
os.makedirs('/var/www/22222/htdocs/php') os.makedirs('/var/www/22222/htdocs/php')
shutil.move('/tmp/webgrind-master/', shutil.move('/tmp/webgrind-master/',
'/var/www/22222/htdocs/php/webgrind') '/var/www/22222/htdocs/php/webgrind')
Log.debug(self, "Privillages www-data:www-data " Log.debug(self, "Setting Privileges of www-data:www-data to "
"/var/www/22222/htdocs/php/webgrind/ ") "/var/www/22222/htdocs/php/webgrind/ file ")
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/php/webgrind/') # '/var/www/22222/htdocs/php/webgrind/')
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '/var/www/22222',
@ -739,7 +739,7 @@ class EEStackController(CementBaseController):
string.ascii_letters, 64))) string.ascii_letters, 64)))
config['user']['defaults.mailbox.' config['user']['defaults.mailbox.'
'password_salt'] = vm_salt 'password_salt'] = vm_salt
Log.debug(self, "Writting configration to file " Log.debug(self, "Writting configuration to file "
"/var/www/22222/htdocs/vimbadmin" "/var/www/22222/htdocs/vimbadmin"
"/application/configs/application.ini ") "/application/configs/application.ini ")
with open('/var/www/22222/htdocs/vimbadmin/application' with open('/var/www/22222/htdocs/vimbadmin/application'
@ -776,25 +776,26 @@ class EEStackController(CementBaseController):
out=vm_config) out=vm_config)
vm_config.close() vm_config.close()
Log.debug(self, "Configration of file " Log.debug(self, "Writting configuration to "
"/etc/postfix/mysql" "/etc/postfix/mysql"
"/virtual_domains_maps.cf") "/virtual_domains_maps.cf file")
vm_config = open('/etc/postfix/mysql/virtual_domains_maps.cf', vm_config = open('/etc/postfix/mysql/virtual_domains_maps.cf',
'w') 'w')
self.app.render((data), 'virtual_domains_maps.mustache', self.app.render((data), 'virtual_domains_maps.mustache',
out=vm_config) out=vm_config)
vm_config.close() vm_config.close()
Log.debug(self, "Configation of file " Log.debug(self, "Writting configuration to "
"/etc/postfix/mysql" "/etc/postfix/mysql"
"/virtual_mailbox_maps.cf ") "/virtual_mailbox_maps.cf file")
vm_config = open('/etc/postfix/mysql/virtual_mailbox_maps.cf', vm_config = open('/etc/postfix/mysql/virtual_mailbox_maps.cf',
'w') 'w')
self.app.render((data), 'virtual_mailbox_maps.mustache', self.app.render((data), 'virtual_mailbox_maps.mustache',
out=vm_config) out=vm_config)
vm_config.close() vm_config.close()
Log.debug(self, "Configration of file ") Log.debug(self, "Writting configration"
" to /etc/dovecot/dovecot-sql.conf.ext file ")
vm_config = open('/etc/dovecot/dovecot-sql.conf.ext', vm_config = open('/etc/dovecot/dovecot-sql.conf.ext',
'w') 'w')
self.app.render((data), 'dovecot-sql-conf.mustache', self.app.render((data), 'dovecot-sql-conf.mustache',
@ -876,7 +877,7 @@ class EEStackController(CementBaseController):
ee_db_user='', ee_db_pass='', ee_db_host='', ee_db_user='', ee_db_pass='', ee_db_host='',
rc=True) rc=True)
Log.debug(self, 'Writting the nginx configration for' Log.debug(self, 'Writting the nginx configuration for '
'RoundCubemail') 'RoundCubemail')
ee_rc = open('/etc/nginx/sites-available/webmail.conf', 'w') ee_rc = open('/etc/nginx/sites-available/webmail.conf', 'w')
self.app.render((data), 'virtualconf.mustache', self.app.render((data), 'virtualconf.mustache',
@ -909,7 +910,7 @@ class EEStackController(CementBaseController):
EEVariables.ee_php_user, EEVariables.ee_php_user,
EEVariables.ee_php_user, recursive=True) EEVariables.ee_php_user, recursive=True)
@expose() @expose(help="Install packages")
def install(self, packages=[], apt_packages=[]): def install(self, packages=[], apt_packages=[]):
self.msg = [] self.msg = []
try: try:
@ -964,43 +965,43 @@ class EEStackController(CementBaseController):
apt_packages = (apt_packages + apt_packages = (apt_packages +
EEVariables.ee_mailscanner) EEVariables.ee_mailscanner)
else: else:
Log.info(self, "Mail server is allready installed") Log.info(self, "Mail server is already installed")
if self.app.pargs.nginx: if self.app.pargs.nginx:
Log.debug(self, "Setting apt_packages variable for Nginx") Log.debug(self, "Setting apt_packages variable for Nginx")
if not EEAptGet.is_installed(self, 'nginx-common'): if not EEAptGet.is_installed(self, 'nginx-common'):
apt_packages = apt_packages + EEVariables.ee_nginx apt_packages = apt_packages + EEVariables.ee_nginx
else: else:
Log.info(self, "Nginx allready installed") Log.debug(self, "Nginx already installed")
if self.app.pargs.php: if self.app.pargs.php:
Log.debug(self, "Setting apt_packages variable for PHP") Log.debug(self, "Setting apt_packages variable for PHP")
if not EEAptGet.is_installed(self, 'php5-fpm'): if not EEAptGet.is_installed(self, 'php5-fpm'):
apt_packages = apt_packages + EEVariables.ee_php apt_packages = apt_packages + EEVariables.ee_php
else: else:
Log.info(self, "PHP allready installed") Log.debug(self, "PHP already installed")
if self.app.pargs.mysql: if self.app.pargs.mysql:
Log.debug(self, "Setting apt_packages variable for MySQL") Log.debug(self, "Setting apt_packages variable for MySQL")
if not EEShellExec.cmd_exec(self, "mysqladmin ping"): if not EEShellExec.cmd_exec(self, "mysqladmin ping"):
apt_packages = apt_packages + EEVariables.ee_mysql apt_packages = apt_packages + EEVariables.ee_mysql
else: else:
Log.info(self, "MySQL connection is allready alive") Log.debug(self, "MySQL connection is already alive")
if self.app.pargs.postfix: if self.app.pargs.postfix:
Log.debug(self, "Setting apt_packages variable for PostFix") Log.debug(self, "Setting apt_packages variable for Postfix")
if not EEAptGet.is_installed(self, 'postfix'): if not EEAptGet.is_installed(self, 'postfix'):
apt_packages = apt_packages + EEVariables.ee_postfix apt_packages = apt_packages + EEVariables.ee_postfix
else: else:
Log.info(self, "Postfix is allready installed") Log.debug(self, "Postfix is already installed")
if self.app.pargs.wpcli: if self.app.pargs.wpcli:
Log.debug(self, "Setting packages variable for WPCLI") Log.debug(self, "Setting packages variable for WP-CLI")
if not EEShellExec.cmd_exec(self, "which wp"): if not EEShellExec.cmd_exec(self, "which wp"):
packages = packages + [["https://github.com/wp-cli/wp-cli/" packages = packages + [["https://github.com/wp-cli/wp-cli/"
"releases/download/v{0}/" "releases/download/v{0}/"
"wp-cli-{0}.phar" "wp-cli-{0}.phar"
"".format(EEVariables.ee_wp_cli), "".format(EEVariables.ee_wp_cli),
"/usr/bin/wp", "/usr/bin/wp",
"WP_CLI"]] "WP-CLI"]]
else: else:
Log.info(self, "WP-CLI is allready installed") Log.debug(self, "WP-CLI is already installed")
if self.app.pargs.phpmyadmin: if self.app.pargs.phpmyadmin:
Log.debug(self, "Setting packages varible for phpMyAdmin ") Log.debug(self, "Setting packages varible for phpMyAdmin ")
packages = packages + [["https://github.com/phpmyadmin/" packages = packages + [["https://github.com/phpmyadmin/"
@ -1035,12 +1036,12 @@ class EEStackController(CementBaseController):
"opcache-gui/master/index.php", "opcache-gui/master/index.php",
"/var/www/22222/htdocs/" "/var/www/22222/htdocs/"
"cache/opcache/opgui.php", "cache/opcache/opgui.php",
"index.php"], "Opgui"],
["https://gist.github.com/ck-on/4959032" ["https://gist.github.com/ck-on/4959032"
"/raw/0b871b345fd6cfcd6d2be030c1f33d1" "/raw/0b871b345fd6cfcd6d2be030c1f33d1"
"ad6a475cb/ocp.php", "ad6a475cb/ocp.php",
"/var/www/22222/htdocs/cache/" "/var/www/22222/htdocs/cache/"
"opcache/ocp.php", "ocp.php"], "opcache/ocp.php", "OCP.php"],
["https://github.com/jokkedk/webgrind/" ["https://github.com/jokkedk/webgrind/"
"archive/master.tar.gz", "archive/master.tar.gz",
'/tmp/webgrind.tar.gz', 'Webgrind'], '/tmp/webgrind.tar.gz', 'Webgrind'],
@ -1050,7 +1051,7 @@ class EEStackController(CementBaseController):
"20110624220137-or26tn4" "20110624220137-or26tn4"
"expb9ul2a-16/pt-query-digest", "expb9ul2a-16/pt-query-digest",
"/usr/bin/pt-query-advisor", "/usr/bin/pt-query-advisor",
"pt-query-digest"], "pt-query-advisor"],
["https://github.com/box/Anemometer/" ["https://github.com/box/Anemometer/"
"archive/master.tar.gz", "archive/master.tar.gz",
'/tmp/anemometer.tar.gz', 'Anemometer'] '/tmp/anemometer.tar.gz', 'Anemometer']
@ -1065,9 +1066,6 @@ class EEStackController(CementBaseController):
EESwap.add(self) EESwap.add(self)
Log.debug(self, "Updating apt-cache") Log.debug(self, "Updating apt-cache")
EEAptGet.update(self) EEAptGet.update(self)
Log.debug(self, "Installing following: {0}"
.format(apt_packages))
print(apt_packages)
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))
@ -1079,7 +1077,7 @@ class EEStackController(CementBaseController):
Log.info(self, msg) Log.info(self, msg)
Log.info(self, "Successfully installed packages") Log.info(self, "Successfully installed packages")
@expose() @expose(help="Remove packages")
def remove(self): def remove(self):
apt_packages = [] apt_packages = []
packages = [] packages = []
@ -1135,16 +1133,16 @@ class EEStackController(CementBaseController):
packages = packages + ['/var/www/22222/htdocs/db/pma'] packages = packages + ['/var/www/22222/htdocs/db/pma']
if self.app.pargs.adminer: if self.app.pargs.adminer:
Log.debug(self, "Removing package variable of Adminer ") Log.debug(self, "Removing package variable of Adminer ")
packages = packages + ['/var/www/22222/htdocs/db/adminer'] packages = packages + ['/var/www/22222/htdocs/db/Adminer']
if self.app.pargs.utils: if self.app.pargs.utils:
Log.debug(self, "Removing package variable of utils ") Log.debug(self, "Removing package variable of utils ")
packages = packages + ['/var/www/22222/htdocs/php/webgrind/', packages = packages + ['/var/www/22222/htdocs/php/webgrind/',
'/var/www/22222/htdocs/cache/opcache', '/var/www/22222/htdocs/cache/opcache',
'/var/www/22222/htdocs/cache/nginx/' '/var/www/22222/htdocs/cache/Nginx/'
'clean.php', 'clean.php',
'/var/www/22222/htdocs/cache/memcache', '/var/www/22222/htdocs/cache/Memcache',
'/usr/bin/pt-query-advisor', '/usr/bin/pt-query-advisor',
'/var/www/22222/htdocs/db/anemometer'] '/var/www/22222/htdocs/db/Anemometer']
if len(apt_packages): if len(apt_packages):
Log.debug(self, "Removing apt_packages") Log.debug(self, "Removing apt_packages")
@ -1153,7 +1151,7 @@ class EEStackController(CementBaseController):
EEFileUtils.remove(self, packages) EEFileUtils.remove(self, packages)
Log.info(self, "Successfully removed packages") Log.info(self, "Successfully removed packages")
@expose() @expose(help="Purge packages")
def purge(self): def purge(self):
apt_packages = [] apt_packages = []
packages = [] packages = []

10
ee/cli/plugins/stack_services.py

@ -17,7 +17,7 @@ class EEStackStatusController(CementBaseController):
dict(help='start/stop/restart dovecot', action='store_true')), dict(help='start/stop/restart dovecot', action='store_true')),
] ]
@expose(help="start stack services") @expose(help="Start stack services")
def start(self): def start(self):
services = [] services = []
if self.app.pargs.nginx: if self.app.pargs.nginx:
@ -44,7 +44,7 @@ class EEStackStatusController(CementBaseController):
for service in services: for service in services:
EEService.start_service(self, service) EEService.start_service(self, service)
@expose(help="stop stack services") @expose(help="Stop stack services")
def stop(self): def stop(self):
services = [] services = []
if self.app.pargs.nginx: if self.app.pargs.nginx:
@ -71,7 +71,7 @@ class EEStackStatusController(CementBaseController):
for service in services: for service in services:
EEService.stop_service(self, service) EEService.stop_service(self, service)
@expose(help="restart stack services") @expose(help="Restart stack services")
def restart(self): def restart(self):
services = [] services = []
if self.app.pargs.nginx: if self.app.pargs.nginx:
@ -98,7 +98,7 @@ class EEStackStatusController(CementBaseController):
Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart") Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart")
EEService.restart_service(self, service) EEService.restart_service(self, service)
@expose(help="get stack status") @expose(help="Get stack status")
def status(self): def status(self):
services = [] services = []
if self.app.pargs.nginx: if self.app.pargs.nginx:
@ -126,7 +126,7 @@ class EEStackStatusController(CementBaseController):
if EEService.get_service_status(self, service): if EEService.get_service_status(self, service):
Log.info(self, "{0:10}: {1}".format(service, "Running")) Log.info(self, "{0:10}: {1}".format(service, "Running"))
@expose(help="reload stack services") @expose(help="Reload stack services")
def reload(self): def reload(self):
services = [] services = []
if self.app.pargs.nginx: if self.app.pargs.nginx:

3
ee/core/download.py

@ -19,8 +19,9 @@ class EEDownload():
directory = os.path.dirname(filename) directory = os.path.dirname(filename)
if not os.path.exists(directory): if not os.path.exists(directory):
os.makedirs(directory) os.makedirs(directory)
Log.info(self, "Downloading "+pkg_name+" ...") Log.info(self, "Downloading {0:20}".format(pkg_name), end=' ')
urllib.request.urlretrieve(url, filename) urllib.request.urlretrieve(url, filename)
Log.info(self, "{0}".format("[ Done ]"))
except urllib.error.URLError as e: except urllib.error.URLError as e:
Log.debug(self, "[{err}]".format(err=str(e.reason))) Log.debug(self, "[{err}]".format(err=str(e.reason)))
Log.error(self, "Unable to donwload file, {0}" Log.error(self, "Unable to donwload file, {0}"

6
ee/core/fileutils.py

@ -16,13 +16,15 @@ class EEFileUtils():
def remove(self, filelist): def remove(self, filelist):
for file in filelist: for file in filelist:
if os.path.isfile(file): if os.path.isfile(file):
Log.info(self, "Removing "+os.path.basename(file)+" ...") Log.info(self, "Removing {0:65}".format(file), end=' ')
os.remove(file) os.remove(file)
Log.info(self, "{0}".format("[Done]"))
Log.debug(self, 'file Removed') Log.debug(self, 'file Removed')
if os.path.isdir(file): if os.path.isdir(file):
try: try:
Log.info(self, "Removing "+os.path.basename(file)+"...") Log.info(self, "Removing {0:65}".format(file), end=' ')
shutil.rmtree(file) shutil.rmtree(file)
Log.info(self, "{0}".format("[Done]"))
except shutil.Error as e: except shutil.Error as e:
Log.debug(self, "{err}".format(err=str(e.reason))) Log.debug(self, "{err}".format(err=str(e.reason)))
Log.error(self, 'Unable to Remove file ') Log.error(self, 'Unable to Remove file ')

11
tests/cli/97_test_site_update.py

@ -1,5 +1,5 @@
from ee.utils import test from ee.utils import test
from ee.cli.main import get_test_app from ee.cli.plugins.site import EESiteUpdateController
class CliTestCaseSite(test.EETestCase): class CliTestCaseSite(test.EETestCase):
@ -10,15 +10,13 @@ class CliTestCaseSite(test.EETestCase):
self.app.close() self.app.close()
def test_ee_cli_site_update(self): def test_ee_cli_site_update(self):
self.app = get_test_app(argv=['site', 'update', 'example5.com', self.ok(self.config.has_key('EESiteUpdateController', 'debug'))
'--password'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
def test_ee_cli_site_update_html(self): def test_ee_cli_site_update_html(self):
self.app = get_test_app(argv=['site', 'update', 'example2.com', self.ok(self.config.has_key('EESiteUpdateController', 'debug'))
'--html'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()
@ -38,8 +36,7 @@ class CliTestCaseSite(test.EETestCase):
self.app.close() self.app.close()
def test_ee_cli_site_update_wp(self): def test_ee_cli_site_update_wp(self):
self.app = get_test_app(argv=['site', 'update', 'example5.com', self.ok(self.config.has_key('EESiteUpdateController', 'debug'))
'--wp'])
self.app.setup() self.app.setup()
self.app.run() self.app.run()
self.app.close() self.app.close()

Loading…
Cancel
Save