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