Browse Source

minor fix

bugfixes
harshadyeola 10 years ago
parent
commit
1a1e95d888
  1. 93
      ee/cli/plugins/site_functions.py

93
ee/cli/plugins/site_functions.py

@ -6,6 +6,7 @@ import getpass
from ee.core.fileutils import EEFileUtils from ee.core.fileutils import EEFileUtils
from ee.core.mysql import EEMysql from ee.core.mysql import EEMysql
from ee.core.shellexec import EEShellExec from ee.core.shellexec import EEShellExec
from ee.core.variables import EEVariables
def setup_domain(self, data): def setup_domain(self, data):
@ -64,8 +65,10 @@ def setup_database(self, data):
prompt_dbuser = self.app.config.get('mysql', 'db-user') prompt_dbuser = self.app.config.get('mysql', 'db-user')
ee_mysql_host = self.app.config.get('mysql', 'grant-host') ee_mysql_host = self.app.config.get('mysql', 'grant-host')
ee_db_name = '' ee_db_name = ''
ee_db_username = ''
ee_db_password = ''
if prompt_dbname == 'True': if prompt_dbname == 'True' or prompt_dbname == 'true':
try: try:
ee_db_name = input('Enter the MySQL database name [{0}]:' ee_db_name = input('Enter the MySQL database name [{0}]:'
.format(ee_replace_dot)) .format(ee_replace_dot))
@ -76,7 +79,7 @@ def setup_database(self, data):
if not ee_db_name: if not ee_db_name:
ee_db_name = ee_replace_dot ee_db_name = ee_replace_dot
if prompt_dbuser: if prompt_dbuser == 'True' or prompt_dbuser == 'true':
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))
@ -98,17 +101,19 @@ def setup_database(self, data):
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
EEMysql.execute(self, "create database \'{0}\'" EEMysql.execute(self, "create database {0}"
.format(ee_db_name)) .format(ee_db_name))
print("create user {0}@{1} identified by '{2}'"
.format(ee_db_username, ee_mysql_host, ee_db_password))
# Create MySQL User # Create MySQL User
EEMysql.execute(self, EEMysql.execute(self,
"create user \'{0}\'@\'{1}\' identified by \'{2}\'" "create user {0}@{1} identified by '{2}'"
.format(ee_db_username, ee_mysql_host, ee_db_password)) .format(ee_db_username, ee_mysql_host, ee_db_password))
# Grant permission # Grant permission
EEMysql.execute(self, EEMysql.execute(self,
"grant all privileges on \'{0}\'.* to \'{1}\'@\'{2}\'" "grant all privileges on {0}.* to {1}@{2}"
.format(ee_db_name, ee_db_username, ee_db_password)) .format(ee_db_name, ee_db_username, ee_db_password))
data['ee_db_name'] = ee_db_name data['ee_db_name'] = ee_db_name
data['ee_db_user'] = ee_db_username data['ee_db_user'] = ee_db_username
@ -126,59 +131,55 @@ def setup_wordpress(self, data):
# Random characters # Random characters
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)))
ee_wp_prefix = ''
ee_wp_user = ''
ee_wp_pass = ''
print("Downloading Wordpress, please wait...") print("Downloading Wordpress, please wait...")
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")
setup_database(self, data) data = setup_database(self, data)
if prompt_wpprefix == 'True': if prompt_wpprefix == 'True' or prompt_wpprefix == 'true':
try:
ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: '
.format(ee_replace_dot)) .format(ee_replace_dot))
while re.match('^[A-Za-z0-9_]*$', ee_wp_prefix): while re.match('^[A-Za-z0-9_]*$', ee_wp_prefix):
print("Warning: table prefix can only contain numbers, letters," print("Warning: table prefix can only contain numbers, "
"and underscores") "letters, and underscores")
ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ') ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: '
)
except EOFError as e:
print("{0} {1}".format(e.errorno, e.strerror))
sys.exit(1)
if not ee_wp_prefix: if not ee_wp_prefix:
ee_wp_prefix = 'wp_' ee_wp_prefix = 'wp_'
# Modify wp-config.php & move outside the webroot # Modify wp-config.php & move outside the webroot
'''EEFileUtils.copyfile(self,
'{0}/htdocs/wp-config-sample.php'
.format(ee_site_webroot),
'{0}/wp-config.php'.format(ee_site_webroot))
EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot),
'database_name_here', '')
EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot),
'database_name_here', '')
EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot),
'username_here', '')
EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot),
'password_here', '')
EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot),
'localhost', '')
EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot),
'wp_', '')'''
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
if not data['multisite']: if not data['multisite']:
EEShellExec.cmd_exec(self, "wp --allow-root core config" print("Generating wp-config")
"--dbname={0} --dbprefix={1} --dbuser={2}"
.format(ee_db_name, ee_wp_prefix, ee_db_user) EEShellExec.cmd_exec(self, "wp --allow-root core config "
+ "--dbpass={0}".format(ee_db_password)) + "--dbname={0} --dbprefix={1} --dbuser={2} "
.format(data['ee_db_name'], ee_wp_prefix,
data['ee_db_user'])
+ "--dbpass={0}".format(data['ee_db_pass']))
else: else:
EEShellExec.cmd_exec(self, "wp --allow-root core config" EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core config "
"--dbname={0} --dbprefix={1}" + "--dbname={0} --dbprefix={1} "
.format(ee_db_name, ee_wp_prefix) .format(data['ee_db_name'], ee_wp_prefix)
+ "--dbuser={0} --dbpass={1} --extra-php<<PHP" + "--dbuser={0} --dbpass={1} --extra-php<<PHP"
+ "define('WP_ALLOW_MULTISITE', true);" + "\n define('WP_ALLOW_MULTISITE', true);"
+ "define('WPMU_ACCEL_REDIRECT', true);" + "\n define('WPMU_ACCEL_REDIRECT', true);"
+ "PHP" + "\n PHP"
.format(ee_db_user, ee_db_password)) .format(data['ee_db_user'], data['ee_db_pass']))
EEFileUtils.mvfile('./wp-config.php', '../') EEFileUtils.mvfile(self, './wp-config.php', '../')
# TODO code for salts here
if not ee_wp_user: if not ee_wp_user:
ee_wp_user = EEVariables.ee_user ee_wp_user = EEVariables.ee_user
while not ee_wp_user: while not ee_wp_user:
@ -214,7 +215,7 @@ def setup_wordpress(self, data):
if not data['wpsubdir'] else '')) if not data['wpsubdir'] else ''))
print("Updating WordPress permalink, please wait...") print("Updating WordPress permalink, please wait...")
EEShellExec.cmd_exec("wp rewrite structure --allow-root" EEShellExec.cmd_exec(self, "wp --allow-root rewrite structure "
"/%year%/%monthnum%/%day%/%postname%/") "/%year%/%monthnum%/%day%/%postname%/")
"""Install nginx-helper plugin """ """Install nginx-helper plugin """
@ -229,18 +230,20 @@ def setup_wordpress(self, data):
install_wp_plugin(self, 'w3-total-cache', data) install_wp_plugin(self, 'w3-total-cache', data)
def setup_wordpress_network(self, ee_www_domain, ee_site_webroot, def setup_wordpress_network(self, data):
subdomain=False): ee_site_webroot = data['webroot']
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 multisite-convert' EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert'
'--title={0}') '--title=')
def install_wp_plugin(self, plugin_name, data): def install_wp_plugin(self, plugin_name, data):
ee_site_webroot = ee_site_webroot = data['webroot'] ee_site_webroot = data['webroot']
print("Installing plugin {0}".format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
EEShellExec.cmd_exec(self, "wp plugin --allow-root install {0}" EEShellExec.cmd_exec(self, "wp plugin --allow-root install {0}"
.format(plugin_name)) .format(plugin_name))
EEShellExec.cmd_exec(self, "wp plugin --allow-root activate {0} {na}" EEShellExec.cmd_exec(self, "wp plugin --allow-root activate {0} {na}"
.format(na='--network' if data['multisite'] else '')) .format(plugin_name,
na='--network' if data['multisite'] else ''))

Loading…
Cancel
Save