Merge pull request #52 from WordOps/updating-configuration

Updating configuration
This commit is contained in:
VirtuBox
2019-04-03 11:45:31 +02:00
committed by GitHub
6 changed files with 193 additions and 110 deletions

View File

@@ -25,6 +25,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- WordOps configuration backup before upgrade - WordOps configuration backup before upgrade
- Previous acme.sh certs migration - Previous acme.sh certs migration
- "wo maintenance" command to perform server package update & cleanup - "wo maintenance" command to perform server package update & cleanup
- Support for Netdata on backend : https://server.hostname:22222/netdata/
- New Stacks : composer and netdata
#### Changed #### Changed
@@ -48,7 +50,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- PHP 7.2 & PHP 7.3 pool configuration during upgrade - PHP 7.2 & PHP 7.3 pool configuration during upgrade
- WordOps backup directory creation before upgrade - WordOps backup directory creation before upgrade
- EasyEngine database sync during migration - EasyEngine database sync during migration
- command "wo info" - fix command "wo info"
- phpmyadmin install with composer
- command "wo clean --memcached"
### v3.9.4 - 2019-03-15 ### v3.9.4 - 2019-03-15

41
install
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# WordOps install and update script # WordOps install and update script
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@@ -145,10 +145,10 @@ wo_install_dep() {
{ {
if [ "$wo_linux_distro" == "Ubuntu" ]; then if [ "$wo_linux_distro" == "Ubuntu" ]; then
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar software-properties-common pigz gnupg2 fail2ban cron ccze rsync tree > /dev/null 2>&1 DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar software-properties-common pigz gnupg2 fail2ban cron ccze rsync tree haveged ufw > /dev/null 2>&1
else else
wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip dirmngr sudo python3 python3-apt python3-setuptools python3-dev ca-certificates sqlite3 git tar software-properties-common pigz apt-transport-https gnupg2 fail2ban cron ccze rsync tree > /dev/null 2>&1 DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip dirmngr sudo python3 python3-apt python3-setuptools python3-dev ca-certificates sqlite3 git tar software-properties-common pigz apt-transport-https gnupg2 fail2ban cron ccze rsync tree haveged ufw > /dev/null 2>&1
fi fi
locale-gen en locale-gen en
@@ -425,7 +425,11 @@ wo_upgrade_nginx() {
rm -f /tmp/nginx-wo.key rm -f /tmp/nginx-wo.key
sudo apt-get update sudo apt-get update
CHECK_NGINX_UPSTREAM_VERSION=$(grep "v3.9.5.1" /etc/nginx/conf.d/fastcgi.conf) if [ -f /etc/nginx/common/release ]; then
CHECK_NGINX_UPSTREAM_VERSION=$(grep "$wo_version_new" /etc/nginx/common/release)
else
CHECK_NGINX_UPSTREAM_VERSION=$(grep "$wo_version_new" /etc/nginx/conf.d/fastcgi.conf)
fi
if [ -z "$CHECK_NGINX_UPSTREAM_VERSION" ]; then if [ -z "$CHECK_NGINX_UPSTREAM_VERSION" ]; then
# stop nginx # stop nginx
@@ -456,11 +460,13 @@ wo_upgrade_nginx() {
rm -f /etc/php/7.2/fpm/pool.d/{www.conf,www-two.conf,debug.conf} rm -f /etc/php/7.2/fpm/pool.d/{www.conf,www-two.conf,debug.conf}
fi fi
/usr/local/bin/wo stack install --nginx --php /usr/local/bin/wo stack install --nginx --php
echo "$wo_version_new" > /etc/nginx/common/release
if [ -n "$CHECK_PHP73" ]; then if [ -n "$CHECK_PHP73" ]; then
apt-get remove php7.3-fpm -y -qq --purge apt-get remove php7.3-fpm -y -qq --purge
rm -f /etc/php/7.3/fpm/pool.d/{www.conf,www-two.conf,debug.conf} rm -f /etc/php/7.3/fpm/pool.d/{www.conf,www-two.conf,debug.conf}
/usr/local/bin/wo stack install --php73 /usr/local/bin/wo stack install --php73
fi fi
rm -f /etc/nginx/common/acl.conf /etc/nginx/conf.d/{map-wp-cache.conf,map-wp.conf}
fi fi
# restore sites and configuration # restore sites and configuration
@@ -535,13 +541,6 @@ wo_update_latest() {
chmod 600 /root/.my.cnf chmod 600 /root/.my.cnf
fi fi
fi fi
# Fix WordPress example.html issue
# Ref: http://wptavern.com/xss-vulnerability-in-jetpack-and-the-twenty-fifteen-default-theme-affects-millions-of-wordpress-users
CHECK_DEINSTALL_NGINX=$(dpkg --get-selections | grep -v deinstall | grep nginx)
if [ -z "$CHECK_DEINSTALL_NGINX" ]; then
cp /usr/lib/wo/templates/locations.mustache /etc/nginx/common/locations-php72.conf
fi
# Fix Redis-server security issue # Fix Redis-server security issue
# http://redis.io/topics/security # http://redis.io/topics/security
@@ -620,12 +619,14 @@ if [ -x /usr/local/bin/wo ]; then
wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log
wo_install >> wo_install_log 2>&1 wo_install >> wo_install_log 2>&1
if [ -x "$(command -v nginx)" ]; then if [ -x "$(command -v nginx)" ]; then
wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log
wo_upgrade_nginx | tee -ai $wo_install_log wo_upgrade_nginx | tee -ai $wo_install_log
fi fi
wo_update_latest | tee -ai $wo_install_log wo_update_latest | tee -ai $wo_install_log
wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log if [ ! -d /opt/acme.sh ]; then
wo_install_acme_sh | tee -ai $wo_install_log wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
fi
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
wo_git_init | tee -ai $wo_install_log wo_git_init | tee -ai $wo_install_log
wo_update_wp_cli | tee -ai $wo_install_log wo_update_wp_cli | tee -ai $wo_install_log
@@ -650,12 +651,14 @@ else
wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log
wo_install >> wo_install_log 2>&1 wo_install >> wo_install_log 2>&1
if [ -x "$(command -v nginx)" ]; then if [ -x "$(command -v nginx)" ]; then
wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log
wo_upgrade_nginx | tee -ai $wo_install_log wo_upgrade_nginx | tee -ai $wo_install_log
fi fi
wo_update_latest | tee -ai $wo_install_log wo_update_latest | tee -ai $wo_install_log
wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log if [ ! -d /opt/acme.sh ]; then
wo_install_acme_sh | tee -ai $wo_install_log wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
fi
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
wo_git_init | tee -ai $wo_install_log wo_git_init | tee -ai $wo_install_log
wo_update_wp_cli | tee -ai $wo_install_log wo_update_wp_cli | tee -ai $wo_install_log

View File

@@ -65,7 +65,7 @@ class WOCleanController(CementBaseController):
Log.info(self, "Redis is not installed") Log.info(self, "Redis is not installed")
@expose(hide=True) @expose(hide=True)
def clean_memcache(self): def clean_memcached(self):
try: try:
if(WOAptGet.is_installed(self, "memcached")): if(WOAptGet.is_installed(self, "memcached")):
WOService.restart_service(self, "memcached") WOService.restart_service(self, "memcached")

View File

@@ -252,7 +252,7 @@ class WOInfoController(CementBaseController):
if self.app.pargs.nginx: if self.app.pargs.nginx:
if (WOAptGet.is_installed(self, 'nginx-custom') or if (WOAptGet.is_installed(self, 'nginx-custom') or
WOAptGet.is_installed(self, 'nginx-common')): WOAptGet.is_installed(self, 'nginx-wo')):
self.info_nginx() self.info_nginx()
else: else:
Log.error(self, "Nginx is not installed") Log.error(self, "Nginx is not installed")

View File

@@ -725,7 +725,8 @@ def site_package_check(self, stype):
Log.debug(self, "Setting apt_packages variable for PHP 7.2") 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.2-fpm'):
if not WOAptGet.is_installed(self, 'php7.3-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 + WOVariables.wo_php + \
WOVariables.wo_php_extra
else: else:
apt_packages = apt_packages + WOVariables.wo_php apt_packages = apt_packages + WOVariables.wo_php
@@ -733,7 +734,8 @@ def site_package_check(self, stype):
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'):
if not WOAptGet.is_installed(self, 'php7.2-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 + WOVariables.wo_php + \
WOVariables.wo_php73 + WOVariables.wo_php_extra
else: else:
apt_packages = apt_packages + WOVariables.wo_php73 apt_packages = apt_packages + WOVariables.wo_php73
@@ -796,7 +798,8 @@ def site_package_check(self, stype):
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'):
if not WOAptGet.is_installed(self, 'php7.2-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 + WOVariables.wo_php + \
WOVariables.wo_php73 + WOVariables.wo_php_extra
else: else:
apt_packages = apt_packages + WOVariables.wo_php73 apt_packages = apt_packages + WOVariables.wo_php73

View File

@@ -63,6 +63,11 @@ class WOStackController(CementBaseController):
dict(help='Install WPCLI stack', action='store_true')), dict(help='Install WPCLI stack', action='store_true')),
(['--phpmyadmin'], (['--phpmyadmin'],
dict(help='Install PHPMyAdmin stack', action='store_true')), dict(help='Install PHPMyAdmin stack', action='store_true')),
(['--composer'],
dict(help='Install Composer stack', action='store_true')),
(['--netdata'],
dict(help='Install Netdata monitoring suite',
action='store_true')),
(['--adminer'], (['--adminer'],
dict(help='Install Adminer stack', action='store_true')), dict(help='Install Adminer stack', action='store_true')),
(['--utils'], (['--utils'],
@@ -369,6 +374,11 @@ class WOStackController(CementBaseController):
self.app.render((data), 'locations.mustache', self.app.render((data), 'locations.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
if not os.path.isfile("/etc/nginx/common/release"):
with open("/etc/nginx/common/release",
"a") as release_file:
release_file.write("v3.9.5")
release_file.close()
# Nginx-Plus does not have nginx # Nginx-Plus does not have nginx
# package structure like this # package structure like this
@@ -770,10 +780,10 @@ class WOStackController(CementBaseController):
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
os.makedirs('{0}22222/htdocs/fpm/status/' os.makedirs('{0}22222/htdocs/fpm/status/'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
open('{0}22222/htdocs/fpm/status/debug' open('{0}22222/htdocs/fpm/status/debug72'
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='a').close() encoding='utf-8', mode='a').close()
open('{0}22222/htdocs/fpm/status/php' open('{0}22222/htdocs/fpm/status/php72'
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='a').close() encoding='utf-8', mode='a').close()
@@ -924,10 +934,10 @@ class WOStackController(CementBaseController):
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
os.makedirs('{0}22222/htdocs/fpm/status/' os.makedirs('{0}22222/htdocs/fpm/status/'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
open('{0}22222/htdocs/fpm/status/debug' open('{0}22222/htdocs/fpm/status/debug73'
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='a').close() encoding='utf-8', mode='a').close()
open('{0}22222/htdocs/fpm/status/php' open('{0}22222/htdocs/fpm/status/php73'
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='a').close() encoding='utf-8', mode='a').close()
@@ -995,32 +1005,35 @@ class WOStackController(CementBaseController):
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
os.makedirs('{0}22222/htdocs/db' os.makedirs('{0}22222/htdocs/db'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
shutil.move('/tmp/phpmyadmin-STABLE/', if not os.path.exists('{0}22222/htdocs/db/'
'{0}22222/htdocs/db/pma/' 'pma/phpmyadmin-STABLE'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot)):
shutil.copyfile('{0}22222/htdocs/db/pma/config.sample.inc.php' shutil.move('/tmp/phpmyadmin-STABLE/',
.format(WOVariables.wo_webroot), '{0}22222/htdocs/db/pma/'
'{0}22222/htdocs/db/pma/config.inc.php'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
Log.debug(self, 'Setting Blowfish Secret Key FOR COOKIE AUTH to ' shutil.copyfile('{0}22222/htdocs/db/pma/config.sample.inc.php'
'{0}22222/htdocs/db/pma/config.inc.php file ' .format(WOVariables.wo_webroot),
.format(WOVariables.wo_webroot)) '{0}22222/htdocs/db/pma/config.inc.php'
blowfish_key = ''.join([random.choice .format(WOVariables.wo_webroot))
(string.ascii_letters + string.digits) Log.debug(self, 'Setting Blowfish Secret Key FOR COOKIE AUTH to '
for n in range(25)]) '{0}22222/htdocs/db/pma/config.inc.php file '
WOFileUtils.searchreplace(self, .format(WOVariables.wo_webroot))
'{0}22222/htdocs/db/pma/config.inc.php' blowfish_key = ''.join([random.choice
.format(WOVariables.wo_webroot), (string.ascii_letters + string.digits)
"$cfg[\'blowfish_secret\'] = \'\';", "$cfg[\'blowfish_secret\'] = \'{0}\';" for n in range(25)])
.format(blowfish_key)) WOFileUtils.searchreplace(self,
Log.debug(self, 'Setting HOST Server For Mysql to ' '{0}22222/htdocs/db/pma/config.inc.php'
'{0}22222/htdocs/db/pma/config.inc.php file ' .format(WOVariables.wo_webroot),
.format(WOVariables.wo_webroot)) "$cfg[\'blowfish_secret\'] = \'\';", "$cfg[\'blowfish_secret\'] = \'{0}\';"
WOFileUtils.searchreplace(self, .format(blowfish_key))
'{0}22222/htdocs/db/pma/config.inc.php' Log.debug(self, 'Setting HOST Server For Mysql to '
.format(WOVariables.wo_webroot), '{0}22222/htdocs/db/pma/config.inc.php file '
"$cfg[\'Servers\'][$i][\'host\'] = \'localhost\';", "$cfg[\'Servers\'][$i][\'host\'] = \'{0}\';" .format(WOVariables.wo_webroot))
.format(WOVariables.wo_mysql_host)) WOFileUtils.searchreplace(self,
'{0}22222/htdocs/db/pma/config.inc.php'
.format(WOVariables.wo_webroot),
"$cfg[\'Servers\'][$i][\'host\'] = \'localhost\';", "$cfg[\'Servers\'][$i][\'host\'] = \'{0}\';"
.format(WOVariables.wo_mysql_host))
Log.debug(self, 'Setting Privileges of webroot permission to ' Log.debug(self, 'Setting Privileges of webroot permission to '
'{0}22222/htdocs/db/pma file ' '{0}22222/htdocs/db/pma file '
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
@@ -1029,6 +1042,29 @@ class WOStackController(CementBaseController):
WOVariables.wo_php_user, WOVariables.wo_php_user,
WOVariables.wo_php_user, WOVariables.wo_php_user,
recursive=True) recursive=True)
# composer install and phpmyadmin update
if any('/tmp/composer-install' == x[1]
for x in packages):
WOShellExec.cmd_exec(self, "php -q /tmp/composer-install "
"--install-dir=/tmp/")
shutil.copyfile('/tmp/composer.phar',
'/usr/local/bin/composer')
WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775)
WOShellExec.cmd_exec(self, "sudo -u www-data -H composer "
"update --no-dev -d "
"/var/www/22222/htdocs/db/pma/")
# netdata install
if any('/tmp/kickstart.sh' == x[1]
for x in packages):
if not os.path.exists('/etc/netdata'):
WOShellExec.cmd_exec(self, "bash /tmp/kickstart.sh "
"--dont-wait --no-updates")
WOFileUtils.searchreplace(self, "/usr/lib/netdata/conf.d/"
"health_alarm_notify.conf",
'SEND_EMAIL="YES"',
'SEND_EMAIL="NO"')
WOService.restart_service(self, 'netdata')
if any('/tmp/memcached.tar.gz' == x[1] if any('/tmp/memcached.tar.gz' == x[1]
for x in packages): for x in packages):
Log.debug(self, "Extracting memcached.tar.gz to location" Log.debug(self, "Extracting memcached.tar.gz to location"
@@ -1045,7 +1081,6 @@ class WOStackController(CementBaseController):
WOVariables.wo_php_user, WOVariables.wo_php_user,
WOVariables.wo_php_user, WOVariables.wo_php_user,
recursive=True) recursive=True)
if any('/tmp/webgrind.tar.gz' == x[1] if any('/tmp/webgrind.tar.gz' == x[1]
for x in packages): for x in packages):
Log.debug(self, "Extracting file webgrind.tar.gz to " Log.debug(self, "Extracting file webgrind.tar.gz to "
@@ -1058,9 +1093,11 @@ class WOStackController(CementBaseController):
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
os.makedirs('{0}22222/htdocs/php' os.makedirs('{0}22222/htdocs/php'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
shutil.move('/tmp/webgrind-master/', if not os.path.exists('{0}22222/htdocs/php/webgrind'
'{0}22222/htdocs/php/webgrind' .format(WOVariables.wo_webroot)):
.format(WOVariables.wo_webroot)) shutil.move('/tmp/webgrind-master/',
'{0}22222/htdocs/php/webgrind'
.format(WOVariables.wo_webroot))
WOFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" WOFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/"
"config.php" "config.php"
@@ -1096,41 +1133,46 @@ class WOStackController(CementBaseController):
Log.debug(self, "Creating directory") Log.debug(self, "Creating directory")
os.makedirs('{0}22222/htdocs/db/' os.makedirs('{0}22222/htdocs/db/'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
shutil.move('/tmp/Anemometer-master', if not os.path.exists('{0}22222/htdocs/db/anemometer'
'{0}22222/htdocs/db/anemometer' .format(WOVariables.wo_webroot)):
.format(WOVariables.wo_webroot)) shutil.move('/tmp/Anemometer-master',
chars = ''.join(random.sample(string.ascii_letters, 8)) '{0}22222/htdocs/db/anemometer'
try: .format(WOVariables.wo_webroot))
WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db' chars = ''.join(random.sample(string.ascii_letters, 8))
'/anemometer/install.sql' try:
.format(WOVariables.wo_webroot)) WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db'
except CommandExecutionError as e: '/anemometer/install.sql'
raise SiteError("Unable to import Anemometer database") .format(WOVariables.wo_webroot))
except CommandExecutionError as e:
raise SiteError("Unable to import Anemometer database")
WOMysql.execute(self, 'grant select on *.* to \'anemometer\'' WOMysql.execute(self, 'grant select on'
'@\'{0}\' IDENTIFIED' ' *.* to \'anemometer\''
' BY \'{1}\''.format(self.app.config.get('mysql', '@\'{0}\' IDENTIFIED'
'grant-host'), chars)) ' BY \'{1}\''.format(self.app.config.get
Log.debug(self, "grant all on slow-query-log.*" ('mysql', 'grant-host'),
" to anemometer@root_user IDENTIFIED BY password ") chars))
WOMysql.execute(self, 'grant all on slow_query_log.* to' Log.debug(self, "grant all on slow-query-log.*"
'\'anemometer\'@\'{0}\' IDENTIFIED' " to anemometer@root_user"
' BY \'{1}\''.format(self.app.config.get( " IDENTIFIED BY password ")
'mysql', 'grant-host'), WOMysql.execute(self, 'grant all on slow_query_log.* to'
chars), '\'anemometer\'@\'{0}\' IDENTIFIED'
errormsg="cannot grant priviledges", log=False) ' BY \'{1}\''.format(self.app.config.get(
'mysql', 'grant-host'),
chars),
errormsg="cannot grant priviledges", log=False)
# Custom Anemometer configuration # Custom Anemometer configuration
Log.debug(self, "configration Anemometer") Log.debug(self, "configration Anemometer")
data = dict(host=WOVariables.wo_mysql_host, port='3306', data = dict(host=WOVariables.wo_mysql_host, port='3306',
user='anemometer', password=chars) user='anemometer', password=chars)
wo_anemometer = open('{0}22222/htdocs/db/anemometer' wo_anemometer = open('{0}22222/htdocs/db/anemometer'
'/conf/config.inc.php' '/conf/config.inc.php'
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'anemometer.mustache', self.app.render((data), 'anemometer.mustache',
out=wo_anemometer) out=wo_anemometer)
wo_anemometer.close() wo_anemometer.close()
if any('/usr/bin/pt-query-advisor' == x[1] if any('/usr/bin/pt-query-advisor' == x[1]
for x in packages): for x in packages):
@@ -1148,16 +1190,20 @@ class WOStackController(CementBaseController):
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
os.makedirs('{0}22222/htdocs/cache/redis' os.makedirs('{0}22222/htdocs/cache/redis'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
shutil.move('/tmp/phpRedisAdmin-master/', if not os.path.exists('{0}22222/htdocs/cache/'
'{0}22222/htdocs/cache/redis/phpRedisAdmin' 'redis/phpRedisAdmin'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot)):
shutil.move('/tmp/phpRedisAdmin-master/',
'{0}22222/htdocs/cache/redis/phpRedisAdmin'
.format(WOVariables.wo_webroot))
Log.debug(self, 'Extracting file /tmp/predis.tar.gz to ' Log.debug(self, 'Extracting file /tmp/predis.tar.gz to '
'loaction /tmp/') 'loaction /tmp/')
WOExtract.extract(self, '/tmp/predis.tar.gz', '/tmp/') WOExtract.extract(self, '/tmp/predis.tar.gz', '/tmp/')
shutil.move('/tmp/predis-1.0.1/', shutil.move('/tmp/predis-1.0.1/',
'{0}22222/htdocs/cache/redis/phpRedisAdmin/vendor' '{0}22222/htdocs/cache/redis/'
.format(WOVariables.wo_webroot)) 'phpRedisAdmin/vendor'
.format(WOVariables.wo_webroot))
Log.debug(self, 'Setting Privileges of webroot permission to ' Log.debug(self, 'Setting Privileges of webroot permission to '
'{0}22222/htdocs/cache/ file ' '{0}22222/htdocs/cache/ file '
@@ -1178,6 +1224,8 @@ class WOStackController(CementBaseController):
(not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.nginx) and (not self.app.pargs.php) and
(not self.app.pargs.mysql) and (not self.app.pargs.wpcli) and (not self.app.pargs.mysql) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.phpmyadmin) and
(not self.app.pargs.composer) and
(not self.app.pargs.netdata) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and
(not self.app.pargs.redis) and (not self.app.pargs.redis) and
(not self.app.pargs.phpredisadmin) and (not self.app.pargs.phpredisadmin) and
@@ -1201,7 +1249,9 @@ class WOStackController(CementBaseController):
self.app.pargs.mysql = True self.app.pargs.mysql = True
self.app.pargs.adminer = True self.app.pargs.adminer = True
self.app.pargs.phpmyadmin = True self.app.pargs.phpmyadmin = True
self.app.pargs.composer = True
self.app.pargs.utils = True self.app.pargs.utils = True
self.app.pargs.netdata = True
if self.app.pargs.redis: if self.app.pargs.redis:
if not WOAptGet.is_installed(self, 'redis-server'): if not WOAptGet.is_installed(self, 'redis-server'):
@@ -1223,8 +1273,10 @@ class WOStackController(CementBaseController):
apt = ["nginx-plus"] + WOVariables.wo_nginx apt = ["nginx-plus"] + WOVariables.wo_nginx
self.post_pref(apt, packages) self.post_pref(apt, packages)
elif WOAptGet.is_installed(self, 'nginx'): elif WOAptGet.is_installed(self, 'nginx'):
Log.info(self, "WordOps detected an already installed nginx package." Log.info(self, "WordOps detected an already "
"It may or may not have required modules.\n") "installed nginx package."
"It may or may not have "
"required modules.\n")
apt = ["nginx"] + WOVariables.wo_nginx apt = ["nginx"] + WOVariables.wo_nginx
self.post_pref(apt, packages) self.post_pref(apt, packages)
else: else:
@@ -1235,7 +1287,8 @@ class WOStackController(CementBaseController):
Log.debug(self, "Setting apt_packages variable for PHP 7.2") 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.2-fpm')):
if not (WOAptGet.is_installed(self, 'php7.3-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 + WOVariables.wo_php + \
WOVariables.wo_php_extra
else: else:
apt_packages = apt_packages + WOVariables.wo_php apt_packages = apt_packages + WOVariables.wo_php
else: else:
@@ -1247,7 +1300,8 @@ class WOStackController(CementBaseController):
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'):
if not (WOAptGet.is_installed(self, 'php7.2-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 + WOVariables.wo_php + \
WOVariables.wo_php73 + WOVariables.wo_php_extra
else: else:
apt_packages = apt_packages + WOVariables.wo_php73 apt_packages = apt_packages + WOVariables.wo_php73
else: else:
@@ -1286,13 +1340,18 @@ class WOStackController(CementBaseController):
# PHPMYADMIN # PHPMYADMIN
if self.app.pargs.phpmyadmin: if self.app.pargs.phpmyadmin:
Log.debug(self, "Setting packages varible for phpMyAdmin ") Log.debug(self, "Setting packages variable for phpMyAdmin ")
packages = packages + [["https://github.com/phpmyadmin/" packages = packages + [["https://github.com/phpmyadmin/"
"phpmyadmin/archive/STABLE.tar.gz", "phpmyadmin/archive/STABLE.tar.gz",
"/tmp/pma.tar.gz", "phpMyAdmin"]] "/tmp/pma.tar.gz", "phpMyAdmin"]]
# Composer
if self.app.pargs.composer:
Log.debug(self, "Setting packages variable for Composer ")
packages = packages + [["https://getcomposer.org/installer",
"/tmp/composer-install", "Composer"]]
# PHPREDISADMIN # PHPREDISADMIN
if self.app.pargs.phpredisadmin: if self.app.pargs.phpredisadmin:
Log.debug(self, "Setting packages varible for phpRedisAdmin") Log.debug(self, "Setting packages variable for phpRedisAdmin")
packages = packages + [["https://github.com/ErikDubbelboer/" packages = packages + [["https://github.com/ErikDubbelboer/"
"phpRedisAdmin/archive/master.tar.gz", "phpRedisAdmin/archive/master.tar.gz",
"/tmp/pra.tar.gz", "phpRedisAdmin"], "/tmp/pra.tar.gz", "phpRedisAdmin"],
@@ -1302,13 +1361,22 @@ class WOStackController(CementBaseController):
# ADMINER # ADMINER
if self.app.pargs.adminer: if self.app.pargs.adminer:
Log.debug(self, "Setting packages variable for Adminer ") Log.debug(self, "Setting packages variable for Adminer ")
packages = packages + [["https://www.adminer.org/static/download/" packages = packages + [["https://www.adminer.org/static/"
"{0}/adminer-{0}.php" "download/{0}/adminer-{0}.php"
"".format(WOVariables.wo_adminer), "".format(WOVariables.wo_adminer),
"{0}22222/" "{0}22222/"
"htdocs/db/adminer/index.php" "htdocs/db/adminer/index.php"
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
"Adminer"]] "Adminer"]]
# Netdata
if self.app.pargs.netdata:
Log.debug(self, "Setting packages variable for Netdata")
if not os.path.exists('/opt/netdata'):
packages = packages + [['https://my-netdata.io/'
'kickstart.sh',
'/tmp/kickstart.sh',
'Netdata']]
# UTILS # UTILS
if self.app.pargs.utils: if self.app.pargs.utils:
Log.debug(self, "Setting packages variable for utils") Log.debug(self, "Setting packages variable for utils")
@@ -1422,6 +1490,7 @@ class WOStackController(CementBaseController):
(not self.app.pargs.php73) and (not self.app.pargs.mysql) and (not self.app.pargs.php73) and (not self.app.pargs.mysql) and
(not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and
(not self.app.pargs.composer) and (not self.app.pargs.netdata) and
(not self.app.pargs.all) and (not self.app.pargs.redis) and (not self.app.pargs.all) and (not self.app.pargs.redis) and
(not self.app.pargs.phpredisadmin)): (not self.app.pargs.phpredisadmin)):
self.app.pargs.web = True self.app.pargs.web = True
@@ -1441,6 +1510,7 @@ class WOStackController(CementBaseController):
if self.app.pargs.admin: if self.app.pargs.admin:
self.app.pargs.adminer = True self.app.pargs.adminer = True
self.app.pargs.phpmyadmin = True self.app.pargs.phpmyadmin = True
self.app.pargs.composer = True
self.app.pargs.utils = True self.app.pargs.utils = True
# NGINX # NGINX
if self.app.pargs.nginx: if self.app.pargs.nginx:
@@ -1454,7 +1524,8 @@ class WOStackController(CementBaseController):
Log.debug(self, "Removing apt_packages variable of PHP") Log.debug(self, "Removing apt_packages variable of PHP")
if WOAptGet.is_installed(self, 'php7.2-fpm'): if WOAptGet.is_installed(self, 'php7.2-fpm'):
if not WOAptGet.is_installed(self, 'php7.3-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 + WOVariables.wo_php + \
WOVariables.wo_php_extra
else: else:
apt_packages = apt_packages + WOVariables.wo_php apt_packages = apt_packages + WOVariables.wo_php
else: else:
@@ -1465,7 +1536,8 @@ class WOStackController(CementBaseController):
Log.debug(self, "Removing apt_packages variable of PHP 7.3") Log.debug(self, "Removing apt_packages variable of PHP 7.3")
if WOAptGet.is_installed(self, 'php7.3-fpm'): if WOAptGet.is_installed(self, 'php7.3-fpm'):
if not (WOAptGet.is_installed(self, 'php7.2-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 + WOVariables.wo_php73 + \
WOVariables.wo_php_extra
else: else:
apt_packages = apt_packages + WOVariables.wo_php73 apt_packages = apt_packages + WOVariables.wo_php73
else: else:
@@ -1555,6 +1627,7 @@ class WOStackController(CementBaseController):
(not self.app.pargs.php73) and (not self.app.pargs.mysql) and (not self.app.pargs.php73) and (not self.app.pargs.mysql) and
(not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and
(not self.app.pargs.composer) and (not self.app.pargs.netdata) and
(not self.app.pargs.all) and (not self.app.pargs.redis) and (not self.app.pargs.all) and (not self.app.pargs.redis) and
(not self.app.pargs.phpredisadmin)): (not self.app.pargs.phpredisadmin)):
self.app.pargs.web = True self.app.pargs.web = True