Browse Source

access db info from ee db instead of config files

bugfixes
harshadyeola 10 years ago
parent
commit
39110fb5f4
  1. 45
      ee/cli/plugins/site.py
  2. 14
      ee/cli/plugins/site_functions.py

45
ee/cli/plugins/site.py

@ -326,7 +326,7 @@ class EESiteCreateController(CementBaseController):
if not ee_domain.strip():
Log.error("Invalid domain name, "
"Provide valid domain name")
ee_site_webroot = EEVariables.ee_webroot + ee_domain
if check_domain_exists(self, ee_domain):
@ -756,7 +756,10 @@ class EESiteUpdateController(CementBaseController):
.format(ee_domain))
ee_auth = site_package_check(self, stype)
data['ee_db_name'] = check_site.db_name
data['ee_db_user'] = check_site.db_user
data['ee_db_pass'] = check_site.db_password
data['ee_db_host'] = check_site.db_host
try:
sitebackup(self, data)
except Exception as e:
@ -809,25 +812,25 @@ class EESiteUpdateController(CementBaseController):
Log.error(self, "Update site failed. Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!")
if oldsitetype == 'mysql':
config_file = (ee_site_webroot + '/backup/{0}/ee-config.php'
.format(EEVariables.ee_date))
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())
data['ee_db_host'] = (EEFileUtils.grep(self, config_file,
'DB_HOST')
.split(',')[1]
.split(')')[0].strip())
# if oldsitetype == 'mysql':
# # config_file = (ee_site_webroot + '/backup/{0}/ee-config.php'
# # .format(EEVariables.ee_date))
# # 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())
# # data['ee_db_host'] = (EEFileUtils.grep(self, config_file,
# # 'DB_HOST')
# # .split(',')[1]
# # .split(')')[0].strip())
# Setup WordPress if old sites are html/php/mysql sites
if data['wp'] and oldsitetype in ['html', 'php', 'mysql']:

14
ee/cli/plugins/site_functions.py

@ -486,6 +486,7 @@ def setwebrootpermissions(self, webroot):
def sitebackup(self, data):
print(data['ee_db_name'])
ee_site_webroot = data['webroot']
backup_path = ee_site_webroot + '/backup/{0}'.format(EEVariables.ee_date)
if not EEFileUtils.isexist(self, backup_path):
@ -500,15 +501,16 @@ def sitebackup(self, data):
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
configfiles = glob.glob(ee_site_webroot + '/*-config.php')
if configfiles and EEFileUtils.isexist(self, configfiles[0]):
ee_db_name = (EEFileUtils.grep(self, configfiles[0],
'DB_NAME').split(',')[1]
.split(')')[0].strip().replace('\'', ''))
# if configfiles and EEFileUtils.isexist(self, configfiles[0]):
# ee_db_name = (EEFileUtils.grep(self, configfiles[0],
# 'DB_NAME').split(',')[1]
# .split(')')[0].strip().replace('\'', ''))
if data['ee_db_name']:
Log.info(self, 'Backing up database \t\t', end='')
try:
if not EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql"
.format(ee_db_name, backup_path)):
.format(data['ee_db_name'],
backup_path)):
Log.info(self,
"[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
raise SiteError("mysqldump failed to backup database")

Loading…
Cancel
Save