Refactor acme.sh and WOVariables

This commit is contained in:
VirtuBox
2019-10-02 13:13:32 +02:00
parent d9980998fa
commit c731d806d6
22 changed files with 371 additions and 374 deletions

View File

@@ -15,6 +15,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [STACK] Nginx ultimate bad bots blocker with `wo stack install --ngxblocker`
- [STACK] Added support for custom Nginx compiled from source
#### Changed
- [CORE] Query acme.sh database directly to check if a certificate exist
#### Fixed
- [SITE] Issues with root_domain variable with `wo site update`
### v3.9.9.1 - 2019-09-26
#### Added

View File

@@ -1,21 +0,0 @@
# The following are only required in development, not production
nose
coverage
sphinx
pep8
autopep8
mock
pyinotify
# Required for optional extensions (only the ones supported on py3)
argcomplete
pystache
pyYaml
colorlog
configobj
tabulate
pylibmc
redis
jinja2
watchdog
pybars3

View File

@@ -2,9 +2,9 @@
from cement.core.controller import CementBaseController, expose
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
VERSION = WOVariables.wo_version
VERSION = WOVar.wo_version
BANNER = """
WordOps v%s

View File

@@ -16,7 +16,7 @@ from wo.core.logging import Log
from wo.core.mysql import WOMysql
from wo.core.services import WOService
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
def wo_debug_hook(app):
@@ -146,7 +146,7 @@ class WODebugController(CementBaseController):
Log.info(self, "Nginx debug for site already enabled")
self.msg = self.msg + ['{0}{1}/logs/error.log'
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
else:
@@ -446,14 +446,14 @@ class WODebugController(CementBaseController):
"""Start/Stop WordPress debug"""
if (self.app.pargs.wp == 'on' and self.app.pargs.site_name):
wp_config = ("{0}/{1}/wp-config.php"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name))
webroot = "{0}{1}".format(WOVariables.wo_webroot,
webroot = "{0}{1}".format(WOVar.wo_webroot,
self.app.pargs.site_name)
# Check wp-config.php file into htdocs folder
if not os.path.isfile(wp_config):
wp_config = ("{0}/{1}/htdocs/wp-config.php"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name))
if os.path.isfile(wp_config):
if not WOShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} |"
@@ -464,7 +464,7 @@ class WODebugController(CementBaseController):
WOShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-"
"content/debug.log"
"".format(webroot,
WOVariables.wo_php_user))
WOVar.wo_php_user))
WOShellExec.cmd_exec(self, "sed -i \"s/define(\'WP_DEBUG\'"
".*/define(\'WP_DEBUG\', true);\\n"
"define(\'WP_DEBUG_DISPLAY\', false);"
@@ -478,11 +478,11 @@ class WODebugController(CementBaseController):
WOShellExec.cmd_exec(self, "chown -R {1}: {0}/htdocs/"
"wp-content/plugins"
.format(webroot,
WOVariables.wo_php_user))
WOVar.wo_php_user))
self.msg = self.msg + ['{0}{1}/htdocs/wp-content'
'/debug.log'
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
else:
@@ -491,14 +491,14 @@ class WODebugController(CementBaseController):
elif (self.app.pargs.wp == 'off' and self.app.pargs.site_name):
wp_config = ("{0}{1}/wp-config.php"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name))
webroot = "{0}{1}".format(WOVariables.wo_webroot,
webroot = "{0}{1}".format(WOVar.wo_webroot,
self.app.pargs.site_name)
# Check wp-config.php file into htdocs folder
if not os.path.isfile(wp_config):
wp_config = ("{0}/{1}/htdocs/wp-config.php"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name))
if os.path.isfile(wp_config):
if WOShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} | "
@@ -565,11 +565,11 @@ class WODebugController(CementBaseController):
Log.info(self, "Nginx rewrite logs for {0} already setup"
.format(self.app.pargs.site_name))
if ('{0}{1}/logs/error.log'.format(WOVariables.wo_webroot,
if ('{0}{1}/logs/error.log'.format(WOVar.wo_webroot,
self.app.pargs.site_name)
not in self.msg):
self.msg = self.msg + ['{0}{1}/logs/error.log'
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
# Stop Nginx rewrite for site
@@ -608,7 +608,7 @@ class WODebugController(CementBaseController):
self.debug_fpm73()
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if WOVariables.wo_mysql_host is "localhost":
if WOVar.wo_mysql_host is "localhost":
self.app.pargs.mysql = 'off'
self.debug_mysql()
else:
@@ -756,7 +756,7 @@ class WODebugController(CementBaseController):
self.debug_fpm73()
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if WOVariables.wo_mysql_host == "localhost":
if WOVar.wo_mysql_host == "localhost":
self.debug_mysql()
else:
Log.warn(self, "Remote MySQL found, WordOps does not support "
@@ -796,22 +796,22 @@ class WODebugController(CementBaseController):
def import_slow_log(self):
"""Default function for import slow log"""
if os.path.isdir("{0}22222/htdocs/db/anemometer"
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
if os.path.isfile("/var/log/mysql/mysql-slow.log"):
# Get Anemometer user name and password
Log.info(self, "Importing MySQL slow log to Anemometer")
host = os.popen("grep -e \"\'host\'\" {0}22222/htdocs/"
.format(WOVariables.wo_webroot) +
.format(WOVar.wo_webroot) +
"db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
user = os.popen("grep -e \"\'user\'\" {0}22222/htdocs/"
.format(WOVariables.wo_webroot) +
.format(WOVar.wo_webroot) +
"db/anemometer/conf/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "
"tr -d '\n'").read()
password = os.popen("grep -e \"\'password\'\" {0}22222/"
.format(WOVariables.wo_webroot) +
.format(WOVar.wo_webroot) +
"htdocs/db/anemometer/conf"
"/config.inc.php "
"| head -1 | cut -d\\\' -f4 | "

View File

@@ -13,7 +13,7 @@ from wo.core.logging import Log
from wo.core.mysql import WOMysql
from wo.core.sendmail import WOSendMail
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
def wo_log_hook(app):
@@ -99,7 +99,7 @@ class WOLogShowController(CementBaseController):
'/var/log/php5/fpm.log']
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if WOVariables.wo_mysql_host == "localhost":
if WOVar.wo_mysql_host == "localhost":
if os.path.isfile('/var/log/mysql/mysql-slow.log'):
self.msg = self.msg + ['/var/log/mysql/mysql-slow.log']
else:
@@ -109,18 +109,18 @@ class WOLogShowController(CementBaseController):
"remote MySQL servers or log files")
if self.app.pargs.site_name:
webroot = "{0}{1}".format(WOVariables.wo_webroot,
webroot = "{0}{1}".format(WOVar.wo_webroot,
self.app.pargs.site_name)
if not os.path.isdir(webroot):
Log.error(self, "Site not present, quitting")
if self.app.pargs.access:
self.msg = self.msg + ["{0}/{1}/logs/access.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
if self.app.pargs.nginx:
self.msg = self.msg + ["{0}/{1}/logs/error.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
if self.app.pargs.wp:
if os.path.isdir('{0}/htdocs/wp-content'.format(webroot)):
@@ -134,7 +134,7 @@ class WOLogShowController(CementBaseController):
WOShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/"
"wp-content/debug.log"
"".format(webroot,
WOVariables
WOVar
.wo_php_user)
)
# create symbolic link for debug log
@@ -145,7 +145,7 @@ class WOLogShowController(CementBaseController):
.format(webroot)])
self.msg = self.msg + ["{0}/{1}/logs/debug.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
else:
Log.info(self, "Site is not WordPress site, skipping "
@@ -238,7 +238,7 @@ class WOLogResetController(CementBaseController):
'/var/log/php5/fpm.log']
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if WOVariables.wo_mysql_host == "localhost":
if WOVar.wo_mysql_host == "localhost":
if os.path.isfile('/var/log/mysql/mysql-slow.log'):
self.msg = self.msg + ['/var/log/mysql/mysql-slow.log']
else:
@@ -248,18 +248,18 @@ class WOLogResetController(CementBaseController):
"remote MySQL servers or log files")
if self.app.pargs.site_name:
webroot = "{0}{1}".format(WOVariables.wo_webroot,
webroot = "{0}{1}".format(WOVar.wo_webroot,
self.app.pargs.site_name)
if not os.path.isdir(webroot):
Log.error(self, "Site not present, quitting")
if self.app.pargs.access:
self.msg = self.msg + ["{0}/{1}/logs/access.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
if self.app.pargs.nginx:
self.msg = self.msg + ["{0}/{1}/logs/error.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
if self.app.pargs.wp:
if os.path.isdir('{0}/htdocs/wp-content'.format(webroot)):
@@ -273,7 +273,7 @@ class WOLogResetController(CementBaseController):
WOShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/"
"wp-content/debug.log"
"".format(webroot,
WOVariables
WOVar
.wo_php_user)
)
# create symbolic link for debug log
@@ -284,7 +284,7 @@ class WOLogResetController(CementBaseController):
.format(webroot)])
self.msg = self.msg + ["{0}/{1}/logs/debug.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
else:
Log.info(self, "Site is not WordPress site, skipping "
@@ -366,7 +366,7 @@ class WOLogGzipController(CementBaseController):
'/var/log/php5/fpm.log']
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if WOVariables.wo_mysql_host == "localhost":
if WOVar.wo_mysql_host == "localhost":
if os.path.isfile('/var/log/mysql/mysql-slow.log'):
self.msg = self.msg + ['/var/log/mysql/mysql-slow.log']
else:
@@ -377,18 +377,18 @@ class WOLogGzipController(CementBaseController):
"remote MySQL servers or log files")
if self.app.pargs.site_name:
webroot = "{0}{1}".format(WOVariables.wo_webroot,
webroot = "{0}{1}".format(WOVar.wo_webroot,
self.app.pargs.site_name)
if not os.path.isdir(webroot):
Log.error(self, "Site not present, quitting")
if self.app.pargs.access:
self.msg = self.msg + ["{0}/{1}/logs/access.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
if self.app.pargs.nginx:
self.msg = self.msg + ["{0}/{1}/logs/error.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
if self.app.pargs.wp:
if os.path.isdir('{0}/htdocs/wp-content'.format(webroot)):
@@ -402,7 +402,7 @@ class WOLogGzipController(CementBaseController):
WOShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/"
"wp-content/debug.log"
"".format(webroot,
WOVariables
WOVar
.wo_php_user)
)
# create symbolic link for debug log
@@ -413,7 +413,7 @@ class WOLogGzipController(CementBaseController):
.format(webroot)])
self.msg = self.msg + ["{0}/{1}/logs/debug.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
else:
Log.info(self, "Site is not WordPress site, skipping "
@@ -504,7 +504,7 @@ class WOLogMailController(CementBaseController):
'/var/log/php5/fpm.log']
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if WOVariables.wo_mysql_host == "localhost":
if WOVar.wo_mysql_host == "localhost":
if os.path.isfile('/var/log/mysql/mysql-slow.log'):
self.msg = self.msg + ['/var/log/mysql/mysql-slow.log']
else:
@@ -514,18 +514,18 @@ class WOLogMailController(CementBaseController):
"remote MySQL servers or log files")
if self.app.pargs.site_name:
webroot = "{0}{1}".format(WOVariables.wo_webroot,
webroot = "{0}{1}".format(WOVar.wo_webroot,
self.app.pargs.site_name)
if not os.path.isdir(webroot):
Log.error(self, "Site not present, quitting")
if self.app.pargs.access:
self.msg = self.msg + ["{0}/{1}/logs/access.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
if self.app.pargs.nginx:
self.msg = self.msg + ["{0}/{1}/logs/error.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
if self.app.pargs.wp:
if os.path.isdir('{0}/htdocs/wp-content'.format(webroot)):
@@ -539,7 +539,7 @@ class WOLogMailController(CementBaseController):
WOShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/"
"wp-content/debug.log"
"".format(webroot,
WOVariables
WOVar
.wo_php_user)
)
# create symbolic link for debug log
@@ -550,7 +550,7 @@ class WOLogMailController(CementBaseController):
.format(webroot)])
self.msg = self.msg + ["{0}/{1}/logs/debug.log"
.format(WOVariables.wo_webroot,
.format(WOVar.wo_webroot,
self.app.pargs.site_name)]
else:
Log.info(self, "Site is not WordPress site, skipping "
@@ -563,7 +563,7 @@ class WOLogMailController(CementBaseController):
for tomail in self.app.pargs.to:
Log.info(self, "Sending mail to {0}".format(tomail[0]))
WOSendMail("wordops", tomail[0], "{0} Log Files"
.format(WOVariables.wo_fqdn),
.format(WOVar.wo_fqdn),
"Hi,\n The requested logfiles are attached."
"\n\nBest regards,\nYour WordOps worker",
files=mail_list, port=25, isTls=False)

View File

@@ -11,7 +11,7 @@ from wo.core.random import RANDOM
from wo.core.services import WOService
from wo.core.shellexec import WOShellExec
from wo.core.template import WOTemplate
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
def wo_secure_hook(app):
@@ -73,10 +73,10 @@ class WOSecureController(CementBaseController):
passwd = RANDOM.gen(self, length='24')
if not pargs.user_input:
username = input("Provide HTTP authentication user "
"name [{0}] :".format(WOVariables.wo_user))
"name [{0}] :".format(WOVar.wo_user))
pargs.user_input = username
if username == "":
pargs.user_input = WOVariables.wo_user
pargs.user_input = WOVar.wo_user
if not pargs.user_pass:
password = getpass.getpass("Provide HTTP authentication "
"password [{0}] :".format(passwd))

View File

@@ -17,7 +17,7 @@ from wo.core.nginxhashbucket import hashbucket
from wo.core.services import WOService
from wo.core.shellexec import WOShellExec
from wo.core.sslutils import SSL
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
def wo_site_hook(app):
@@ -56,8 +56,7 @@ class WOSiteController(CementBaseController):
pargs.site_name = pargs.site_name.strip()
# validate domain name
(wo_domain,
wo_www_domain) = WODomain.validate(self, pargs.site_name)
wo_domain = WODomain.validate(self, pargs.site_name)
# check if site exists
if not check_domain_exists(self, wo_domain):
@@ -94,8 +93,7 @@ class WOSiteController(CementBaseController):
Log.debug(self, str(e))
Log.error(self, 'could not input site name')
pargs.site_name = pargs.site_name.strip()
(wo_domain, wo_www_domain) = WODomain.validate(self,
pargs.site_name)
wo_domain = WODomain.validate(self, pargs.site_name)
# check if site exists
if not check_domain_exists(self, wo_domain):
Log.error(self, "site {0} does not exist".format(wo_domain))
@@ -135,8 +133,7 @@ class WOSiteController(CementBaseController):
Log.debug(self, str(e))
Log.error(self, 'could not input site name')
pargs.site_name = pargs.site_name.strip()
(wo_domain,
wo_www_domain) = WODomain.validate(self, pargs.site_name)
wo_domain = WODomain.validate(self, pargs.site_name)
(wo_domain_type, wo_root_domain) = WODomain.getlevel(
self, wo_domain)
wo_db_name = ''
@@ -189,8 +186,7 @@ class WOSiteController(CementBaseController):
def log(self):
pargs = self.app.pargs
pargs.site_name = pargs.site_name.strip()
(wo_domain,
wo_www_domain) = WODomain.validate(self, pargs.site_name)
wo_domain = WODomain.validate(self, pargs.site_name)
wo_site_webroot = getSiteInfo(self, wo_domain).site_path
if not check_domain_exists(self, wo_domain):
@@ -212,8 +208,7 @@ class WOSiteController(CementBaseController):
Log.error(self, 'could not input site name')
# TODO Write code for wo site edit command here
pargs.site_name = pargs.site_name.strip()
(wo_domain,
wo_www_domain) = WODomain.validate(self, pargs.site_name)
wo_domain = WODomain.validate(self, pargs.site_name)
if not check_domain_exists(self, wo_domain):
Log.error(self, "site {0} does not exist".format(wo_domain))
@@ -244,8 +239,7 @@ class WOSiteController(CementBaseController):
Log.error(self, 'Unable to read input, please try again')
pargs.site_name = pargs.site_name.strip()
(wo_domain,
wo_www_domain) = WODomain.validate(self, pargs.site_name)
wo_domain = WODomain.validate(self, pargs.site_name)
if not check_domain_exists(self, wo_domain):
Log.error(self, "site {0} does not exist".format(wo_domain))
@@ -285,13 +279,12 @@ class WOSiteEditController(CementBaseController):
Log.error(self, 'Unable to read input, Please try again')
pargs.site_name = pargs.site_name.strip()
(wo_domain,
wo_www_domain) = WODomain.validate(self, pargs.site_name)
wo_domain = WODomain.validate(self, pargs.site_name)
if not check_domain_exists(self, wo_domain):
Log.error(self, "site {0} does not exist".format(wo_domain))
wo_site_webroot = WOVariables.wo_webroot + wo_domain
wo_site_webroot = WOVar.wo_webroot + wo_domain
if os.path.isfile('/etc/nginx/sites-available/{0}'
.format(wo_domain)):
@@ -436,13 +429,12 @@ class WOSiteCreateController(CementBaseController):
Log.error(self, "Unable to input site name, Please try again!")
pargs.site_name = pargs.site_name.strip()
(wo_domain,
wo_www_domain) = WODomain.validate(self, pargs.site_name)
wo_domain = WODomain.validate(self, pargs.site_name)
if not wo_domain.strip():
Log.error(self, "Invalid domain name, "
"Provide valid domain name")
wo_site_webroot = WOVariables.wo_webroot + wo_domain
wo_site_webroot = WOVar.wo_webroot + wo_domain
if check_domain_exists(self, wo_domain):
Log.error(self, "site {0} already exists".format(wo_domain))
@@ -991,9 +983,8 @@ class WOSiteUpdateController(CementBaseController):
Log.error(self, 'Unable to input site name, Please try again!')
pargs.site_name = pargs.site_name.strip()
(wo_domain,
wo_www_domain) = WODomain.validate(self, pargs.site_name)
wo_site_webroot = WOVariables.wo_webroot + wo_domain
wo_domain = WODomain.validate(self, pargs.site_name)
wo_site_webroot = WOVar.wo_webroot + wo_domain
check_site = getSiteInfo(self, wo_domain)
if check_site is None:
@@ -1958,7 +1949,7 @@ class WOSiteDeleteController(CementBaseController):
Log.error(self, 'could not input site name')
pargs.site_name = pargs.site_name.strip()
(wo_domain, wo_www_domain) = WODomain.validate(self, pargs.site_name)
wo_domain = WODomain.validate(self, pargs.site_name)
wo_db_name = ''
wo_prompt = ''
wo_nginx_prompt = ''

View File

@@ -22,7 +22,7 @@ from wo.core.mysql import (MySQLConnectionError, StatementExcecutionError,
from wo.core.services import WOService
from wo.core.shellexec import CommandExecutionError, WOShellExec
from wo.core.sslutils import SSL
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
class SiteError(Exception):
@@ -229,7 +229,7 @@ def setupdatabase(self, data):
data['wo_db_name'] = wo_db_name
data['wo_db_user'] = wo_db_username
data['wo_db_pass'] = wo_db_password
data['wo_db_host'] = WOVariables.wo_mysql_host
data['wo_db_host'] = WOVar.wo_mysql_host
data['wo_mysql_grant_host'] = wo_mysql_grant_host
return(data)
@@ -295,7 +295,7 @@ def setupwordpress(self, data, vhostonly=False):
if not data['multisite']:
Log.debug(self, "Generating wp-config for WordPress Single site")
Log.debug(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"config create " +
"--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
"--dbhost=\'{3}\' "
@@ -307,7 +307,7 @@ def setupwordpress(self, data, vhostonly=False):
"\n\ndefine(\'WP_DEBUG\', false);"))
try:
if WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root"
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
" config create " +
"--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbuser=\'{2}\' --dbhost=\'{3}\' "
@@ -330,7 +330,7 @@ def setupwordpress(self, data, vhostonly=False):
else:
Log.debug(self, "Generating wp-config for WordPress multisite")
Log.debug(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"config create " +
"--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
.format(data['wo_db_name'],
@@ -345,7 +345,7 @@ def setupwordpress(self, data, vhostonly=False):
"\n\ndefine(\'WP_DEBUG\', false);"))
try:
if WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root"
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
" config create " +
"--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbhost=\'{2}\' "
@@ -370,36 +370,36 @@ def setupwordpress(self, data, vhostonly=False):
try:
WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"config set WP_CACHE_KEY_SALT "
"\'{0}:\'\"".format(wo_domain_name))
WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"config set WP_MEMORY_LIMIT "
"\'128M\'\"")
WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"config set WP_MAX_MEMORY_LIMIT "
"\'256M\'\"")
WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"config set CONCATENATE_SCRIPTS "
"false --raw\"")
WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"config set WP_POST_REVISIONS "
"\'10\'\"")
WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"config set MEDIA_TRASH "
"true --raw\"")
WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"config set EMPTY_TRASH_DAYS "
"\'15\'\"")
WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"config set WP_AUTO_UPDATE_CORE "
"minor\"")
@@ -426,7 +426,7 @@ def setupwordpress(self, data, vhostonly=False):
raise SiteError("Unable to move wp-config.php")
if not wo_wp_user:
wo_wp_user = WOVariables.wo_user
wo_wp_user = WOVar.wo_user
while not wo_wp_user:
Log.warn(self, "Username can have only alphanumeric"
"characters, spaces, underscores, hyphens,"
@@ -439,7 +439,7 @@ def setupwordpress(self, data, vhostonly=False):
wo_wp_pass = wo_random_pass
if not wo_wp_email:
wo_wp_email = WOVariables.wo_email
wo_wp_email = WOVar.wo_email
while not wo_wp_email:
try:
wo_wp_email = input('Enter WordPress email: ')
@@ -460,14 +460,14 @@ def setupwordpress(self, data, vhostonly=False):
if not data['multisite']:
Log.debug(self, "Creating tables for WordPress Single site")
Log.debug(self, "{0} --allow-root core install "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
.format(data['www_domain'], wo_wp_user) +
"--admin_password= --admin_email=\'{1}\'"
.format(wo_wp_pass, wo_wp_email))
try:
if WOShellExec.cmd_exec(self, "{0} --allow-root core "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"install --url=\'{0}\' --title=\'{0}\' "
"--admin_name=\'{1}\' "
.format(data['www_domain'], wo_wp_user) +
@@ -484,7 +484,7 @@ def setupwordpress(self, data, vhostonly=False):
else:
Log.debug(self, "Creating tables for WordPress multisite")
Log.debug(self, "{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"core multisite-install "
"--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
.format(data['www_domain'], wo_wp_user) +
@@ -495,7 +495,7 @@ def setupwordpress(self, data, vhostonly=False):
if not data['wpsubdir'] else ''))
try:
if WOShellExec.cmd_exec(self, "{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"core multisite-install "
"--url=\'{0}\' --title=\'{0}\' "
"--admin_name=\'{1}\' "
@@ -517,7 +517,7 @@ def setupwordpress(self, data, vhostonly=False):
Log.debug(self, "Updating WordPress permalink")
try:
WOShellExec.cmd_exec(self, " {0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"rewrite structure "
"/%postname%/")
except CommandExecutionError as e:
@@ -608,7 +608,7 @@ def setupwordpress(self, data, vhostonly=False):
if vhostonly:
try:
WOShellExec.cmd_exec(self, "/bin/bash -c \"{0} --allow-root "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"db clean --yes\"")
WOFileUtils.rm(self, "{0}/htdocs".format(wo_site_webroot))
WOFileUtils.mkdir(self, "{0}/htdocs".format(wo_site_webroot))
@@ -653,7 +653,7 @@ def installwp_plugin(self, plugin_name, data):
WOFileUtils.chdir(self, '{0}/htdocs/'.format(wo_site_webroot))
try:
WOShellExec.cmd_exec(self, "{0} plugin "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"--allow-root install "
"{0}".format(plugin_name))
except CommandExecutionError as e:
@@ -662,7 +662,7 @@ def installwp_plugin(self, plugin_name, data):
try:
WOShellExec.cmd_exec(self, "{0} plugin "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"--allow-root activate "
"{0} {na}"
.format(plugin_name,
@@ -689,12 +689,12 @@ def uninstallwp_plugin(self, plugin_name, data):
.format(plugin_name))
try:
WOShellExec.cmd_exec(self, "{0} plugin "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"--allow-root deactivate "
"{0}".format(plugin_name))
WOShellExec.cmd_exec(self, "{0} plugin "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"--allow-root uninstall "
"{0}".format(plugin_name))
except CommandExecutionError as e:
@@ -716,7 +716,7 @@ def setupwp_plugin(self, plugin_name, plugin_option, plugin_data, data):
if not data['multisite']:
try:
WOShellExec.cmd_exec(self, "{0} "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"--allow-root option update "
"{0} \'{1}\' --format=json"
.format(plugin_option, plugin_data))
@@ -731,7 +731,7 @@ def setupwp_plugin(self, plugin_name, plugin_option, plugin_data, data):
else:
try:
WOShellExec.cmd_exec(self, "{0} "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"--allow-root network meta update 1 "
"{0} \'{1}\' --format=json"
.format(plugin_option, plugin_data
@@ -750,8 +750,8 @@ def setwebrootpermissions(self, webroot):
Log.debug(self, "Setting up permissions")
try:
WOFileUtils.findBrokenSymlink(self, '/var/www/')
WOFileUtils.chown(self, webroot, WOVariables.wo_php_user,
WOVariables.wo_php_user, recursive=True)
WOFileUtils.chown(self, webroot, WOVar.wo_php_user,
WOVar.wo_php_user, recursive=True)
except Exception as e:
Log.debug(self, str(e))
raise SiteError("problem occured while setting up webroot permissions")
@@ -759,7 +759,7 @@ def setwebrootpermissions(self, webroot):
def sitebackup(self, data):
wo_site_webroot = data['webroot']
backup_path = wo_site_webroot + '/backup/{0}'.format(WOVariables.wo_date)
backup_path = wo_site_webroot + '/backup/{0}'.format(WOVar.wo_date)
if not WOFileUtils.isexist(self, backup_path):
WOFileUtils.mkdir(self, backup_path)
Log.info(self, "Backup location : {0}".format(backup_path))
@@ -836,8 +836,8 @@ def site_package_check(self, stype):
# 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 = ["nginx-plus"] + WOVar.wo_nginx
# apt_packages = apt_packages + WOVar.wo_nginx
stack.post_pref(self, apt, packages)
elif WOAptGet.is_installed(self, 'nginx'):
Log.info(self, "WordOps detected a previously"
@@ -845,13 +845,13 @@ def site_package_check(self, stype):
"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 = ["nginx"] + WOVar.wo_nginx
# apt_packages = apt_packages + WOVar.wo_nginx
post_pref(self, apt, packages)
elif os.path.isfile('/usr/sbin/nginx'):
post_pref(self, WOVariables.wo_nginx, [])
post_pref(self, WOVar.wo_nginx, [])
else:
apt_packages = apt_packages + WOVariables.wo_nginx
apt_packages = apt_packages + WOVar.wo_nginx
else:
# Fix for Nginx white screen death
if not WOFileUtils.grep(self, '/etc/nginx/fastcgi_params',
@@ -871,26 +871,26 @@ def site_package_check(self, stype):
Log.debug(self, "Setting apt_packages variable for PHP 7.2")
if not WOAptGet.is_installed(self, 'php7.2-fpm'):
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
apt_packages = apt_packages + WOVariables.wo_php + \
WOVariables.wo_php_extra
apt_packages = apt_packages + WOVar.wo_php + \
WOVar.wo_php_extra
else:
apt_packages = apt_packages + WOVariables.wo_php
apt_packages = apt_packages + WOVar.wo_php
if self.app.pargs.php73 and stype in ['mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
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.2-fpm'):
apt_packages = apt_packages + WOVariables.wo_php + \
WOVariables.wo_php73 + WOVariables.wo_php_extra
apt_packages = apt_packages + WOVar.wo_php + \
WOVar.wo_php73 + WOVar.wo_php_extra
else:
apt_packages = apt_packages + WOVariables.wo_php73
apt_packages = apt_packages + WOVar.wo_php73
if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for MySQL")
if not WOShellExec.cmd_exec(self, "/usr/bin/mysqladmin ping"):
if not WOVariables.wo_distro == 'raspbian':
if (not WOVariables.wo_platform_codename == 'jessie'):
if not WOVar.wo_distro == 'raspbian':
if (not WOVar.wo_platform_codename == 'jessie'):
wo_mysql = ["mariadb-server", "percona-toolkit",
"python3-mysqldb", "mariadb-backup"]
else:
@@ -907,7 +907,7 @@ def site_package_check(self, stype):
packages = packages + [["https://github.com/wp-cli/wp-cli/"
"releases/download/v{0}/"
"wp-cli-{0}.phar"
.format(WOVariables.wo_wp_cli),
.format(WOVar.wo_wp_cli),
"/usr/local/bin/wp", "WP-CLI"]]
if self.app.pargs.wpredis:
Log.debug(self, "Setting apt_packages variable for redis")
@@ -918,10 +918,10 @@ def site_package_check(self, stype):
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.2-fpm'):
apt_packages = apt_packages + WOVariables.wo_php + \
WOVariables.wo_php73 + WOVariables.wo_php_extra
apt_packages = apt_packages + WOVar.wo_php + \
WOVar.wo_php73 + WOVar.wo_php_extra
else:
apt_packages = apt_packages + WOVariables.wo_php73
apt_packages = apt_packages + WOVar.wo_php73
if self.app.pargs.ngxblocker:
if not os.path.isdir('/etc/nginx/bots.d'):
@@ -1293,9 +1293,9 @@ def removeAcmeConf(self, domain):
Log.error(self, "Cert removal failed")
WOFileUtils.rm(self, '{0}/{1}_ecc'
.format(WOVariables.wo_ssl_archive, domain))
.format(WOVar.wo_ssl_archive, domain))
WOFileUtils.rm(self, '{0}/{1}'
.format(WOVariables.wo_ssl_live, domain))
.format(WOVar.wo_ssl_live, domain))
WOFileUtils.rm(self, '{0}'.format(sslconf))
WOFileUtils.rm(self, '{0}.disabled'.format(sslconf))
WOFileUtils.rm(self, '{0}'.format(sslforce))
@@ -1502,7 +1502,7 @@ def archivedCertificateHandle(self, domain):
self, "You already have an existing certificate "
"for the domain requested.\n"
"(ref: {0}/"
"{1}_ecc/{1}.conf)".format(WOVariables.wo_ssl_archive, domain) +
"{1}_ecc/{1}.conf)".format(WOVar.wo_ssl_archive, domain) +
"\nPlease select an option from below?"
"\n\t1: Reinstall existing certificate"
"\n\t2: Issue a new certificate to replace "
@@ -1511,10 +1511,10 @@ def archivedCertificateHandle(self, domain):
check_prompt = input(
"\nType the appropriate number [1-2] or any other key to cancel: ")
if not os.path.isfile("{0}/{1}/fullchain.pem"
.format(WOVariables.wo_ssl_live, domain)):
.format(WOVar.wo_ssl_live, domain)):
Log.error(
self, "{0}/{1}/fullchain.pem file is missing."
.format(WOVariables.wo_ssl_live, domain))
.format(WOVar.wo_ssl_live, domain))
if check_prompt == "1":
Log.info(self, "Reinstalling SSL cert with acme.sh")
@@ -1539,7 +1539,7 @@ def archivedCertificateHandle(self, domain):
"ssl_certificate_key {0}/{1}/key.pem;\n"
"ssl_trusted_certificate {0}/{1}/ca.pem;\n"
"ssl_stapling_verify on;\n"
.format(WOVariables.wo_ssl_live, domain))
.format(WOVar.wo_ssl_live, domain))
sslconf.close()
except IOError as e:
@@ -1573,7 +1573,7 @@ def archivedCertificateHandle(self, domain):
"{0}/{1}/ca.pem;\n"
"--reloadcmd "
"\"nginx -t && service nginx restart\" "
.format(WOVariables.wo_ssl_live, domain))
.format(WOVar.wo_ssl_live, domain))
except IOError as e:
Log.debug(self, str(e))
@@ -1595,8 +1595,8 @@ def archivedCertificateHandle(self, domain):
def setuprocketchat(self):
if ((not WOVariables.wo_platform_codename == 'bionic') and
(not WOVariables.wo_platform_codename == 'xenial')):
if ((not WOVar.wo_platform_codename == 'bionic') and
(not WOVar.wo_platform_codename == 'xenial')):
Log.info(self, "Rocket.chat is only available on Ubuntu 16.04 "
"& 18.04 LTS")
return False

View File

@@ -18,7 +18,7 @@ from wo.core.logging import Log
from wo.core.mysql import WOMysql
from wo.core.services import WOService
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
def wo_stack_hook(app):
@@ -163,18 +163,18 @@ class WOStackController(CementBaseController):
if not (WOAptGet.is_installed(self, 'nginx-plus') or
WOAptGet.is_installed(self, 'nginx')):
if not os.path.isfile('/usr/sbin/nginx'):
apt_packages = apt_packages + WOVariables.wo_nginx
apt_packages = apt_packages + WOVar.wo_nginx
else:
if WOAptGet.is_installed(self, 'nginx-plus'):
Log.info(self, "NGINX PLUS Detected ...")
apt = ["nginx-plus"] + WOVariables.wo_nginx
apt = ["nginx-plus"] + WOVar.wo_nginx
self.post_pref(apt, empty_packages)
elif WOAptGet.is_installed(self, 'nginx'):
Log.info(self, "WordOps detected an already "
"installed nginx package."
"It may or may not have "
"required modules.\n")
apt = ["nginx"] + WOVariables.wo_nginx
apt = ["nginx"] + WOVar.wo_nginx
self.post_pref(apt, empty_packages)
else:
Log.debug(self, "Nginx already installed")
@@ -182,7 +182,7 @@ class WOStackController(CementBaseController):
# Redis
if pargs.redis:
if not WOAptGet.is_installed(self, 'redis-server'):
apt_packages = apt_packages + WOVariables.wo_redis
apt_packages = apt_packages + WOVar.wo_redis
else:
Log.info(self, "Redis already installed")
@@ -191,8 +191,8 @@ class WOStackController(CementBaseController):
if pargs.php:
Log.debug(self, "Setting apt_packages variable for PHP 7.2")
if not (WOAptGet.is_installed(self, 'php7.2-fpm')):
apt_packages = (apt_packages + WOVariables.wo_php +
WOVariables.wo_php_extra)
apt_packages = (apt_packages + WOVar.wo_php +
WOVar.wo_php_extra)
else:
Log.debug(self, "PHP 7.2 already installed")
Log.info(self, "PHP 7.2 already installed")
@@ -201,9 +201,9 @@ class WOStackController(CementBaseController):
if pargs.php73:
Log.debug(self, "Setting apt_packages variable for PHP 7.3")
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
apt_packages = (apt_packages + WOVariables.wo_php +
WOVariables.wo_php73 +
WOVariables.wo_php_extra)
apt_packages = (apt_packages + WOVar.wo_php +
WOVar.wo_php73 +
WOVar.wo_php_extra)
else:
Log.debug(self, "PHP 7.3 already installed")
Log.info(self, "PHP 7.3 already installed")
@@ -213,7 +213,7 @@ class WOStackController(CementBaseController):
pargs.mysqltuner = True
Log.debug(self, "Setting apt_packages variable for MySQL")
if not WOShellExec.cmd_exec(self, "mysqladmin ping"):
apt_packages = apt_packages + WOVariables.wo_mysql
apt_packages = apt_packages + WOVar.wo_mysql
else:
Log.debug(self, "MySQL already installed and alive")
Log.info(self, "MySQL already installed and alive")
@@ -223,7 +223,7 @@ class WOStackController(CementBaseController):
Log.debug(self, "Setting apt_packages variable "
"for MySQL Client")
if not WOShellExec.cmd_exec(self, "mysqladmin ping"):
apt_packages = apt_packages + WOVariables.wo_mysql_client
apt_packages = apt_packages + WOVar.wo_mysql_client
else:
Log.debug(self, "MySQL already installed and alive")
Log.info(self, "MySQL already installed and alive")
@@ -236,7 +236,7 @@ class WOStackController(CementBaseController):
packages = packages + [["https://github.com/wp-cli/wp-cli/"
"releases/download/v{0}/"
"wp-cli-{0}.phar"
"".format(WOVariables.wo_wp_cli),
"".format(WOVar.wo_wp_cli),
"/usr/local/bin/wp",
"WP-CLI"]]
else:
@@ -247,7 +247,7 @@ class WOStackController(CementBaseController):
if pargs.fail2ban:
Log.debug(self, "Setting apt_packages variable for Fail2ban")
if not WOAptGet.is_installed(self, 'fail2ban'):
apt_packages = apt_packages + WOVariables.wo_fail2ban
apt_packages = apt_packages + WOVar.wo_fail2ban
else:
Log.debug(self, "Fail2ban already installed")
Log.info(self, "Fail2ban already installed")
@@ -256,7 +256,7 @@ class WOStackController(CementBaseController):
if pargs.clamav:
Log.debug(self, "Setting apt_packages variable for ClamAV")
if not WOAptGet.is_installed(self, 'clamav'):
apt_packages = apt_packages + WOVariables.wo_clamav
apt_packages = apt_packages + WOVar.wo_clamav
else:
Log.debug(self, "ClamAV already installed")
Log.info(self, "ClamAV already installed")
@@ -346,17 +346,17 @@ class WOStackController(CementBaseController):
packages = packages + [["https://github.com/vrana/adminer/"
"releases/download/v{0}"
"/adminer-{0}.php"
.format(WOVariables.wo_adminer),
.format(WOVar.wo_adminer),
"{0}22222/"
"htdocs/db/adminer/index.php"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"Adminer"],
["https://raw.githubusercontent.com"
"/vrana/adminer/master/designs/"
"pepa-linha/adminer.css",
"{0}22222/"
"htdocs/db/adminer/adminer.css"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"Adminer theme"]]
else:
Log.debug(self, "Adminer already installed")
@@ -383,7 +383,7 @@ class WOStackController(CementBaseController):
os.path.isdir("/etc/netdata")):
Log.debug(
self, "Setting packages variable for Netdata")
if WOVariables.wo_distro == 'raspbian':
if WOVar.wo_distro == 'raspbian':
packages = packages + [['https://my-netdata.io/'
'kickstart.sh',
'/var/lib/wo/tmp/kickstart.sh',
@@ -407,7 +407,7 @@ class WOStackController(CementBaseController):
"/wordops-dashboard/"
"releases/download/v{0}/"
"wordops-dashboard.tar.gz"
.format(WOVariables.wo_dashboard),
.format(WOVar.wo_dashboard),
"/var/lib/wo/tmp/wo-dashboard.tar.gz",
"WordOps Dashboard"]]
else:
@@ -421,7 +421,7 @@ class WOStackController(CementBaseController):
packages = packages + \
[["https://github.com/soerennb/"
"extplorer/archive/v{0}.tar.gz"
.format(WOVariables.wo_extplorer),
.format(WOVar.wo_extplorer),
"/var/lib/wo/tmp/extplorer.tar.gz",
"eXtplorer"]]
else:
@@ -449,25 +449,25 @@ class WOStackController(CementBaseController):
"clean.php",
"{0}22222/htdocs/cache/"
"nginx/clean.php"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"clean.php"],
["https://raw.github.com/rlerdorf/"
"opcache-status/master/opcache.php",
"{0}22222/htdocs/cache/"
"opcache/opcache.php"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"opcache.php"],
["https://raw.github.com/amnuts/"
"opcache-gui/master/index.php",
"{0}22222/htdocs/"
"cache/opcache/opgui.php"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"Opgui"],
["https://raw.githubusercontent.com/"
"mlazarov/ocp/master/ocp.php",
"{0}22222/htdocs/cache/"
"opcache/ocp.php"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"OCP.php"],
["https://github.com/jokkedk/webgrind/"
"archive/master.tar.gz",
@@ -575,27 +575,27 @@ class WOStackController(CementBaseController):
if pargs.nginx:
if WOAptGet.is_installed(self, 'nginx-custom'):
Log.debug(self, "Removing apt_packages variable of Nginx")
apt_packages = apt_packages + WOVariables.wo_nginx
apt_packages = apt_packages + WOVar.wo_nginx
# PHP 7.2
if pargs.php:
Log.debug(self, "Removing apt_packages variable of PHP")
if WOAptGet.is_installed(self, 'php7.2-fpm'):
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
apt_packages = apt_packages + WOVariables.wo_php + \
WOVariables.wo_php_extra
apt_packages = apt_packages + WOVar.wo_php + \
WOVar.wo_php_extra
else:
apt_packages = apt_packages + WOVariables.wo_php
apt_packages = apt_packages + WOVar.wo_php
# PHP7.3
if pargs.php73:
Log.debug(self, "Removing apt_packages variable of PHP 7.3")
if WOAptGet.is_installed(self, 'php7.3-fpm'):
if not (WOAptGet.is_installed(self, 'php7.2-fpm')):
apt_packages = apt_packages + WOVariables.wo_php73 + \
WOVariables.wo_php_extra
apt_packages = apt_packages + WOVar.wo_php73 + \
WOVar.wo_php_extra
else:
apt_packages = apt_packages + WOVariables.wo_php73
apt_packages = apt_packages + WOVar.wo_php73
# REDIS
if pargs.redis:
@@ -616,19 +616,19 @@ class WOStackController(CementBaseController):
Log.debug(self, "Removing apt_packages variable "
"for MySQL Client")
if WOShellExec.cmd_exec(self, "mysqladmin ping"):
apt_packages = apt_packages + WOVariables.wo_mysql_client
apt_packages = apt_packages + WOVar.wo_mysql_client
# fail2ban
if pargs.fail2ban:
if WOAptGet.is_installed(self, 'fail2ban'):
Log.debug(self, "Remove apt_packages variable of Fail2ban")
apt_packages = apt_packages + WOVariables.wo_fail2ban
apt_packages = apt_packages + WOVar.wo_fail2ban
# ClamAV
if pargs.clamav:
Log.debug(self, "Setting apt_packages variable for ClamAV")
if WOAptGet.is_installed(self, 'clamav'):
apt_packages = apt_packages + WOVariables.wo_clamav
apt_packages = apt_packages + WOVar.wo_clamav
# sendmail
if pargs.sendmail:
@@ -657,10 +657,10 @@ class WOStackController(CementBaseController):
# PHPMYADMIN
if pargs.phpmyadmin:
if os.path.isdir('{0}22222/htdocs/db/pma'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
Log.debug(self, "Removing package of phpMyAdmin ")
packages = packages + ['{0}22222/htdocs/db/pma'
.format(WOVariables.wo_webroot)]
.format(WOVar.wo_webroot)]
# Composer
if pargs.composer:
Log.debug(self, "Removing package of Composer ")
@@ -677,28 +677,28 @@ class WOStackController(CementBaseController):
if pargs.phpredisadmin:
Log.debug(self, "Removing package variable of phpRedisAdmin ")
if os.path.isdir('{0}22222/htdocs/cache/redis'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
packages = packages + ['{0}22222/htdocs/'
'cache/redis'
.format(WOVariables.wo_webroot)]
.format(WOVar.wo_webroot)]
# ADMINER
if pargs.adminer:
if os.path.isdir('{0}22222/htdocs/db/adminer'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
Log.debug(self, "Removing package variable of Adminer ")
packages = packages + ['{0}22222/htdocs/db/adminer'
.format(WOVariables.wo_webroot)]
.format(WOVar.wo_webroot)]
if pargs.utils:
Log.debug(self, "Removing package variable of utils ")
packages = packages + ['{0}22222/htdocs/php/webgrind/'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'{0}22222/htdocs/cache/opcache'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'{0}22222/htdocs/cache/nginx/'
'clean.php'.format(WOVariables.wo_webroot),
'clean.php'.format(WOVar.wo_webroot),
'/usr/bin/pt-query-advisor',
'{0}22222/htdocs/db/anemometer'
.format(WOVariables.wo_webroot)]
.format(WOVar.wo_webroot)]
if pargs.netdata:
Log.debug(self, "Removing Netdata")
@@ -708,16 +708,16 @@ class WOStackController(CementBaseController):
if pargs.dashboard:
if (os.path.isfile('{0}22222/htdocs/index.php'
.format(WOVariables.wo_webroot)) or
.format(WOVar.wo_webroot)) or
os.path.isfile('{0}22222/htdocs/index.html'
.format(WOVariables.wo_webroot))):
.format(WOVar.wo_webroot))):
Log.debug(self, "Removing Wo-Dashboard")
packages = packages + ['{0}22222/htdocs/assets'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'{0}22222/htdocs/index.php'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'{0}22222/htdocs/index.html'
.format(WOVariables.wo_webroot)]
.format(WOVar.wo_webroot)]
if (packages) or (apt_packages):
if (not pargs.force):
@@ -739,7 +739,7 @@ class WOStackController(CementBaseController):
# Netdata uninstaller
if (set(['/var/lib/wo/tmp/'
'kickstart.sh']).issubset(set(packages))):
if WOVariables.wo_distro == 'Raspbian':
if WOVar.wo_distro == 'Raspbian':
WOShellExec.cmd_exec(self, "bash /usr/"
"libexec/netdata/"
"netdata-uninstaller.sh -y -f")
@@ -818,7 +818,7 @@ class WOStackController(CementBaseController):
if pargs.nginx:
if WOAptGet.is_installed(self, 'nginx-custom'):
Log.debug(self, "Add Nginx to apt_packages list")
apt_packages = apt_packages + WOVariables.wo_nginx
apt_packages = apt_packages + WOVar.wo_nginx
else:
Log.info(self, "Nginx is not installed")
@@ -827,20 +827,20 @@ class WOStackController(CementBaseController):
Log.debug(self, "Add PHP to apt_packages list")
if WOAptGet.is_installed(self, 'php7.2-fpm'):
if not (WOAptGet.is_installed(self, 'php7.3-fpm')):
apt_packages = apt_packages + WOVariables.wo_php + \
WOVariables.wo_php_extra
apt_packages = apt_packages + WOVar.wo_php + \
WOVar.wo_php_extra
else:
apt_packages = apt_packages + WOVariables.wo_php
apt_packages = apt_packages + WOVar.wo_php
# PHP 7.3
if pargs.php73:
Log.debug(self, "Removing apt_packages variable of PHP 7.3")
if WOAptGet.is_installed(self, 'php7.3-fpm'):
if not (WOAptGet.is_installed(self, 'php7.2-fpm')):
apt_packages = apt_packages + WOVariables.wo_php73 + \
WOVariables.wo_php_extra
apt_packages = apt_packages + WOVar.wo_php73 + \
WOVar.wo_php_extra
else:
apt_packages = apt_packages + WOVariables.wo_php73
apt_packages = apt_packages + WOVar.wo_php73
# REDIS
if pargs.redis:
@@ -865,19 +865,19 @@ class WOStackController(CementBaseController):
if pargs.mysqlclient:
if WOShellExec.cmd_exec(self, "mysqladmin ping"):
Log.debug(self, "Add MySQL client to apt_packages list")
apt_packages = apt_packages + WOVariables.wo_mysql_client
apt_packages = apt_packages + WOVar.wo_mysql_client
# fail2ban
if pargs.fail2ban:
if WOAptGet.is_installed(self, 'fail2ban'):
Log.debug(self, "Add Fail2ban to apt_packages list")
apt_packages = apt_packages + WOVariables.wo_fail2ban
apt_packages = apt_packages + WOVar.wo_fail2ban
# ClamAV
if pargs.clamav:
if WOAptGet.is_installed(self, 'clamav'):
Log.debug(self, "Add ClamAV to apt_packages list")
apt_packages = apt_packages + WOVariables.wo_clamav
apt_packages = apt_packages + WOVar.wo_clamav
# UFW
if pargs.ufw:
@@ -906,10 +906,10 @@ class WOStackController(CementBaseController):
# PHPMYADMIN
if pargs.phpmyadmin:
if os.path.isdir('{0}22222/htdocs/db/pma'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
Log.debug(self, "Removing package of phpMyAdmin ")
packages = packages + ['{0}22222/htdocs/db/pma'
.format(WOVariables.wo_webroot)]
.format(WOVar.wo_webroot)]
# Composer
if pargs.composer:
@@ -927,29 +927,29 @@ class WOStackController(CementBaseController):
if pargs.phpredisadmin:
Log.debug(self, "Removing package variable of phpRedisAdmin ")
if os.path.isdir('{0}22222/htdocs/cache/redis'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
packages = packages + ['{0}22222/htdocs/'
'cache/redis'
.format(WOVariables.wo_webroot)]
.format(WOVar.wo_webroot)]
# ADMINER
if pargs.adminer:
if os.path.isdir('{0}22222/htdocs/db/adminer'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
Log.debug(self, "Removing package variable of Adminer ")
packages = packages + ['{0}22222/htdocs/db/adminer'
.format(WOVariables.wo_webroot)]
.format(WOVar.wo_webroot)]
# utils
if pargs.utils:
Log.debug(self, "Purge package variable utils")
packages = packages + ['{0}22222/htdocs/php/webgrind/'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'{0}22222/htdocs/cache/opcache'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'{0}22222/htdocs/cache/nginx/'
'clean.php'.format(WOVariables.wo_webroot),
'clean.php'.format(WOVar.wo_webroot),
'/usr/bin/pt-query-advisor',
'{0}22222/htdocs/db/anemometer'
.format(WOVariables.wo_webroot)
.format(WOVar.wo_webroot)
]
if pargs.netdata:
@@ -961,9 +961,9 @@ class WOStackController(CementBaseController):
if pargs.dashboard:
Log.debug(self, "Removing Wo-Dashboard")
packages = packages + ['{0}22222/htdocs/assets/'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'{0}22222/htdocs/index.php'
.format(WOVariables.wo_webroot)]
.format(WOVar.wo_webroot)]
if (packages) or (apt_packages):
if (not pargs.force):
@@ -991,7 +991,7 @@ class WOStackController(CementBaseController):
# Netdata uninstaller
if (set(['/var/lib/wo/tmp/'
'kickstart.sh']).issubset(set(packages))):
if WOVariables.wo_distro == 'Raspbian':
if WOVar.wo_distro == 'Raspbian':
WOShellExec.cmd_exec(self, "bash /usr/"
"libexec/netdata/netdata-"
"uninstaller.sh -y -f",

View File

@@ -9,7 +9,7 @@ from wo.core.aptget import WOAptGet
from wo.core.logging import Log
from wo.core.mysql import WOMysql
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
class WOStackMigrateController(CementBaseController):
@@ -29,8 +29,8 @@ class WOStackMigrateController(CementBaseController):
# Backup all database
WOMysql.backupAll(self)
if not WOVariables.wo_distro == 'raspbian':
if (not WOVariables.wo_platform_codename == 'jessie'):
if not WOVar.wo_distro == 'raspbian':
if (not WOVar.wo_platform_codename == 'jessie'):
wo_mysql = ["mariadb-server", "percona-toolkit",
"python3-mysqldb", "mariadb-backup"]
else:
@@ -49,9 +49,9 @@ class WOStackMigrateController(CementBaseController):
'MariaDB.pref', 'w') as mysql_pref_file:
mysql_pref_file.write(mysql_pref)
WORepo.add(self, repo_url=WOVariables.wo_mysql_repo)
WORepo.add(self, repo_url=WOVar.wo_mysql_repo)
Log.debug(self, 'Adding key for {0}'
.format(WOVariables.wo_mysql_repo))
.format(WOVar.wo_mysql_repo))
WORepo.add_key(self, '0xcbcb082a1bb943db',
keyserver="keyserver.ubuntu.com")
@@ -104,7 +104,7 @@ class WOStackMigrateController(CementBaseController):
if ((not self.app.pargs.mariadb)):
self.app.args.print_help()
if self.app.pargs.mariadb:
if WOVariables.wo_mysql_host != "localhost":
if WOVar.wo_mysql_host != "localhost":
Log.error(
self, "Remote MySQL server in use, skipping local install")

View File

@@ -23,7 +23,7 @@ from wo.core.services import WOService
from wo.core.shellexec import CommandExecutionError, WOShellExec
from wo.core.sslutils import SSL
from wo.core.template import WOTemplate
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
from wo.core.nginxhashbucket import hashbucket
@@ -32,7 +32,7 @@ def pre_pref(self, apt_packages):
if ("mariadb-server" in apt_packages or "mariadb-client" in apt_packages):
# add mariadb repository excepted on raspbian and ubuntu 19.04
if (not WOVariables.wo_distro == 'raspbian'):
if (not WOVar.wo_distro == 'raspbian'):
Log.info(self, "Adding repository for MySQL, please wait...")
mysql_pref = ("Package: *\nPin: origin "
"sfo1.mirrors.digitalocean.com"
@@ -40,7 +40,7 @@ def pre_pref(self, apt_packages):
with open('/etc/apt/preferences.d/'
'MariaDB.pref', 'w') as mysql_pref_file:
mysql_pref_file.write(mysql_pref)
WORepo.add(self, repo_url=WOVariables.wo_mysql_repo)
WORepo.add(self, repo_url=WOVar.wo_mysql_repo)
WORepo.add_key(self, '0xcbcb082a1bb943db',
keyserver='keys.gnupg.net')
WORepo.add_key(self, '0xF1656F24C74CD1D8',
@@ -50,8 +50,8 @@ def pre_pref(self, apt_packages):
chars = ''.join(random.sample(string.ascii_letters, 24))
# configure MySQL non-interactive install
if ((WOVariables.wo_distro == 'raspbian') and
(WOVariables.wo_platform_codename == 'stretch')):
if ((WOVar.wo_distro == 'raspbian') and
(WOVar.wo_platform_codename == 'stretch')):
mariadb_ver = '10.1'
else:
mariadb_ver = '10.3'
@@ -106,26 +106,26 @@ def pre_pref(self, apt_packages):
WOFileUtils.chmod(self, "/etc/mysql/conf.d/my.cnf", 0o600)
# add nginx repository
if set(WOVariables.wo_nginx).issubset(set(apt_packages)):
if set(WOVar.wo_nginx).issubset(set(apt_packages)):
Log.info(self, "Adding repository for NGINX, please wait...")
if (WOVariables.wo_distro == 'ubuntu'):
WORepo.add(self, ppa=WOVariables.wo_nginx_repo)
if (WOVar.wo_distro == 'ubuntu'):
WORepo.add(self, ppa=WOVar.wo_nginx_repo)
Log.debug(self, 'Adding ppa for Nginx')
else:
WORepo.add(self, repo_url=WOVariables.wo_nginx_repo)
WORepo.add(self, repo_url=WOVar.wo_nginx_repo)
Log.debug(self, 'Adding repository for Nginx')
WORepo.add_key(self, WOVariables.wo_nginx_key)
WORepo.add_key(self, WOVar.wo_nginx_key)
# add php repository
if (set(WOVariables.wo_php73).issubset(set(apt_packages)) or
set(WOVariables.wo_php).issubset(set(apt_packages))):
if (set(WOVar.wo_php73).issubset(set(apt_packages)) or
set(WOVar.wo_php).issubset(set(apt_packages))):
Log.info(self, "Adding repository for PHP, please wait...")
if (WOVariables.wo_distro == 'ubuntu'):
if (WOVar.wo_distro == 'ubuntu'):
Log.debug(self, 'Adding ppa for PHP')
WORepo.add(self, ppa=WOVariables.wo_php_repo)
WORepo.add(self, ppa=WOVar.wo_php_repo)
else:
# Add repository for php
if (WOVariables.wo_platform_codename == 'buster'):
if (WOVar.wo_platform_codename == 'buster'):
php_pref = ("Package: *\nPin: origin "
"packages.sury.org"
"\nPin-Priority: 1000\n")
@@ -133,22 +133,22 @@ def pre_pref(self, apt_packages):
'PHP.pref', 'w') as php_pref_file:
php_pref_file.write(php_pref)
Log.debug(self, 'Adding repo_url of php for debian')
WORepo.add(self, repo_url=WOVariables.wo_php_repo)
WORepo.add(self, repo_url=WOVar.wo_php_repo)
Log.debug(self, 'Adding deb.sury GPG key')
WORepo.add_key(self, WOVariables.wo_php_key)
WORepo.add_key(self, WOVar.wo_php_key)
# add redis repository
if set(WOVariables.wo_redis).issubset(set(apt_packages)):
if set(WOVar.wo_redis).issubset(set(apt_packages)):
Log.info(self, "Adding repository for Redis, please wait...")
if WOVariables.wo_distro == 'ubuntu':
if WOVar.wo_distro == 'ubuntu':
Log.debug(self, 'Adding ppa for redis')
WORepo.add(self, ppa=WOVariables.wo_redis_repo)
WORepo.add(self, ppa=WOVar.wo_redis_repo)
def post_pref(self, apt_packages, packages, upgrade=False):
"""Post activity after installation of packages"""
if (apt_packages):
# Nginx configuration
if set(WOVariables.wo_nginx).issubset(set(apt_packages)):
if set(WOVar.wo_nginx).issubset(set(apt_packages)):
Log.info(self, "Applying Nginx configuration templates")
# Nginx main configuration
ngxcnf = '/etc/nginx/conf.d'
@@ -306,7 +306,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
with open("/etc/nginx/common/release",
"w") as release_file:
release_file.write("v{0}"
.format(WOVariables.wo_version))
.format(WOVar.wo_version))
release_file.close()
# Following files should not be overwrited
@@ -459,7 +459,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"on https://{0}:22222 "
"or https://{1}:22222"
.format(server_ip.text,
WOVariables.wo_fqdn)])
WOVar.wo_fqdn)])
if not os.path.isfile("/opt/cf-update.sh"):
data = dict()
@@ -493,7 +493,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"Use the command nginx -t to identify "
"the cause of this issue", False)
if set(WOVariables.wo_php).issubset(set(apt_packages)):
if set(WOVar.wo_php).issubset(set(apt_packages)):
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
Log.info(self, "Configuring php7.2-fpm")
ngxroot = '/var/www/'
@@ -517,7 +517,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
config['PHP']['max_execution_time'] = '300'
config['PHP']['max_input_time'] = '300'
config['PHP']['max_input_vars'] = '20000'
config['Date']['date.timezone'] = WOVariables.wo_timezone
config['Date']['date.timezone'] = WOVar.wo_timezone
config['opcache']['opcache.enable'] = '1'
config['opcache']['opcache.interned_strings_buffer'] = '8'
config['opcache']['opcache.max_accelerated_files'] = '10000'
@@ -627,7 +627,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
WOService.restart_service(self, 'php7.2-fpm')
# PHP7.3 configuration
if set(WOVariables.wo_php73).issubset(set(apt_packages)):
if set(WOVar.wo_php73).issubset(set(apt_packages)):
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
Log.info(self, "Configuring php7.3-fpm")
ngxroot = '/var/www/'
@@ -651,7 +651,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
config['PHP']['max_execution_time'] = '300'
config['PHP']['max_input_time'] = '300'
config['PHP']['max_input_vars'] = '20000'
config['Date']['date.timezone'] = WOVariables.wo_timezone
config['Date']['date.timezone'] = WOVar.wo_timezone
config['opcache']['opcache.enable'] = '1'
config['opcache']['opcache.interned_strings_buffer'] = '8'
config['opcache']['opcache.max_accelerated_files'] = '10000'
@@ -815,7 +815,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
WOGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git")
# create fail2ban configuration files
if set(WOVariables.wo_fail2ban).issubset(set(apt_packages)):
if set(WOVar.wo_fail2ban).issubset(set(apt_packages)):
WOGit.add(self, ["/etc/fail2ban"],
msg="Adding Fail2ban into Git")
if not os.path.isfile("/etc/fail2ban/jail.d/custom.conf"):
@@ -1004,7 +1004,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
WOService.restart_service(self, 'redis-server')
# ClamAV configuration
if set(WOVariables.wo_clamav).issubset(set(apt_packages)):
if set(WOVar.wo_clamav).issubset(set(apt_packages)):
Log.debug(self, "Setting up freshclam cronjob")
if not os.path.isfile("/opt/freshclam.sh"):
data = dict()
@@ -1032,26 +1032,26 @@ def post_pref(self, apt_packages, packages, upgrade=False):
Log.debug(self, 'Extracting file /var/lib/wo/tmp/pma.tar.gz to '
'location /var/lib/wo/tmp/')
if not os.path.exists('{0}22222/htdocs/db'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
Log.debug(self, "Creating new directory "
"{0}22222/htdocs/db"
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
os.makedirs('{0}22222/htdocs/db'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
if not os.path.exists('{0}22222/htdocs/db/pma/'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
shutil.move('/var/lib/wo/tmp/phpmyadmin-STABLE/',
'{0}22222/htdocs/db/pma/'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
shutil.copyfile('{0}22222/htdocs/db/pma'
'/config.sample.inc.php'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'{0}22222/htdocs/db/pma/config.inc.php'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
Log.debug(self, 'Setting Blowfish Secret Key '
'FOR COOKIE AUTH to '
'{0}22222/htdocs/db/pma/config.inc.php file '
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
blowfish_key = ''.join([random.choice
(string.ascii_letters +
string.digits)
@@ -1059,7 +1059,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
WOFileUtils.searchreplace(self,
'{0}22222/htdocs/db/pma'
'/config.inc.php'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"$cfg[\'blowfish_secret\']"
" = \'\';",
"$cfg[\'blowfish_secret\']"
@@ -1067,21 +1067,21 @@ def post_pref(self, apt_packages, packages, upgrade=False):
.format(blowfish_key))
Log.debug(self, 'Setting HOST Server For Mysql to '
'{0}22222/htdocs/db/pma/config.inc.php file '
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
WOFileUtils.searchreplace(self,
'{0}22222/htdocs/db/pma'
'/config.inc.php'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"$cfg[\'Servers\'][$i][\'host\']"
" = \'localhost\';", "$cfg"
"[\'Servers\'][$i][\'host\'] "
"= \'{0}\';"
.format(WOVariables.wo_mysql_host))
.format(WOVar.wo_mysql_host))
Log.debug(self, 'Setting Privileges of webroot permission to '
'{0}22222/htdocs/db/pma file '
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
WOFileUtils.chown(self, '{0}22222/htdocs'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'www-data',
'www-data',
recursive=True)
@@ -1107,19 +1107,19 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"/var/www/22222/htdocs/db/pma/")
WOFileUtils.chown(
self, '{0}22222/htdocs/db/pma'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'www-data',
'www-data',
recursive=True)
Log.valide(self, "Updating phpMyAdmin")
if not os.path.exists('{0}22222/htdocs/cache/'
'redis/phpRedisAdmin'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
Log.debug(self, "Creating new directory "
"{0}22222/htdocs/cache/redis"
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
os.makedirs('{0}22222/htdocs/cache/redis/phpRedisAdmin'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
if not os.path.isfile('/var/www/22222/htdocs/cache/redis/'
'phpRedisAdmin/composer.lock'):
WOShellExec.cmd_exec(
@@ -1128,7 +1128,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"erik-dubbelboer/php-redis-admin "
"/var/www/22222/htdocs/cache/redis/phpRedisAdmin")
WOFileUtils.chown(self, '{0}22222/htdocs'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'www-data',
'www-data',
recursive=True)
@@ -1194,25 +1194,25 @@ def post_pref(self, apt_packages, packages, upgrade=False):
for x in packages):
Log.debug(self, "Extracting wo-dashboard.tar.gz "
"to location {0}22222/htdocs/"
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
WOExtract.extract(self, '/var/lib/wo/tmp/'
'wo-dashboard.tar.gz',
'{0}22222/htdocs'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
wo_wan = os.popen("/sbin/ip -4 route get 8.8.8.8 | "
"grep -oP \"dev [^[:space:]]+ \" "
"| cut -d ' ' -f 2").read()
if (wo_wan != 'eth0' and wo_wan != ''):
WOFileUtils.searchreplace(self,
"{0}22222/htdocs/index.html"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"eth0",
"{0}".format(wo_wan))
Log.debug(self, "Setting Privileges to "
"{0}22222/htdocs"
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
WOFileUtils.chown(self, '{0}22222/htdocs'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'www-data',
'www-data',
recursive=True)
@@ -1222,18 +1222,18 @@ def post_pref(self, apt_packages, packages, upgrade=False):
for x in packages):
Log.debug(self, "Extracting extplorer.tar.gz "
"to location {0}22222/htdocs/files"
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
WOExtract.extract(self, '/var/lib/wo/tmp/extplorer.tar.gz',
'/var/lib/wo/tmp/')
shutil.move('/var/lib/wo/tmp/extplorer-{0}'
.format(WOVariables.wo_extplorer),
.format(WOVar.wo_extplorer),
'{0}22222/htdocs/files'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
Log.debug(self, "Setting Privileges to "
"{0}22222/htdocs/files"
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
WOFileUtils.chown(self, '{0}22222/htdocs'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'www-data',
'www-data',
recursive=True)
@@ -1247,41 +1247,41 @@ def post_pref(self, apt_packages, packages, upgrade=False):
self, '/var/lib/wo/tmp/webgrind.tar.gz',
'/var/lib/wo/tmp/')
if not os.path.exists('{0}22222/htdocs/php'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
Log.debug(self, "Creating directroy "
"{0}22222/htdocs/php"
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
os.makedirs('{0}22222/htdocs/php'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
if not os.path.exists('{0}22222/htdocs/php/webgrind'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
shutil.move('/var/lib/wo/tmp/webgrind-master/',
'{0}22222/htdocs/php/webgrind'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
WOFileUtils.searchreplace(
self, "{0}22222/htdocs/php/webgrind/"
"config.php"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"/usr/local/bin/dot", "/usr/bin/dot")
WOFileUtils.searchreplace(
self, "{0}22222/htdocs/php/webgrind/"
"config.php"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"Europe/Copenhagen",
WOVariables.wo_timezone)
WOVar.wo_timezone)
WOFileUtils.searchreplace(
self, "{0}22222/htdocs/php/webgrind/"
"config.php"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
"90", "100")
Log.debug(self, "Setting Privileges of webroot permission to "
"{0}22222/htdocs/php/webgrind/ file "
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
WOFileUtils.chown(self, '{0}22222/htdocs'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'www-data',
'www-data',
recursive=True)
@@ -1294,20 +1294,20 @@ def post_pref(self, apt_packages, packages, upgrade=False):
self, '/var/lib/wo/tmp/anemometer.tar.gz',
'/var/lib/wo/tmp/')
if not os.path.exists('{0}22222/htdocs/db/'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
Log.debug(self, "Creating directory")
os.makedirs('{0}22222/htdocs/db/'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
if not os.path.exists('{0}22222/htdocs/db/anemometer'
.format(WOVariables.wo_webroot)):
.format(WOVar.wo_webroot)):
shutil.move('/var/lib/wo/tmp/Anemometer-master',
'{0}22222/htdocs/db/anemometer'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
chars = ''.join(random.sample(string.ascii_letters, 8))
try:
WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db'
'/anemometer/install.sql'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "failed to configure Anemometer",
@@ -1334,11 +1334,11 @@ def post_pref(self, apt_packages, packages, upgrade=False):
# Custom Anemometer configuration
Log.debug(self, "configration Anemometer")
data = dict(host=WOVariables.wo_mysql_host, port='3306',
data = dict(host=WOVar.wo_mysql_host, port='3306',
user='anemometer', password=chars)
WOTemplate.deploy(self, '{0}22222/htdocs/db/anemometer'
'/conf/config.inc.php'
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'anemometer.mustache', data)
# pt-query-advisor

View File

@@ -6,7 +6,7 @@ from cement.core.controller import CementBaseController, expose
from wo.core.aptget import WOAptGet
from wo.core.logging import Log
from wo.core.services import WOService
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
class WOStackStatusController(CementBaseController):
@@ -57,8 +57,8 @@ class WOStackStatusController(CementBaseController):
Log.info(self, "PHP7.3-FPM is not installed")
if pargs.mysql:
if ((WOVariables.wo_mysql_host == "localhost") or
(WOVariables.wo_mysql_host == "127.0.0.1")):
if ((WOVar.wo_mysql_host == "localhost") or
(WOVar.wo_mysql_host == "127.0.0.1")):
if (WOAptGet.is_installed(self, 'mysql-server') or
WOAptGet.is_installed(self, 'percona-server-server-5.6') or
WOAptGet.is_installed(self, 'mariadb-server')):
@@ -144,8 +144,8 @@ class WOStackStatusController(CementBaseController):
# mysql
if pargs.mysql:
if ((WOVariables.wo_mysql_host == "localhost") or
(WOVariables.wo_mysql_host == "127.0.0.1")):
if ((WOVar.wo_mysql_host == "localhost") or
(WOVar.wo_mysql_host == "127.0.0.1")):
if (WOAptGet.is_installed(self, 'mysql-server') or
WOAptGet.is_installed(self, 'percona-server-server-5.6') or
WOAptGet.is_installed(self, 'mariadb-server')):
@@ -230,8 +230,8 @@ class WOStackStatusController(CementBaseController):
Log.info(self, "PHP7.3-FPM is not installed")
if pargs.mysql:
if ((WOVariables.wo_mysql_host == "localhost") or
(WOVariables.wo_mysql_host == "127.0.0.1")):
if ((WOVar.wo_mysql_host == "localhost") or
(WOVar.wo_mysql_host == "127.0.0.1")):
if ((WOAptGet.is_installed(self, 'mysql-server') or
WOAptGet.is_installed(self,
'percona-server-server-5.6') or
@@ -316,8 +316,8 @@ class WOStackStatusController(CementBaseController):
Log.info(self, "PHP7.3-FPM is not installed")
if pargs.mysql:
if ((WOVariables.wo_mysql_host == "localhost") or
(WOVariables.wo_mysql_host == "127.0.0.1")):
if ((WOVar.wo_mysql_host == "localhost") or
(WOVar.wo_mysql_host == "127.0.0.1")):
if (WOAptGet.is_installed(self, 'mysql-server') or
WOAptGet.is_installed(self, 'percona-server-server-5.6') or
WOAptGet.is_installed(self, 'mariadb-server')):
@@ -401,8 +401,8 @@ class WOStackStatusController(CementBaseController):
Log.info(self, "PHP7.3-FPM is not installed")
if pargs.mysql:
if ((WOVariables.wo_mysql_host == "localhost") or
(WOVariables.wo_mysql_host == "127.0.0.1")):
if ((WOVar.wo_mysql_host == "localhost") or
(WOVar.wo_mysql_host == "127.0.0.1")):
if (WOAptGet.is_installed(self, 'mysql-server') or
WOAptGet.is_installed(self, 'percona-server-server-5.6') or
WOAptGet.is_installed(self, 'mariadb-server')):

View File

@@ -12,7 +12,7 @@ from wo.core.fileutils import WOFileUtils
from wo.core.logging import Log
from wo.core.services import WOService
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
class WOStackUpgradeController(CementBaseController):
@@ -92,31 +92,31 @@ class WOStackUpgradeController(CementBaseController):
if pargs.nginx:
if WOAptGet.is_installed(self, 'nginx-custom'):
apt_packages = apt_packages + WOVariables.wo_nginx
apt_packages = apt_packages + WOVar.wo_nginx
else:
if os.path.isfile(self, '/usr/sbin/nginx'):
Log.info(self, "Updating Nginx templates")
post_pref(self, WOVariables.wo_nginx, [])
post_pref(self, WOVar.wo_nginx, [])
else:
Log.info(self, "Nginx Stable is not already installed")
if pargs.php:
if WOAptGet.is_installed(self, 'php7.2-fpm'):
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
apt_packages = apt_packages + WOVariables.wo_php + \
WOVariables.wo_php_extra
apt_packages = apt_packages + WOVar.wo_php + \
WOVar.wo_php_extra
else:
apt_packages = apt_packages + WOVariables.wo_php
apt_packages = apt_packages + WOVar.wo_php
else:
Log.info(self, "PHP 7.2 is not installed")
if pargs.php73:
if WOAptGet.is_installed(self, 'php7.3-fpm'):
if not WOAptGet.is_installed(self, 'php7.2-fpm'):
apt_packages = apt_packages + WOVariables.wo_php73 + \
WOVariables.wo_php_extra
apt_packages = apt_packages + WOVar.wo_php73 + \
WOVar.wo_php_extra
else:
apt_packages = apt_packages + WOVariables.wo_php73
apt_packages = apt_packages + WOVar.wo_php73
else:
Log.info(self, "PHP 7.3 is not installed")
@@ -137,7 +137,7 @@ class WOStackUpgradeController(CementBaseController):
packages = packages + [["https://github.com/wp-cli/wp-cli/"
"releases/download/v{0}/"
"wp-cli-{0}.phar"
"".format(WOVariables.wo_wp_cli),
"".format(WOVar.wo_wp_cli),
"/usr/local/bin/wp",
"WP-CLI"]]
else:
@@ -157,7 +157,7 @@ class WOStackUpgradeController(CementBaseController):
packages = packages + \
[["https://github.com/WordOps/wordops-dashboard/"
"releases/download/v{0}/wordops-dashboard.tar.gz"
.format(WOVariables.wo_dashboard),
.format(WOVar.wo_dashboard),
"/var/lib/wo/tmp/wo-dashboard.tar.gz",
"WordOps Dashboard"]]
@@ -168,7 +168,7 @@ class WOStackUpgradeController(CementBaseController):
"/phpMyAdmin/{0}/"
"phpMyAdmin-{0}-"
"all-languages"
".tar.gz".format(WOVariables.wo_phpmyadmin),
".tar.gz".format(WOVar.wo_phpmyadmin),
"/var/lib/wo/tmp/pma.tar.gz",
"PHPMyAdmin"]]
else:
@@ -209,7 +209,7 @@ class WOStackUpgradeController(CementBaseController):
# additional pre_pref
if ["nginx-custom"] in apt_packages:
pre_pref(self, WOVariables.wo_nginx)
pre_pref(self, WOVar.wo_nginx)
if ["php7.2-fpm"] in apt_packages:
WOAptGet.remove(self, ['php7.2-fpm'],
auto=False, purge=True)
@@ -219,8 +219,8 @@ class WOStackUpgradeController(CementBaseController):
# check if nginx upgrade is blocked
if os.path.isfile(
'/etc/apt/preferences.d/nginx-block'):
apt_packages.remove(WOVariables.wo_nginx)
post_pref(self, WOVariables.wo_nginx, [], True)
apt_packages.remove(WOVar.wo_nginx)
post_pref(self, WOVar.wo_nginx, [], True)
# upgrade packages
WOAptGet.install(self, apt_packages)
Log.valide(self, "Upgrading APT Packages")
@@ -269,7 +269,7 @@ class WOStackUpgradeController(CementBaseController):
"/wordops-dashboard/"
"releases/download/v{0}/"
"wordops-dashboard.tar.gz"
.format(WOVariables.wo_dashboard),
.format(WOVar.wo_dashboard),
"/var/lib/wo/tmp/wo-dashboard.tar.gz",
"WordOps Dashboard"]])
@@ -290,20 +290,20 @@ class WOStackUpgradeController(CementBaseController):
'/var/lib/wo/tmp/')
shutil.copyfile(('{0}22222/htdocs/db/pma'
'/config.inc.php'
.format(WOVariables.wo_webroot)),
.format(WOVar.wo_webroot)),
('/var/lib/wo/tmp/phpMyAdmin-{0}'
'-all-languages/config.inc.php'
.format(WOVariables.wo_phpmyadmin))
.format(WOVar.wo_phpmyadmin))
)
WOFileUtils.rm(self, '{0}22222/htdocs/db/pma'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
shutil.move('/var/lib/wo/tmp/phpMyAdmin-{0}'
'-all-languages/'
.format(WOVariables.wo_phpmyadmin),
.format(WOVar.wo_phpmyadmin),
'{0}22222/htdocs/db/pma/'
.format(WOVariables.wo_webroot))
.format(WOVar.wo_webroot))
WOFileUtils.chown(self, "{0}22222/htdocs"
.format(WOVariables.wo_webroot),
.format(WOVar.wo_webroot),
'www-data',
'www-data', recursive=True)
Log.valide(self, "Upgrading phpMyAdmin")

View File

@@ -7,7 +7,7 @@ from wo.core.fileutils import WOFileUtils
from wo.core.git import WOGit
from wo.core.logging import Log
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
class WOAcme:
@@ -77,7 +77,7 @@ class WOAcme:
"--fullchain-file {0}/{1}/fullchain.pem "
"--ca-file {0}/{1}/ca.pem --reloadcmd \"nginx -t && "
"service nginx restart\" "
.format(WOVariables.wo_ssl_live,
.format(WOVar.wo_ssl_live,
wo_domain_name, WOAcme.wo_acme_exec)):
Log.valide(self, "Deploying SSL cert")
else:
@@ -97,7 +97,7 @@ class WOAcme:
"ssl_certificate_key {0}/{1}/key.pem;\n"
"ssl_trusted_certificate {0}/{1}/ca.pem;\n"
"ssl_stapling_verify on;\n"
.format(WOVariables.wo_ssl_live, wo_domain_name))
.format(WOVar.wo_ssl_live, wo_domain_name))
sslconf.close()
if not WOFileUtils.grep(self, '/var/www/22222/conf/nginx/ssl.conf',
@@ -109,7 +109,7 @@ class WOAcme:
"ssl_certificate_key {0}/{1}/key.pem;\n"
"ssl_trusted_certificate {0}/{1}/ca.pem;\n"
"ssl_stapling_verify on;\n"
.format(WOVariables.wo_ssl_live, wo_domain_name))
.format(WOVar.wo_ssl_live, wo_domain_name))
sslconf.close()
WOGit.add(self, ["/etc/letsencrypt"],

View File

@@ -3,7 +3,7 @@ import os
from wo.core.logging import Log
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
class WORepo():
@@ -25,7 +25,7 @@ class WORepo():
if repo_url is not None:
repo_file_path = ("/etc/apt/sources.list.d/" +
WOVariables().wo_repo_file)
WOVar().wo_repo_file)
try:
if not os.path.isfile(repo_file_path):
with open(repo_file_path,
@@ -65,7 +65,7 @@ class WORepo():
.format(ppa_name=ppa))
elif repo_url:
repo_file_path = ("/etc/apt/sources.list.d/" +
WOVariables().wo_repo_file)
WOVar().wo_repo_file)
try:
repofile = open(repo_file_path, "w+")

View File

@@ -1,20 +1,20 @@
import requests
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
def check_fqdn(self, wo_host):
"""FQDN check with WordOps, for mail server hostname must be FQDN"""
# wo_host=os.popen("hostname -f | tr -d '\n'").read()
if '.' in wo_host:
WOVariables.wo_fqdn = wo_host
WOVar.wo_fqdn = wo_host
with open('/etc/hostname', encoding='utf-8', mode='w') as hostfile:
hostfile.write(wo_host)
WOShellExec.cmd_exec(self, "sed -i \"1i\\127.0.0.1 {0}\" /etc/hosts"
.format(wo_host))
if WOVariables.wo_distro == 'debian':
if WOVar.wo_distro == 'debian':
WOShellExec.cmd_exec(self, "/etc/init.d/hostname.sh start")
else:
WOShellExec.cmd_exec(self, "service hostname restart")
@@ -29,7 +29,7 @@ def check_fqdn_ip(self):
x = requests.get('http://v4.wordops.eu')
ip = (x.text).strip()
wo_fqdn = WOVariables.wo_fqdn
wo_fqdn = WOVar.wo_fqdn
y = requests.get('http://v4.wordops.eu/dns/{0}/'.format(wo_fqdn))
ip_fqdn = (y.text).strip()

View File

@@ -3,10 +3,10 @@ from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
# db_path = self.app.config.get('site', 'db_path')
engine = create_engine(WOVariables.wo_db_uri, convert_unicode=True)
engine = create_engine(WOVar.wo_db_uri, convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))

View File

@@ -24,7 +24,7 @@ class WODomain():
else:
final_domain = domain_name
return (final_domain, domain_name)
return final_domain
def getlevel(self, domain):
"""
@@ -49,3 +49,4 @@ class WODomain():
root_domain = ('.'.join(domain_name[1:]))
suffix_file.close()
return (domain_type, root_domain)
return ('other', domain)

View File

@@ -6,7 +6,7 @@ import pymysql
from pymysql import DatabaseError, Error, connections
from wo.core.logging import Log
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
class MySQLConnectionError(Exception):
@@ -115,7 +115,7 @@ class WOMysql():
stderr=subprocess.PIPE, shell=True)
p2 = subprocess.Popen("/usr/bin/pigz -c > "
"/var/wo-mysqlbackup/{0}{1}.sql.gz"
.format(dbs, WOVariables.wo_date),
.format(dbs, WOVar.wo_date),
stdin=p1.stdout,
shell=True)

View File

@@ -5,7 +5,7 @@ import re
from wo.core.fileutils import WOFileUtils
from wo.core.logging import Log
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVariables
from wo.core.variables import WOVar
class SSL:
@@ -63,11 +63,11 @@ class SSL:
self, '{0}/htdocs/'.format(wo_site_webroot))
if WOShellExec.cmd_exec(
self, "{0} --allow-root core is-installed"
.format(WOVariables.wo_wp_cli)):
.format(WOVar.wo_wp_cli)):
wo_siteurl = (
WOShellExec.cmd_exec_stdout(
self, "{0} option get siteurl "
.format(WOVariables.wo_wpcli_path) +
.format(WOVar.wo_wpcli_path) +
"--allow-root --quiet"))
test_url = re.split(":", wo_siteurl)
if not (test_url[0] == 'https'):
@@ -76,11 +76,11 @@ class SSL:
WOShellExec.cmd_exec(
self, "{0} option update siteurl "
"\'https://{1}\' --allow-root".format(
WOVariables.wo_wpcli_path, domain))
WOVar.wo_wpcli_path, domain))
WOShellExec.cmd_exec(
self, "{0} option update home "
"\'https://{1}\' --allow-root".format(
WOVariables.wo_wpcli_path, domain))
WOVar.wo_wpcli_path, domain))
WOShellExec.cmd_exec(
self, "{0} search-replace \'http://{0}\'"
"\'https://{0}\' --skip-columns=guid "

View File

@@ -9,6 +9,8 @@ Render Templates
class WOTemplate():
"""WordOps template utilities"""
def deploy(self, fileconf, template, data, overwrite=True):
"""Deploy template with render()"""
data = dict(data)

View File

@@ -1,13 +1,15 @@
"""WordOps core variable module"""
import configparser
import datetime
import os
import socket
from datetime import datetime
from re import match
from socket import getfqdn
import distro
from distro import linux_distribution
from sh import git
class WOVariables():
class WOVar():
"""Intialization of core variables"""
# WordOps version
@@ -23,14 +25,14 @@ class WOVariables():
wo_wpcli_path = '/usr/local/bin/wp'
# Current date and time of System
wo_date = datetime.datetime.now().strftime('%d%b%Y-%H-%M-%S')
wo_date = datetime.now().strftime('%d%b%Y-%H-%M-%S')
# WordOps core variables
wo_distro = distro.linux_distribution(
wo_distro = linux_distribution(
full_distribution_name=False)[0].lower()
wo_platform_version = distro.linux_distribution(
wo_platform_version = linux_distribution(
full_distribution_name=False)[1].lower()
wo_platform_codename = distro.linux_distribution(
wo_platform_codename = linux_distribution(
full_distribution_name=False)[2].lower()
# Get timezone of system
@@ -43,7 +45,7 @@ class WOVariables():
wo_timezone = "Europe/Amsterdam"
# Get FQDN of system
wo_fqdn = socket.getfqdn()
wo_fqdn = getfqdn()
# WordOps default webroot path
wo_webroot = '/var/www/'
@@ -64,11 +66,25 @@ class WOVariables():
wo_user = config['user']['name']
wo_email = config['user']['email']
except Exception:
print("WordOps (wo) require an username & and an email "
"address to configure Git (used to save server configurations)")
print("Your informations will ONLY be stored locally")
wo_user = input("Enter your name: ")
while wo_user == "":
print("Unfortunately, this can't be left blank")
wo_user = input("Enter your name: ")
wo_email = input("Enter your email: ")
os.system("git config --global user.name {0}".format(wo_user))
os.system(
"git config --global user.email {0}".format(wo_email))
while not match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",
wo_email):
print("Whoops, seems like you made a typo - "
"the e-mailaddress is invalid...")
wo_email = input("Enter your email: ")
git.config("--global", "user.name", "{0}".format(wo_user))
git.config("--global", "user.email", "{0}".format(wo_email))
# MySQL hostname
wo_mysql_host = ""