fix indentation and wp-cli path
This commit is contained in:
2
install
2
install
@@ -597,7 +597,7 @@ wo_update_latest()
|
||||
|
||||
|
||||
# Fix for 3.3.2 renamed nginx.conf
|
||||
nginx -V 2>&1 &>>/dev/null
|
||||
nginx -V &>>/dev/null 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
nginx -t 2>&1 | grep 'open() "/etc/nginx/nginx.conf" failed' &>>/dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
|
||||
@@ -54,9 +54,9 @@ def check_domain_exists(self, domain):
|
||||
|
||||
def setupdomain(self, data):
|
||||
|
||||
#for debug purpose
|
||||
# for key, value in data.items() :
|
||||
# print (key, value)
|
||||
# for debug purpose
|
||||
# for key, value in data.items() :
|
||||
# print (key, value)
|
||||
|
||||
wo_domain_name = data['site_name']
|
||||
wo_site_webroot = data['webroot'] if 'webroot' in data.keys() else ''
|
||||
@@ -100,7 +100,6 @@ def setupdomain(self, data):
|
||||
raise SiteError("created nginx configuration failed for site."
|
||||
" check with `nginx -t`")
|
||||
|
||||
|
||||
# create symbolic link for
|
||||
WOFileUtils.create_symlink(self, ['/etc/nginx/sites-available/{0}'
|
||||
.format(wo_domain_name),
|
||||
@@ -323,9 +322,9 @@ def setupwordpress(self, data):
|
||||
.format(wo_domain_name) if data['wpredis']
|
||||
else ''),
|
||||
log=False
|
||||
):
|
||||
):
|
||||
pass
|
||||
else :
|
||||
else:
|
||||
raise SiteError("generate wp-config failed for wp single site")
|
||||
except CommandExecutionError as e:
|
||||
raise SiteError("generate wp-config failed for wp single site")
|
||||
@@ -346,46 +345,45 @@ def setupwordpress(self, data):
|
||||
"\n\ndefine(\'WP_DEBUG\', false);"))
|
||||
try:
|
||||
if WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root"
|
||||
.format(WOVariables.wo_wpcli_path)
|
||||
+ " core config "
|
||||
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' "
|
||||
"--dbhost=\'{2}\' "
|
||||
.format(data['wo_db_name'], wo_wp_prefix,
|
||||
data['wo_db_host'])
|
||||
+ "--dbuser=\'{0}\' --dbpass=\'{1}\' "
|
||||
"--extra-php<<PHP \n {2} {3} {4} {redissalt}\nPHP\""
|
||||
.format(data['wo_db_user'],
|
||||
data['wo_db_pass'],
|
||||
"\ndefine(\'WP_ALLOW_MULTISITE\', "
|
||||
"true);",
|
||||
"\ndefine(\'WPMU_ACCEL_REDIRECT\',"
|
||||
" true);",
|
||||
"\n\ndefine(\'WP_DEBUG\', false);",
|
||||
redissalt="\n\ndefine( \'WP_CACHE_KEY_SALT\', \'{0}:\' );"
|
||||
.format(wo_domain_name) if data['wpredis']
|
||||
else ''),
|
||||
log=False
|
||||
):
|
||||
.format(WOVariables.wo_wpcli_path)
|
||||
+ " core config "
|
||||
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' "
|
||||
"--dbhost=\'{2}\' "
|
||||
.format(data['wo_db_name'], wo_wp_prefix,
|
||||
data['wo_db_host'])
|
||||
+ "--dbuser=\'{0}\' --dbpass=\'{1}\' "
|
||||
"--extra-php<<PHP \n {2} {3} {4} {redissalt}\nPHP\""
|
||||
.format(data['wo_db_user'],
|
||||
data['wo_db_pass'],
|
||||
"\ndefine(\'WP_ALLOW_MULTISITE\', "
|
||||
"true);",
|
||||
"\ndefine(\'WPMU_ACCEL_REDIRECT\',"
|
||||
" true);",
|
||||
"\n\ndefine(\'WP_DEBUG\', false);",
|
||||
redissalt="\n\ndefine( \'WP_CACHE_KEY_SALT\', \'{0}:\' );"
|
||||
.format(wo_domain_name) if data['wpredis']
|
||||
else ''),
|
||||
log=False
|
||||
):
|
||||
pass
|
||||
else:
|
||||
raise SiteError("generate wp-config failed for wp multi site")
|
||||
except CommandExecutionError as e:
|
||||
raise SiteError("generate wp-config failed for wp multi site")
|
||||
|
||||
#WOFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
|
||||
# WOFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
|
||||
# os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
|
||||
|
||||
try:
|
||||
import shutil
|
||||
|
||||
Log.debug(self, "Moving file from {0} to {1}".format(os.getcwd()+'/wp-config.php',os.path.abspath(os.path.join(os.getcwd(), os.pardir))))
|
||||
shutil.move(os.getcwd()+'/wp-config.php',os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
|
||||
Log.debug(self, "Moving file from {0} to {1}".format(os.getcwd()+'/wp-config.php', os.path.abspath(os.path.join(os.getcwd(), os.pardir))))
|
||||
shutil.move(os.getcwd()+'/wp-config.php', os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
|
||||
except Exception as e:
|
||||
Log.error(self, 'Unable to move file from {0} to {1}'
|
||||
.format(os.getcwd()+'/wp-config.php', os.path.abspath(os.path.join(os.getcwd(), os.pardir))),False)
|
||||
.format(os.getcwd()+'/wp-config.php', os.path.abspath(os.path.join(os.getcwd(), os.pardir))), False)
|
||||
raise SiteError("Unable to move wp-config.php")
|
||||
|
||||
|
||||
if not wo_wp_user:
|
||||
wo_wp_user = WOVariables.wo_user
|
||||
while not wo_wp_user:
|
||||
@@ -577,6 +575,7 @@ def uninstallwp_plugin(self, plugin_name, data):
|
||||
except CommandExecutionError as e:
|
||||
raise SiteError("plugin uninstall failed")
|
||||
|
||||
|
||||
def setupwp_plugin(self, plugin_name, plugin_option, plugin_data, data):
|
||||
wo_site_webroot = data['webroot']
|
||||
Log.info(self, "Setting plugin {0}, please wait..."
|
||||
@@ -634,7 +633,7 @@ def sitebackup(self, data):
|
||||
|
||||
configfiles = glob.glob(wo_site_webroot + '/*-config.php')
|
||||
if not configfiles:
|
||||
#search for wp-config.php inside htdocs/
|
||||
# search for wp-config.php inside htdocs/
|
||||
Log.debug(self, "Config files not found in {0}/ "
|
||||
.format(wo_site_webroot))
|
||||
if data['currsitetype'] in ['mysql']:
|
||||
@@ -681,21 +680,21 @@ def site_package_check(self, stype):
|
||||
Log.debug(self, "Setting apt_packages variable for Nginx")
|
||||
|
||||
# Check if server has nginx-custom package
|
||||
if not (WOAptGet.is_installed(self, 'nginx-custom') or WOAptGet.is_installed(self, 'nginx-mainline')):
|
||||
if not (WOAptGet.is_installed(self, 'nginx-custom') or WOAptGet.is_installed(self, 'nginx-mainline')):
|
||||
# check if Server has nginx-plus installed
|
||||
if WOAptGet.is_installed(self, 'nginx-plus'):
|
||||
# do something
|
||||
# do post nginx installation configuration
|
||||
Log.info(self, "NGINX PLUS Detected ...")
|
||||
apt = ["nginx-plus"] + WOVariables.wo_nginx
|
||||
#apt_packages = apt_packages + WOVariables.wo_nginx
|
||||
# apt_packages = apt_packages + WOVariables.wo_nginx
|
||||
stack.post_pref(apt, packages)
|
||||
elif WOAptGet.is_installed(self, 'nginx'):
|
||||
Log.info(self, "WordOps detected a previously installed Nginx package. "
|
||||
"It may or may not have required modules. "
|
||||
"\nIf you need help, please create an issue at https://github.com/WordOps/WordOps/issues/ \n")
|
||||
apt = ["nginx"] + WOVariables.wo_nginx
|
||||
#apt_packages = apt_packages + WOVariables.wo_nginx
|
||||
# apt_packages = apt_packages + WOVariables.wo_nginx
|
||||
stack.post_pref(apt, packages)
|
||||
else:
|
||||
apt_packages = apt_packages + WOVariables.wo_nginx
|
||||
@@ -709,13 +708,13 @@ def site_package_check(self, stype):
|
||||
'\t$request_filename;\n')
|
||||
|
||||
if self.app.pargs.php and self.app.pargs.php73:
|
||||
Log.error(self,"Error: two different PHP versions cannot be combined within the same WordOps site")
|
||||
Log.error(self, "Error: two different PHP versions cannot be combined within the same WordOps site")
|
||||
|
||||
if not self.app.pargs.php73 and stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
|
||||
Log.debug(self, "Setting apt_packages variable for PHP 7.2")
|
||||
apt_packages = apt_packages + WOVariables.wo_php + WOVariables.wo_php_extra
|
||||
|
||||
if self.app.pargs.php73 and stype in [ 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
|
||||
if self.app.pargs.php73 and stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
|
||||
if (WOVariables.wo_platform_codename == 'trusty' or WOVariables.wo_platform_codename == 'xenial' or WOVariables.wo_platform_codename == 'bionic'):
|
||||
Log.debug(self, "Setting apt_packages variable for PHP 7.3")
|
||||
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
@@ -741,7 +740,7 @@ def site_package_check(self, stype):
|
||||
"releases/download/v{0}/"
|
||||
"wp-cli-{0}.phar"
|
||||
.format(WOVariables.wo_wp_cli),
|
||||
"/usr/bin/wp", "WP-CLI"]]
|
||||
"/usr/local/bin/wp", "WP-CLI"]]
|
||||
if self.app.pargs.wpredis:
|
||||
Log.debug(self, "Setting apt_packages variable for redis")
|
||||
if not WOAptGet.is_installed(self, 'redis-server'):
|
||||
@@ -832,7 +831,7 @@ def site_package_check(self, stype):
|
||||
|
||||
if self.app.pargs.php73:
|
||||
if (WOVariables.wo_platform_codename == 'wheezy' or WOVariables.wo_platform_codename == 'precise'):
|
||||
Log.error(self,"PHP 7.3 is not supported in your Platform")
|
||||
Log.error(self, "PHP 7.3 is not supported in your Platform")
|
||||
|
||||
Log.debug(self, "Setting apt_packages variable for PHP 7.3")
|
||||
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
|
||||
@@ -319,7 +319,7 @@ class WOStackController(CementBaseController):
|
||||
# php7 conf
|
||||
if (WOVariables.wo_platform_codename == 'stretch' or WOVariables.wo_platform_codename == 'jessie' or WOVariables.wo_platform_codename == 'trusty' or WOVariables.wo_platform_codename == 'xenial' or WOVariables.wo_platform_codename == 'bionic') and (not
|
||||
os.path.isfile("/etc/nginx/common/php7.conf")):
|
||||
#data = dict()
|
||||
# data = dict()
|
||||
Log.debug(self, 'Writting the nginx configuration to '
|
||||
'file /etc/nginx/common/locations-php7.conf')
|
||||
wo_nginx = open('/etc/nginx/common/locations-php7.conf',
|
||||
@@ -877,7 +877,7 @@ class WOStackController(CementBaseController):
|
||||
|
||||
# PHP7.3 configuration for debian
|
||||
if (WOVariables.wo_platform_codename == 'jessie') and set(WOVariables.wo_php73).issubset(set(apt_packages)):
|
||||
# Create log directories
|
||||
# Create log directories
|
||||
if not os.path.exists('/var/log/php/7.3/'):
|
||||
Log.debug(self, 'Creating directory /var/log/php/7.3/')
|
||||
os.makedirs('/var/log/php/7.3/')
|
||||
@@ -1476,7 +1476,7 @@ class WOStackController(CementBaseController):
|
||||
"releases/download/v{0}/"
|
||||
"wp-cli-{0}.phar"
|
||||
"".format(WOVariables.wo_wp_cli),
|
||||
"/usr/bin/wp",
|
||||
"/usr/local/bin/wp",
|
||||
"WP-CLI"]]
|
||||
else:
|
||||
Log.debug(self, "WP-CLI is already installed")
|
||||
@@ -1686,8 +1686,8 @@ class WOStackController(CementBaseController):
|
||||
|
||||
if self.app.pargs.wpcli:
|
||||
Log.debug(self, "Removing package variable of WPCLI ")
|
||||
if os.path.isfile('/usr/bin/wp'):
|
||||
packages = packages + ['/usr/bin/wp']
|
||||
if os.path.isfile('/usr/local/bin/wp'):
|
||||
packages = packages + ['/usr/local/bin/wp']
|
||||
else:
|
||||
Log.warn(self, "WP-CLI is not installed with WordOps")
|
||||
if self.app.pargs.phpmyadmin:
|
||||
@@ -1824,8 +1824,8 @@ class WOStackController(CementBaseController):
|
||||
apt_packages = apt_packages + WOVariables.wo_hhvm
|
||||
|
||||
Log.debug(self, "Purge package variable WPCLI")
|
||||
if os.path.isfile('/usr/bin/wp'):
|
||||
packages = packages + ['/usr/bin/wp']
|
||||
if os.path.isfile('/usr/local/bin/wp'):
|
||||
packages = packages + ['/usr/local/bin/wp']
|
||||
else:
|
||||
Log.warn(self, "WP-CLI is not installed with WordOps")
|
||||
if self.app.pargs.phpmyadmin:
|
||||
|
||||
@@ -106,7 +106,7 @@ class WOStackUpgradeController(CementBaseController):
|
||||
self.app.pargs.mysql = True
|
||||
self.app.pargs.wpcli = True
|
||||
|
||||
if self.app.pargs.nginx :
|
||||
if self.app.pargs.nginx:
|
||||
if WOAptGet.is_installed(self, 'nginx-custom'):
|
||||
apt_packages = apt_packages + WOVariables.wo_nginx
|
||||
else:
|
||||
@@ -137,12 +137,12 @@ class WOStackUpgradeController(CementBaseController):
|
||||
Log.info(self, "Redis is not installed")
|
||||
|
||||
if self.app.pargs.wpcli:
|
||||
if os.path.isfile('/usr/bin/wp'):
|
||||
if os.path.isfile('/usr/local/bin/wp'):
|
||||
packages = packages + [["https://github.com/wp-cli/wp-cli/"
|
||||
"releases/download/v{0}/"
|
||||
"wp-cli-{0}.phar"
|
||||
"".format(WOVariables.wo_wp_cli),
|
||||
"/usr/bin/wp",
|
||||
"/usr/local/bin/wp",
|
||||
"WP-CLI"]]
|
||||
else:
|
||||
Log.info(self, "WPCLI is not installed with WordOps")
|
||||
@@ -178,7 +178,7 @@ class WOStackUpgradeController(CementBaseController):
|
||||
|
||||
if len(packages):
|
||||
if self.app.pargs.wpcli:
|
||||
WOFileUtils.remove(self,['/usr/local/bin/wp'])
|
||||
WOFileUtils.remove(self, ['/usr/local/bin/wp'])
|
||||
|
||||
Log.debug(self, "Downloading following: {0}".format(packages))
|
||||
WODownload.download(self, packages)
|
||||
|
||||
Reference in New Issue
Block a user