Browse Source

update all done

bugfixes
harshadyeola 10 years ago
parent
commit
b5eba6cffe
  1. 71
      ee/cli/plugins/site.py
  2. 14
      ee/cli/plugins/site_functions.py

71
ee/cli/plugins/site.py

@ -604,34 +604,52 @@ class EESiteUpdateController(CementBaseController):
(['--pagespeed'], (['--pagespeed'],
dict(help='Use PageSpeed for site', dict(help='Use PageSpeed for site',
action='store' or 'store_const', action='store' or 'store_const',
choices=('on', 'off'), const='on', nargs='?')) choices=('on', 'off'), const='on', nargs='?')),
(['--all'],
dict(help="update all sites", action='store_true')),
] ]
@expose(help="Update site type or cache") @expose(help="Update site type or cache")
def default(self): def default(self):
pargs = self.app.pargs
if pargs.all:
sites = getAllsites(self)
if not sites:
Log.info(self, "no sites :(")
pass
else:
Log.info(self, "updating sites :)")
for site in sites:
pargs.site_name = site.sitename
Log.info(self, "Updating site {0}, please wait ..."
.format(pargs.site_name))
self.doupdatesite(pargs)
else:
self.doupdatesite(pargs)
def doupdatesite(self, pargs):
hhvm = None hhvm = None
pagespeed = None pagespeed = None
data = dict() data = dict()
try: try:
stype, cache = detSitePar(vars(self.app.pargs)) stype, cache = detSitePar(vars(pargs))
except RuntimeError as e: except RuntimeError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Please provide valid options combination for" Log.error(self, "Please provide valid options combination for"
" site update") " site update")
if not self.app.pargs.site_name: if not pargs.site_name:
try: try:
while not self.app.pargs.site_name: while not pargs.site_name:
self.app.pargs.site_name = (input('Enter site name : ') pargs.site_name = (input('Enter site name : ').strip())
.strip())
except IOError as e: except IOError as e:
Log.error(self, 'Unable to input site name, Please try again!') Log.error(self, 'Unable to input site name, Please try again!')
self.app.pargs.site_name = self.app.pargs.site_name.strip() pargs.site_name = pargs.site_name.strip()
(ee_domain, (ee_domain,
ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) ee_www_domain, ) = ValidateDomain(pargs.site_name)
ee_site_webroot = EEVariables.ee_webroot + ee_domain ee_site_webroot = EEVariables.ee_webroot + ee_domain
check_site = getSiteInfo(self, ee_domain) check_site = getSiteInfo(self, ee_domain)
@ -644,10 +662,10 @@ class EESiteUpdateController(CementBaseController):
old_hhvm = check_site.is_hhvm old_hhvm = check_site.is_hhvm
old_pagespeed = check_site.is_pagespeed old_pagespeed = check_site.is_pagespeed
if (self.app.pargs.password and not (self.app.pargs.html or if (pargs.password and not (pargs.html or
self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or pargs.php or pargs.mysql or pargs.wp or
self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc pargs.w3tc or pargs.wpfc or pargs.wpsc
or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): or pargs.wpsubdir or pargs.wpsubdomain)):
try: try:
updatewpuserpassword(self, ee_domain, ee_site_webroot) updatewpuserpassword(self, ee_domain, ee_site_webroot)
except SiteError as e: except SiteError as e:
@ -691,7 +709,7 @@ class EESiteUpdateController(CementBaseController):
if stype == 'wpsubdir': if stype == 'wpsubdir':
data['wpsubdir'] = True data['wpsubdir'] = True
if self.app.pargs.pagespeed or self.app.pargs.hhvm: if pargs.pagespeed or pargs.hhvm:
if not data: if not data:
data = dict(site_name=ee_domain, www_domain=ee_www_domain, data = dict(site_name=ee_domain, www_domain=ee_www_domain,
currsitetype=oldsitetype, currsitetype=oldsitetype,
@ -748,21 +766,21 @@ class EESiteUpdateController(CementBaseController):
data['wpfc'] = False data['wpfc'] = False
data['wpsc'] = True data['wpsc'] = True
if self.app.pargs.hhvm != 'off': if pargs.hhvm != 'off':
data['hhvm'] = True data['hhvm'] = True
hhvm = True hhvm = True
elif self.app.pargs.hhvm == 'off': elif pargs.hhvm == 'off':
data['hhvm'] = False data['hhvm'] = False
hhvm = False hhvm = False
if self.app.pargs.pagespeed != 'off': if pargs.pagespeed != 'off':
data['pagespeed'] = True data['pagespeed'] = True
pagespeed = True pagespeed = True
elif self.app.pargs.pagespeed == 'off': elif pargs.pagespeed == 'off':
data['pagespeed'] = False data['pagespeed'] = False
pagespeed = False pagespeed = False
if self.app.pargs.pagespeed: if pargs.pagespeed:
if pagespeed is old_pagespeed: if pagespeed is old_pagespeed:
if pagespeed is False: if pagespeed is False:
Log.info(self, "Pagespeed is allready disabled for given " Log.info(self, "Pagespeed is allready disabled for given "
@ -771,7 +789,7 @@ class EESiteUpdateController(CementBaseController):
Log.info(self, "Pagespeed is allready enabled for given " Log.info(self, "Pagespeed is allready enabled for given "
"site") "site")
if self.app.pargs.hhvm: if pargs.hhvm:
if hhvm is old_hhvm: if hhvm is old_hhvm:
if hhvm is False: if hhvm is False:
Log.info(self, "HHVM is allready disabled for given " Log.info(self, "HHVM is allready disabled for given "
@ -780,12 +798,12 @@ class EESiteUpdateController(CementBaseController):
Log.info(self, "HHVM is allready enabled for given " Log.info(self, "HHVM is allready enabled for given "
"site") "site")
if self.app.pargs.pagespeed or self.app.pargs.hhvm: if pargs.pagespeed or pargs.hhvm:
if ((hhvm is old_hhvm) and (pagespeed is old_pagespeed) and if ((hhvm is old_hhvm) and (pagespeed is old_pagespeed) and
(stype == oldsitetype and cache == oldcachetype)): (stype == oldsitetype and cache == oldcachetype)):
self.app.close(0) self.app.close(0)
if data and (not self.app.pargs.hhvm): if data and (not pargs.hhvm):
if old_hhvm is True: if old_hhvm is True:
data['hhvm'] = True data['hhvm'] = True
hhvm = True hhvm = True
@ -793,7 +811,7 @@ class EESiteUpdateController(CementBaseController):
data['hhvm'] = False data['hhvm'] = False
hhvm = False hhvm = False
if data and (not self.app.pargs.pagespeed): if data and (not pargs.pagespeed):
if old_pagespeed is True: if old_pagespeed is True:
data['pagespeed'] = True data['pagespeed'] = True
pagespeed = True pagespeed = True
@ -810,6 +828,13 @@ class EESiteUpdateController(CementBaseController):
data['ee_db_user'] = check_site.db_user data['ee_db_user'] = check_site.db_user
data['ee_db_pass'] = check_site.db_password data['ee_db_pass'] = check_site.db_password
data['ee_db_host'] = check_site.db_host data['ee_db_host'] = check_site.db_host
try:
pre_run_checks(self)
except SiteError as e:
Log.debug(self, str(e))
Log.error(self, "NGINX configuration check failed.")
try: try:
sitebackup(self, data) sitebackup(self, data)
except Exception as e: except Exception as e:
@ -826,7 +851,7 @@ class EESiteUpdateController(CementBaseController):
"`tail /var/log/ee/ee.log` & Try Again!!!") "`tail /var/log/ee/ee.log` & Try Again!!!")
# Update pagespeed config # Update pagespeed config
if self.app.pargs.pagespeed: if pargs.pagespeed:
operateOnPagespeed(self, data) operateOnPagespeed(self, data)
if stype == oldsitetype and cache == oldcachetype: if stype == oldsitetype and cache == oldcachetype:

14
ee/cli/plugins/site_functions.py

@ -28,6 +28,20 @@ class SiteError(Exception):
return repr(self.message) return repr(self.message)
def pre_run_checks(self):
# Check nginx configuration
Log.info(self, "Running pre-update checks, please wait ...")
try:
Log.debug(self, "checking NGINX configuration ...")
FNULL = open('/dev/null', 'w')
ret = subprocess.check_call(["nginx", "-t"], stdout=FNULL,
stderr=subprocess.STDOUT)
except CalledProcessError as e:
Log.debug(self, "{0}".format(str(e)))
raise SiteError("nginx configuration check failed.")
def check_domain_exists(self, domain): def check_domain_exists(self, domain):
if getSiteInfo(self, domain): if getSiteInfo(self, domain):
return True return True

Loading…
Cancel
Save