Browse Source

modified function name according to pep

bugfixes
harshadyeola 10 years ago
parent
commit
47f6b87365
  1. 157
      ee/cli/plugins/site.py
  2. 49
      ee/cli/plugins/site_functions.py
  3. 8
      ee/cli/plugins/sitedb.py
  4. 14
      ee/cli/plugins/stack_services.py
  5. 1
      ee/core/aptget.py
  6. 8
      ee/core/mysql.py

157
ee/cli/plugins/site.py

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

49
ee/cli/plugins/site_functions.py

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

14
ee/cli/plugins/stack_services.py

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

1
ee/core/aptget.py

@ -170,7 +170,6 @@ class EEAptGet():
.format(package_name=pkg.name)) .format(package_name=pkg.name))
continue continue
my_selected_packages.append(pkg.name) my_selected_packages.append(pkg.name)
print(my_selected_packages)
# How logic works: # How logic works:
# 1) We loop trough dependencies's dependencies and add them to # 1) We loop trough dependencies's dependencies and add them to
# the list. # the list.

8
ee/core/mysql.py

@ -44,11 +44,13 @@ class EEMysql():
try: try:
cur.execute(statement) cur.execute(statement)
except Exception as e: except Exception as e:
Log.error(self, 'Unable to execute statement:')
Lod.debug(self, "{0}".format(e))
cur.close() cur.close()
conn.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() cur.close()
conn.close() conn.close()

Loading…
Cancel
Save