Browse Source

Merged code, cleaned outputhandler

bugfixes
gau1991 10 years ago
parent
commit
d0bc5f22f5
  1. 2
      ee/cli/main.py
  2. 175
      ee/cli/plugins/site.py
  3. 51
      ee/cli/plugins/site_functions.py
  4. 8
      ee/cli/plugins/sitedb.py
  5. 14
      ee/cli/plugins/stack_services.py
  6. 9
      ee/core/apt_repo.py
  7. 11
      ee/core/aptget.py
  8. 8
      ee/core/mysql.py
  9. 4
      ee/core/variables.py

2
ee/cli/main.py

@ -47,7 +47,7 @@ class EEApp(foundation.CementApp):
# Internal plugins (ship with application code)
plugin_bootstrap = 'ee.cli.plugins'
extensions = ['mustache', 'json']
extensions = ['mustache']
# default output handler
output_handler = 'mustache'

175
ee/cli/plugins/site.py

@ -131,7 +131,7 @@ class EESiteController(CementBaseController):
.format(ee_domain))
f = open('/etc/nginx/sites-available/{0}'.format(ee_domain), "r")
text = f.read()
print(text)
Log.info(self, Log.ENDC + text)
f.close()
else:
Log.error(self, " site {0} does not exists".format(ee_domain))
@ -156,8 +156,8 @@ class EESiteCreateController(CementBaseController):
label = 'create'
stacked_on = 'site'
stacked_type = 'nested'
description = 'create command manages website configuration with the \
help of the following subcommands'
description = ('this commands set up configuration and installs '
'required files as options are provided')
arguments = [
(['site_name'],
dict(help='domain name for the site to be created.')),
@ -191,6 +191,7 @@ class EESiteCreateController(CementBaseController):
def default(self):
# self.app.render((data), 'default.mustache')
# Check domain name validation
data = ''
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_site_webroot = EEVariables.ee_webroot + ee_domain
@ -406,10 +407,10 @@ class EESiteCreateController(CementBaseController):
# Check rerequired packages are installed or not
site_package_check(self, stype)
# setup NGINX configuration, and webroot
setupDomain(self, data)
setupdomain(self, data)
# Setup database for MySQL site
if 'ee_db_name' in data.keys() and not data['wp']:
data = setupDatabase(self, data)
data = setupdatabase(self, data)
try:
eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot),
'w')
@ -430,7 +431,7 @@ class EESiteCreateController(CementBaseController):
# Setup WordPress if Wordpress site
if data['wp']:
ee_wp_creds = setupWordpress(self, data)
ee_wp_creds = setupwordpress(self, data)
# Service Nginx Reload
EEService.reload_service(self, 'nginx')
@ -438,11 +439,11 @@ class EESiteCreateController(CementBaseController):
msg="{0} created with {1} {2}"
.format(ee_www_domain, stype, cache))
# Setup Permissions for webroot
SetWebrootPermissions(self, data['webroot'])
setwebrootpermissions(self, data['webroot'])
if data['wp']:
Log.info(self, '\033[94m'+"WordPress Admin User :"
" {0}".format(ee_wp_creds['wp_user'])+'\033[0m')
Log.info(self, "WordPress Admin User Password : {0}"
Log.info(self, Log.ENDC + "WordPress Admin User :"
" {0}".format(ee_wp_creds['wp_user']))
Log.info(self, Log.ENDC + "WordPress Admin User Password : {0}"
.format(ee_wp_creds['wp_pass']))
addNewSite(self, ee_www_domain, stype, cache, ee_site_webroot)
Log.info(self, "Successfully created site"
@ -454,11 +455,14 @@ class EESiteUpdateController(CementBaseController):
label = 'update'
stacked_on = 'site'
stacked_type = 'nested'
description = 'Update command manages website configuration with the \
help of the following subcommands'
description = ('This command updates websites configuration to '
'another as per the options are provided')
arguments = [
(['site_name'],
dict(help='domain name for the site to be updated')),
(['--password'],
dict(help="update to password for wordpress site user",
action='store_true')),
(['--html'],
dict(help="update to html site", action='store_true')),
(['--php'],
@ -482,6 +486,7 @@ class EESiteUpdateController(CementBaseController):
@expose(help="Update site type or cache")
def default(self):
data = ''
(ee_domain,
ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name)
ee_site_webroot = EEVariables.ee_webroot + ee_domain
@ -494,13 +499,20 @@ class EESiteUpdateController(CementBaseController):
oldsitetype = check_site.site_type
oldcachetype = check_site.cache_type
print(oldsitetype, oldcachetype)
if (self.app.pargs.password and not (self.app.pargs.html or
self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or
self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc
or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)):
updatewpuserpassword(self, ee_domain, ee_site_webroot)
self.app.close(0)
if (self.app.pargs.html and not (self.app.pargs.php or
self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc or
self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)):
pass
Log.error(self, " Cannot update {0} {1} to html"
.format(ee_domain, oldsitetype))
# PHP
if (self.app.pargs.php and not (self.app.pargs.html or
@ -549,8 +561,8 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wp and not (self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc)):
if ((oldsitetype in ['html', 'php', 'mysql', 'wp'])
and (oldcachetype not in ['w3tc', 'wpfc', 'wpsc'])):
if ((oldsitetype not in ['html', 'php', 'mysql', 'wp'])
or (oldsitetype is 'wp' and oldcachetype is 'basic')):
print(oldsitetype, oldcachetype)
Log.error(self, " Cannot update {0}, {1} {2} to wp basic"
.format(ee_domain, oldsitetype, oldcachetype))
@ -568,9 +580,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.w3tc and not
(self.app.pargs.wpfc or self.app.pargs.wpsc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp']
and oldcachetype not in ['basic', 'wpfc', 'wpsc']):
Log.error(self, " Cannot update {0}, {1} {2}to wp w3tc"
if (oldsitetype not in ['html', 'php', 'mysql', 'wp']
or (oldsitetype is 'wp' and oldcachetype is 'w3tc')):
Log.error(self, " Cannot update {0}, {1} {2} to wp w3tc"
.format(ee_domain, oldsitetype, oldcachetype))
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
@ -587,8 +599,8 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpfc and not
(self.app.pargs.wpsc or self.app.pargs.w3tc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp']
and oldcachetype not in ['basic', 'w3tc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp']
or (oldsitetype is 'wp' and oldcachetype is 'wpfc')):
Log.error(self, "Cannot update {0}, {1} {2} to wp wpfc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -605,8 +617,8 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpsc and not
(self.app.pargs.w3tc or self.app.pargs.wpfc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp']
and oldcachetype not in ['basic', 'w3tc', 'wpfc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp']
or (oldsitetype is 'wp' and oldcachetype is 'wpsc')):
Log.error(self, "Cannot update {0}, {1} {2} to wp wpsc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -627,8 +639,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir']
and oldcachetype not in ['w3tc', 'wpfc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'basic')):
Log.error(self, " Cannot update {0}, {1} {2} "
"to wpsubdir basic"
.format(ee_domain, oldsitetype, oldcachetype))
@ -646,8 +659,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.w3tc and not
(self.app.pargs.wpfc or self.app.pargs.wpsc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir']
and oldcachetype not in ['basic', 'wpfc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'w3tc')):
Log.error(self, " Cannot update {0} {1} {2}"
"to wpsubdir w3tc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -666,8 +680,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpfc and not
(self.app.pargs.wpsc or self.app.pargs.w3tc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir']
and oldcachetype not in ['basic', 'w3tc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'wpfc')):
Log.error(self, " Cannot update {0} {1} {2}"
" to wpsubdir wpfc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -685,8 +700,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpsc and not
(self.app.pargs.w3tc or self.app.pargs.wpfc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir']
and oldcachetype not in ['basic', 'w3tc', 'wpfc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdir']
or (oldsitetype is 'wpsubdir' and oldcachetype is 'wpsc')):
Log.error(self, " Cannot update {0} {1} {2}"
" to wpsubdir wpsc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -705,8 +721,9 @@ class EESiteUpdateController(CementBaseController):
self.app.pargs.php or self.app.pargs.mysql or
self.app.pargs.wpsubdir or self.app.pargs.wp)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdomain']
and oldcachetype not in ['w3tc', 'wpfc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain']
or (oldsitetype is 'wpsubdomain' and oldcachetype is 'basic')):
Log.error(self, " Cannot update {0} {1} {2}"
" to wpsubdomain basic"
.format(ee_domain, oldsitetype, oldcachetype))
@ -725,9 +742,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.w3tc and not
(self.app.pargs.wpfc or self.app.pargs.wpsc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp',
'wpsubdomain']
and oldcachetype not in ['basic', 'wpfc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain'] or
(oldsitetype is 'wpsubdomain' and oldcachetype is 'w3tc')):
Log.error(self, " Cannot update {0}, {1} {2}"
" to wpsubdomain w3tc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -746,9 +763,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpfc and not
(self.app.pargs.wpsc or self.app.pargs.w3tc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp',
'wpsubdomain']
and oldcachetype not in ['basic', 'w3tc', 'wpsc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain'] or
(oldsitetype is 'wpsubdomain' and oldcachetype is 'wpfc')):
Log.error(self, " Cannot update {0}, {1} {2} "
"to wpsubdomain wpfc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -767,9 +784,9 @@ class EESiteUpdateController(CementBaseController):
if (self.app.pargs.wpsc and not
(self.app.pargs.w3tc or self.app.pargs.wpfc)):
if (oldsitetype in ['html', 'php', 'mysql', 'wp',
'wpsubdomain']
and oldcachetype not in ['basic', 'w3tc', 'wpfc']):
if (oldsitetype not in ['html', 'php', 'mysql', 'wp',
'wpsubdomain'] or
(oldsitetype is 'wpsubdomain' and oldcachetype is 'wpsc')):
Log.error(self, " Cannot update {0}, {1} {2}"
" to wpsubdomain wpsc"
.format(ee_domain, oldsitetype, oldcachetype))
@ -786,17 +803,17 @@ class EESiteUpdateController(CementBaseController):
cache = 'wpsc'
if not data:
Log.error(self, " Cannot update"
Log.error(self, " Cannot update {0}, Invalid Options"
.format(ee_domain))
site_package_check(self, stype)
siteBackup(self, data)
# TODO Check for required packages before update
sitebackup(self, data)
# setup NGINX configuration, and webroot
setupDomain(self, data)
setupdomain(self, data)
if 'ee_db_name' in data.keys() and not data['wp']:
data = setupDatabase(self, data)
data = setupdatabase(self, data)
try:
eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot),
'w')
@ -816,45 +833,44 @@ class EESiteUpdateController(CementBaseController):
if oldsitetype == 'mysql':
config_file = (ee_site_webroot + '/backup/{0}/ee-config.php'
.format(EEVariables.ee_date))
data['ee_db_name'] = EEFileUtils.grep(EEFileUtils
.grep(self, config_file,
'DB_NAME')
.split(',')[1]
.split(')')[0].strip())
data['ee_db_user'] = EEFileUtils.grep(EEFileUtils
.grep(self, config_file,
'DB_USER')
.split(',')[1]
.split(')')[0].strip())
data['ee_db_pass'] = EEFileUtils.grep(EEFileUtils
.grep(self, config_file,
'DB_PASSWORD')
.split(',')[1]
.split(')')[0].strip())
print(config_file, 'DB_NAME')
data['ee_db_name'] = (EEFileUtils.grep(self, config_file,
'DB_NAME')
.split(',')[1]
.split(')')[0].strip())
data['ee_db_user'] = (EEFileUtils.grep(self, config_file,
'DB_USER')
.split(',')[1]
.split(')')[0].strip())
data['ee_db_pass'] = (EEFileUtils.grep(self, config_file,
'DB_PASSWORD')
.split(',')[1]
.split(')')[0].strip())
# Setup WordPress if old sites are html/php/mysql sites
if data['wp'] and oldsitetype in ['html', 'php', 'mysql']:
ee_wp_creds = setupWordpress(self, data)
ee_wp_creds = setupwordpress(self, data)
# Uninstall unnecessary plugins
if oldsitetype in ['wp', 'wpsubdir', 'wpsubdomain']:
# Setup WordPress Network if update option is multisite
# and oldsite is WordPress single site
if data['multisite'] and oldsitetype == 'wp':
setupWordpressNetwork(self, data)
setupwordpressnetwork(self, data)
if (oldcachetype == 'w3tc' or oldcachetype == 'wpfc' and
not data['w3tc', 'wpfc']):
uninstallWP_Plugin(self, 'w3-total-cache', data)
not (data['w3tc'] or data['wpfc'])):
uninstallwp_plugin(self, 'w3-total-cache', data)
if oldcachetype == 'wpsc' and not data['wpsc']:
uninstallWP_Plugin(self, 'wp-super-cache', data)
uninstallwp_plugin(self, 'wp-super-cache', data)
if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and data['w3tc']:
installWP_Plugin(self, 'w3-total-cache', data)
if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and (data['w3tc']
or data['wpfc']):
installwp_plugin(self, 'w3-total-cache', data)
if oldcachetype != 'wpsc' and data['wpsc']:
installWP_Plugin(self, 'wp-super-cache', data)
installwp_plugin(self, 'wp-super-cache', data)
# Service Nginx Reload
EEService.reload_service(self, 'nginx')
@ -863,7 +879,13 @@ class EESiteUpdateController(CementBaseController):
msg="{0} updated with {1} {2}"
.format(ee_www_domain, stype, cache))
# Setup Permissions for webroot
# SetWebrootPermissions(self, data['webroot'])
# setwebrootpermissions(self, data['webroot'])
if data['wp'] and oldsitetype in ['html', 'php', 'mysql']:
Log.info(self, Log.ENDC + "WordPress Admin User :"
" {0}".format(ee_wp_creds['wp_user']))
Log.info(self, Log.ENDC + "WordPress Admin User Password : {0}"
.format(ee_wp_creds['wp_pass']))
updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache)
Log.info(self, "Successfully updated site"
@ -890,12 +912,13 @@ class EESiteDeleteController(CementBaseController):
dict(help="delete webroot only", action='store_true')),
]
@expose(help="Delete site")
@expose(help="Delete website configuration and files")
def default(self):
# TODO Write code for ee site update here
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_db_name = ''
ee_prompt = ''
ee_nginx_prompt = ''
if ((not self.app.pargs.db) and (not self.app.pargs.files) and
(not self.app.pargs.all)):
@ -914,7 +937,7 @@ class EESiteDeleteController(CementBaseController):
'[Y/N]: ')
else:
ee_db_prompt = 'Y'
ee_nginx_prompt = 'Y'
if ee_db_prompt == 'Y' or ee_db_prompt == 'y':
self.deleteDB(ee_site_webroot)
@ -924,7 +947,6 @@ class EESiteDeleteController(CementBaseController):
'[Y/N]: ')
else:
ee_web_prompt = 'Y'
ee_nginx_prompt = 'Y'
if ee_web_prompt == 'Y' or ee_web_prompt == 'y':
self.deleteWebRoot(ee_site_webroot)
@ -949,9 +971,10 @@ class EESiteDeleteController(CementBaseController):
self.deleteWebRoot(ee_site_webroot)
if (ee_nginx_prompt == 'Y' or ee_nginx_prompt == 'y'):
Log.debug(self, "Removing Nginx configuration")
EEFileUtils.rm(self, '/etc/nginx/sites-available/{0}'
.format(ee_domain))
deleteSiteInfo(self, ee_domain)
deleteSiteInfo(self, ee_domain)
Log.info(self, "Deleted site {0}".format(ee_domain))
else:
Log.error(self, " site {0} does not exists".format(ee_domain))
@ -1007,7 +1030,7 @@ class EESiteListController(CementBaseController):
dict(help="List disabled websites", action='store_true')),
]
@expose(help="Delete example.com")
@expose(help="Lists websites")
def default(self):
sites = getAllsites(self)
if not sites:

51
ee/cli/plugins/site_functions.py

@ -13,11 +13,11 @@ import getpass
import glob
def setupDomain(self, data):
def setupdomain(self, data):
ee_domain_name = data['site_name']
ee_site_webroot = data['webroot']
Log.info(self, "Setting up NGINX configuration ", end='')
Log.info(self, "Setting up NGINX configuration \t\t", end='')
# write nginx config for file
try:
ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}'
@ -41,7 +41,7 @@ def setupDomain(self, data):
.format(ee_domain_name)])
# Creating htdocs & logs directory
Log.info(self, "Setting up webroot ", end='')
Log.info(self, "Setting up webroot \t\t", end='')
try:
if not os.path.exists('{0}/htdocs'.format(ee_site_webroot)):
os.makedirs('{0}/htdocs'.format(ee_site_webroot))
@ -62,7 +62,7 @@ def setupDomain(self, data):
Log.info(self, "[Done]")
def setupDatabase(self, data):
def setupdatabase(self, data):
ee_domain_name = data['site_name']
ee_random = (''.join(random.sample(string.ascii_uppercase +
string.ascii_lowercase + string.digits, 15)))
@ -89,8 +89,9 @@ def setupDatabase(self, data):
try:
ee_db_username = input('Enter the MySQL database user name [{0}]: '
.format(ee_replace_dot))
ee_db_password = input('Enter the MySQL database password [{0}]: '
.format(ee_random))
ee_db_password = getpass.getpass(prompt='Enter the MySQL database'
' password [{0}]: '
.format(ee_random))
except EOFError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to input database credentials")
@ -102,13 +103,13 @@ def setupDatabase(self, data):
if len(ee_db_username) > 16:
Log.info(self, 'Autofix MySQL username (ERROR 1470 (HY000)),'
' please wait...')
' please wait')
ee_random10 = (''.join(random.sample(string.ascii_uppercase +
string.ascii_lowercase + string.digits, 10)))
ee_db_name = (ee_db_name[0:6] + ee_random10)
# create MySQL database
Log.info(self, "Setting Up Database ", end='')
Log.info(self, "Setting up database\t\t", end='')
Log.debug(self, "Creating databse {0}".format(ee_db_name))
EEMysql.execute(self, "create database {0}"
.format(ee_db_name))
@ -134,7 +135,7 @@ def setupDatabase(self, data):
return(data)
def setupWordpress(self, data):
def setupwordpress(self, data):
ee_domain_name = data['site_name']
ee_site_webroot = data['webroot']
prompt_wpprefix = self.app.config.get('wordpress', 'prefix')
@ -148,13 +149,13 @@ def setupWordpress(self, data):
ee_wp_user = ''
ee_wp_pass = ''
Log.info(self, "Downloading Wordpress ", end='')
Log.info(self, "Downloading Wordpress \t\t", end='')
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
EEShellExec.cmd_exec(self, "wp --allow-root core download")
Log.info(self, "[Done]")
if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']):
data = setupDatabase(self, data)
data = setupdatabase(self, data)
if prompt_wpprefix == 'True' or prompt_wpprefix == 'true':
try:
ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: '
@ -251,15 +252,15 @@ def setupWordpress(self, data):
errormsg="Unable to Update WordPress permalink")
"""Install nginx-helper plugin """
installWP_Plugin(self, 'nginx-helper', data)
installwp_plugin(self, 'nginx-helper', data)
"""Install Wp Super Cache"""
if data['wpsc']:
installWP_Plugin(self, 'wp-super-cache', data)
installwp_plugin(self, 'wp-super-cache', data)
"""Install W3 Total Cache"""
if data['w3tc'] or data['wpfc']:
installWP_Plugin(self, 'w3-total-cache', data)
installwp_plugin(self, 'w3-total-cache', data)
wp_creds = dict(wp_user=ee_wp_user, wp_pass=ee_wp_pass,
wp_email=ee_wp_email)
@ -267,10 +268,10 @@ def setupWordpress(self, data):
return(wp_creds)
def setupWordpressNetwork(self, data):
def setupwordpressnetwork(self, data):
ee_site_webroot = data['webroot']
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
Log.info(self, "Setting up WordPress Network ", end='')
Log.info(self, "Setting up WordPress Network \t\t", end='')
EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert'
' --title={0} {subdomains}'
.format(data['www_domain'], subdomains='--subdomains'
@ -278,7 +279,7 @@ def setupWordpressNetwork(self, data):
Log.info(self, "Done")
def installWP_Plugin(self, plugin_name, data):
def installwp_plugin(self, plugin_name, data):
ee_site_webroot = data['webroot']
Log.debug(self, "Installing plugin {0}".format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
@ -295,7 +296,7 @@ def installWP_Plugin(self, plugin_name, data):
.format(plugin_name))
def uninstallWP_Plugin(self, plugin_name, data):
def uninstallwp_plugin(self, plugin_name, data):
ee_site_webroot = data['webroot']
Log.debug(self, "Uninstalling plugin {0}".format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
@ -305,13 +306,13 @@ def uninstallWP_Plugin(self, plugin_name, data):
.format(plugin_name))
def SetWebrootPermissions(self, webroot):
Log.debug(self, "Setting up permissions...")
def setwebrootpermissions(self, webroot):
Log.debug(self, "Setting up permissions")
EEFileUtils.chown(self, webroot, EEVariables.ee_php_user,
EEVariables.ee_php_user, recursive=True)
def siteBackup(self, data):
def sitebackup(self, data):
ee_site_webroot = data['webroot']
backup_path = ee_site_webroot + '/backup/{0}'.format(EEVariables.ee_date)
if not EEFileUtils.isexist(self, backup_path):
@ -321,7 +322,7 @@ def siteBackup(self, data):
.format(data['site_name']), backup_path)
if data['currsitetype'] in ['html', 'php', 'mysql']:
Log.info(self, "Backing up Webroot ", end='')
Log.info(self, "Backing up Webroot \t\t", end='')
EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path)
Log.info(self, "[Done]")
@ -331,7 +332,7 @@ def siteBackup(self, data):
ee_db_name = (EEFileUtils.grep(self, configfiles[0],
'DB_NAME').split(',')[1]
.split(')')[0].strip().replace('\'', ''))
Log.info(self, 'Backing up database ', end='')
Log.info(self, 'Backing up database \t\t', end='')
EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql"
.format(ee_db_name, backup_path),
errormsg="\nFailed: Backup Database")
@ -378,7 +379,7 @@ def site_package_check(self, stype):
stack.install(apt_packages=apt_packages, packages=packages)
def updateWPuserPassword(self, ee_domain, ee_site_webroot):
def updatewpuserpassword(self, ee_domain, ee_site_webroot):
ee_wp_user = ''
ee_wp_pass = ''
@ -412,7 +413,7 @@ def updateWPuserPassword(self, ee_domain, ee_site_webroot):
if is_user_exist:
ee_wp_pass = input("Provide password for {0} user: "
.format(ee_wp_user))
if len(ee_wp_pass) < 8:
if len(ee_wp_pass) > 8:
EEShellExec.cmd_exec(self, "wp --allow-root user update {0}"
" --user_pass={1}"
.format(ee_wp_user, ee_wp_pass))

8
ee/cli/plugins/sitedb.py

@ -35,6 +35,10 @@ def updateSiteInfo(self, site, stype='', cache='',
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to query database for site info")
if not q:
Log.error(self, "{0} does not exist in database".format(site))
if stype and q.site_type != stype:
q.site_type = stype
@ -61,6 +65,10 @@ def deleteSiteInfo(self, site):
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to query database")
if not q:
Log.error(self, "{0} does not exist in database".format(site))
try:
db_session.delete(q)
db_session.commit()

14
ee/cli/plugins/stack_services.py

@ -130,25 +130,25 @@ class EEStackStatusController(CementBaseController):
def reload(self):
services = []
if self.app.pargs.nginx:
Log.debug(self, "nginx service restart")
Log.debug(self, "nginx service reload")
services = services + ['nginx']
elif self.app.pargs.php:
Log.debug(self, "php5-fpm service restart")
Log.debug(self, "php5-fpm service reload")
services = services + ['php5-fpm']
elif self.app.pargs.mysql:
Log.debug(self, "mysql service restart")
Log.debug(self, "mysql service reload")
services = services + ['mysql']
elif self.app.pargs.postfix:
Log.debug(self, "postfix service restart")
Log.debug(self, "postfix service reload")
services = services + ['postfix']
elif self.app.pargs.memcache:
Log.debug(self, "memcached service restart")
Log.debug(self, "memcached service reload")
services = services + ['memcached']
elif self.app.pargs.dovecot:
Log.debug(self, "dovecot service restart")
Log.debug(self, "dovecot service reload")
services = services + ['dovecot']
else:
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services:
Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart")
Log.debug(self, "nginx,php5-fpm,mysql,postfix services reload")
EEService.reload_service(self, service)

9
ee/core/apt_repo.py

@ -12,7 +12,6 @@ class EERepo():
pass
def add(self, repo_url=None, ppa=None):
# TODO add repository code
if repo_url is not None:
repo_file_path = ("/etc/apt/sources.list.d/"
@ -28,10 +27,11 @@ class EERepo():
repofile.close()
return True
except IOError as e:
print("File I/O error({0}): {1}".format(e.errno, e.strerror))
Log.debug(self, "{0}".format(e))
Log.error(self, "File I/O error.")
except Exception as e:
print("{error}".format(error=e))
return False
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to add repo")
if ppa is not None:
if EEVariables.ee_platform_distro == 'squeeze':
print("Cannot add repo for {distro}"
@ -42,7 +42,6 @@ class EERepo():
.format(ppa_name=ppa))
def remove(self, repo_url=None):
# TODO remove repository
EEShellExec.cmd_exec(self, "add-apt-repository -y "
"--remove '{ppa_name}'"
.format(ppa_name=repo_url))

11
ee/core/aptget.py

@ -59,7 +59,7 @@ class EEAptGet():
.format(space=cache.required_space))
try:
# Commit changes in cache (actually install)
cache.commit(fprogress, iprogress)
cache.commit(fprogress, iprogres)
except Exception as e:
print("package installation failed. [{err}]"
.format(err=str(e)))
@ -111,8 +111,8 @@ class EEAptGet():
.format(pkg_install_count=cache.install_count))
print("Need to get {req_download} bytes of archives"
.format(req_download=cache.required_download))
print("After this operation, {space} bytes of"
"additional disk space will be used."
print("After this operation, {space:.2f} MB of"
" additional disk space will be used."
.format(space=cache.required_space/1e6))
try:
# Commit changes in cache (actually install)
@ -170,7 +170,6 @@ class EEAptGet():
.format(package_name=pkg.name))
continue
my_selected_packages.append(pkg.name)
print(my_selected_packages)
# How logic works:
# 1) We loop trough dependencies's dependencies and add them to
# the list.
@ -211,8 +210,8 @@ class EEAptGet():
print("{pkg_remove_count} to remove."
.format(pkg_remove_count=cache.delete_count))
# app.log.debug('bytes disk space will be freed')
print("After this operation, {space} bytes disk spac"
"e will be freed.".format(space=cache.required_space))
print("After this operation, {space:.2f} MB disk space "
"will be freed.".format(space=cache.required_space/1e6))
try:
cache.commit(fprogress, iprogress)
except Exception as e:

8
ee/core/mysql.py

@ -44,11 +44,13 @@ class EEMysql():
try:
cur.execute(statement)
except Exception as e:
Log.error(self, 'Unable to execute statement:')
Lod.debug(self, "{0}".format(e))
cur.close()
conn.close()
sys.exit(1)
Log.debug(self, "{0}".format(e))
if not errormsg:
Log.error(self, 'Unable to execute statement')
else:
Log.error(self, '{0}'.format(errormsg))
cur.close()
conn.close()

4
ee/core/variables.py

@ -81,9 +81,9 @@ class EEVariables():
elif ee_platform_codename == 'wheezy':
ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php55 all"
.format(codename=ee_platform_codename))
ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-cli", "php5-imap",
ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap",
"php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline",
"php5-mysql", "memcached"]
"php5-mysql", "php5-cli", "memcached"]
# MySQL repo and packages
ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main"

Loading…
Cancel
Save