Browse Source

Now support for WPCLI custom location

release/v3.3.0
gau1991 10 years ago
parent
commit
f4bf4a25bd
  1. 57
      ee/cli/plugins/site_functions.py
  2. 2
      ee/cli/plugins/stack.py
  3. 7
      ee/core/variables.py

57
ee/cli/plugins/site_functions.py

@ -281,7 +281,8 @@ def setupwordpress(self, data):
Log.debug(self, "Setting up wp-config file") Log.debug(self, "Setting up wp-config file")
if not data['multisite']: if not data['multisite']:
Log.debug(self, "Generating wp-config for WordPress Single site") Log.debug(self, "Generating wp-config for WordPress Single site")
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root " Log.debug(self, "bash -c \"php {0} --allow-root "
.format(EEVariables.ee_wpcli_path)
+ "core config " + "core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' " + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
"--dbhost=\'{3}\' " "--dbhost=\'{3}\' "
@ -292,7 +293,8 @@ def setupwordpress(self, data):
.format(data['ee_db_pass'], .format(data['ee_db_pass'],
"\n\ndefine(\'WP_DEBUG\', false);")) "\n\ndefine(\'WP_DEBUG\', false);"))
try: try:
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root" EEShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root"
.format(EEVariables.ee_wpcli_path)
+ " core config " + " core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' " + "--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbuser=\'{2}\' --dbhost=\'{3}\' " "--dbuser=\'{2}\' --dbhost=\'{3}\' "
@ -309,7 +311,8 @@ def setupwordpress(self, data):
raise SiteError("generate wp-config failed for wp single site") raise SiteError("generate wp-config failed for wp single site")
else: else:
Log.debug(self, "Generating wp-config for WordPress multisite") Log.debug(self, "Generating wp-config for WordPress multisite")
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root " Log.debug(self, "bash -c \"php {0} --allow-root "
.format(EEVariables.ee_wpcli_path)
+ "core config " + "core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' " + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
.format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host']) .format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host'])
@ -322,7 +325,8 @@ def setupwordpress(self, data):
" true);", " true);",
"\n\ndefine(\'WP_DEBUG\', false);")) "\n\ndefine(\'WP_DEBUG\', false);"))
try: try:
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root" EEShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root"
.format(EEVariables.ee_wpcli_path)
+ " core config " + " core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' " + "--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbhost=\'{2}\' " "--dbhost=\'{2}\' "
@ -382,14 +386,16 @@ def setupwordpress(self, data):
if not data['multisite']: if not data['multisite']:
Log.debug(self, "Creating tables for WordPress Single site") Log.debug(self, "Creating tables for WordPress Single site")
Log.debug(self, "php /usr/bin/wp --allow-root core install " Log.debug(self, "php {0} --allow-root core install "
"--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' " .format(EEVariables.ee_wpcli_path)
+ "--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user) .format(data['www_domain'], ee_wp_user)
+ "--admin_password= --admin_email=\'{1}\'" + "--admin_password= --admin_email=\'{1}\'"
.format(ee_wp_pass, ee_wp_email)) .format(ee_wp_pass, ee_wp_email))
try: try:
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core " EEShellExec.cmd_exec(self, "php {0} --allow-root core "
"install --url=\'{0}\' --title=\'{0}\' " .format(EEVariables.ee_wpcli_path)
+ "install --url=\'{0}\' --title=\'{0}\' "
"--admin_name=\'{1}\' " "--admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user) .format(data['www_domain'], ee_wp_user)
+ "--admin_password=\'{0}\' " + "--admin_password=\'{0}\' "
@ -400,8 +406,9 @@ def setupwordpress(self, data):
raise SiteError("setup wordpress tables failed for single site") raise SiteError("setup wordpress tables failed for single site")
else: else:
Log.debug(self, "Creating tables for WordPress multisite") Log.debug(self, "Creating tables for WordPress multisite")
Log.debug(self, "php /usr/bin/wp --allow-root " Log.debug(self, "php {0} --allow-root "
"core multisite-install " .format(EEVariables.ee_wpcli_path)
+ "core multisite-install "
"--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' " "--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user) .format(data['www_domain'], ee_wp_user)
+ "--admin_password= --admin_email=\'{1}\' " + "--admin_password= --admin_email=\'{1}\' "
@ -410,8 +417,9 @@ def setupwordpress(self, data):
subdomains='--subdomains' subdomains='--subdomains'
if not data['wpsubdir'] else '')) if not data['wpsubdir'] else ''))
try: try:
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root " EEShellExec.cmd_exec(self, "php {0} --allow-root "
"core multisite-install " .format(EEVariables.ee_wpcli_path)
+ "core multisite-install "
"--url=\'{0}\' --title=\'{0}\' " "--url=\'{0}\' --title=\'{0}\' "
"--admin_name=\'{1}\' " "--admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user) .format(data['www_domain'], ee_wp_user)
@ -427,8 +435,9 @@ def setupwordpress(self, data):
Log.debug(self, "Updating WordPress permalink") Log.debug(self, "Updating WordPress permalink")
try: try:
EEShellExec.cmd_exec(self, " php /usr/bin/wp --allow-root " EEShellExec.cmd_exec(self, " php {0} --allow-root "
"rewrite structure " .format(EEVariables.ee_wpcli_path)
+ "rewrite structure "
"/%year%/%monthnum%/%day%/%postname%/") "/%year%/%monthnum%/%day%/%postname%/")
except CommandExecutionError as e: except CommandExecutionError as e:
raise SiteError("Update wordpress permalinks failed") raise SiteError("Update wordpress permalinks failed")
@ -476,15 +485,17 @@ def installwp_plugin(self, plugin_name, data):
.format(plugin_name)) .format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
try: try:
EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin " EEShellExec.cmd_exec(self, "php {0} plugin "
"--allow-root install " .format(EEVariables.ee_wpcli_path)
+ "--allow-root install "
"{0}".format(plugin_name)) "{0}".format(plugin_name))
except CommandExecutionError as e: except CommandExecutionError as e:
raise SiteError("plugin installation failed") raise SiteError("plugin installation failed")
try: try:
EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin " EEShellExec.cmd_exec(self, "php {0} plugin "
"--allow-root activate " .format(EEVariables.ee_wpcli_path)
+ "--allow-root activate "
"{0} {na}" "{0} {na}"
.format(plugin_name, .format(plugin_name,
na='--network' if data['multisite'] na='--network' if data['multisite']
@ -502,12 +513,14 @@ def uninstallwp_plugin(self, plugin_name, data):
Log.info(self, "Uninstalling plugin {0}, please wait..." Log.info(self, "Uninstalling plugin {0}, please wait..."
.format(plugin_name)) .format(plugin_name))
try: try:
EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin " EEShellExec.cmd_exec(self, "php {0} plugin "
"--allow-root deactivate " .format(EEVariables.ee_wpcli_path)
+ "--allow-root deactivate "
"{0}".format(plugin_name)) "{0}".format(plugin_name))
EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin " EEShellExec.cmd_exec(self, "php {0} plugin "
"--allow-root uninstall " .format(EEVariables.ee_wpcli_path)
+ "--allow-root uninstall "
"{0}".format(plugin_name)) "{0}".format(plugin_name))
except CommandExecutionError as e: except CommandExecutionError as e:
raise SiteError("plugin uninstall failed") raise SiteError("plugin uninstall failed")

2
ee/cli/plugins/stack.py

@ -557,7 +557,7 @@ class EEStackController(CementBaseController):
"a") as redis_file: "a") as redis_file:
redis_file.write("upstream redis {\n" redis_file.write("upstream redis {\n"
" server 127.0.0.1:6379;\n" " server 127.0.0.1:6379;\n"
" keepalive 10;\n}") " keepalive 10;\n}\n")
if set(EEVariables.ee_php).issubset(set(apt_packages)): if set(EEVariables.ee_php).issubset(set(apt_packages)):
# Create log directories # Create log directories

7
ee/core/variables.py

@ -15,11 +15,16 @@ class EEVariables():
ee_version = "3.2.2" ee_version = "3.2.2"
# EasyEngine packages versions # EasyEngine packages versions
ee_wp_cli = "0.19.1" ee_wp_cli = "0.19.2s"
ee_adminer = "4.2.1" ee_adminer = "4.2.1"
ee_roundcube = "1.1.1" ee_roundcube = "1.1.1"
ee_vimbadmin = "3.0.11" ee_vimbadmin = "3.0.11"
# Get WPCLI path
ee_wpcli_path = os.popen('which wp | tr "\n" " "').read()
if ee_wpcli_path == '':
ee_wpcli_path = '/usr/bin/wp '
# Current date and time of System # Current date and time of System
ee_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S') ee_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S')

Loading…
Cancel
Save