Add upgrade script for phpmyadmin

This commit is contained in:
VirtuBox
2019-07-14 22:50:34 +02:00
parent 2eb05e7b82
commit 37bd353fa4
8 changed files with 2665 additions and 2629 deletions

View File

@@ -79,7 +79,7 @@ _wo_complete()
;; ;;
"upgrade" ) "upgrade" )
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "--web --nginx --php --php73 --mysql --all --netdata --no-prompt --wpcli" \ -W "--web --nginx --php --php73 --mysql --all --netdata --composer --phpmyadmin --no-prompt --wpcli" \
-- $cur) ) -- $cur) )
;; ;;
"start" | "stop" | "reload" | "restart" | "status") "start" | "stop" | "reload" | "restart" | "status")
@@ -310,7 +310,7 @@ _wo_complete()
"--all") "--all")
if [ ${COMP_WORDS[1]} == "clean" ]; then if [ ${COMP_WORDS[1]} == "clean" ]; then
retlist="--memcache --opcache --fastcgi --redis" retlist="--opcache --fastcgi --redis"
elif [ ${COMP_WORDS[2]} == "delete" ]; then elif [ ${COMP_WORDS[2]} == "delete" ]; then
retlist="--db --files --force" retlist="--db --files --force"
elif [ ${COMP_WORDS[2]} == "update" ]; then elif [ ${COMP_WORDS[2]} == "update" ]; then

628
docs/wo.8
View File

@@ -1,314 +1,314 @@
.TH wo 8 "WordOps (wo) version: 3.3.8" "Sep 10,2015" "WordOps" .TH wo 8 "WordOps (wo) version: 3.3.8" "Sep 10,2015" "WordOps"
.SH NAME .SH NAME
.B WordOps (wo) .B WordOps (wo)
\- Manage Nginx Based Websites. \- Manage Nginx Based Websites.
.SH SYNOPSIS .SH SYNOPSIS
wo [ --version | --help | info | stack | site | debug | update | clean | import_slow_log | log | secure | sync | maintenance] wo [ --version | --help | info | stack | site | debug | update | clean | import_slow_log | log | secure | sync | maintenance ]
.TP .TP
wo stack [ install | remove | purge | migrate | upgrade] [ --web | --all | --nginx | --php | --php73 | --mysql | --admin | --adminer | --redis | --phpmyadmin | --phpredisadmin | --wpcli | --utils | --dashboard | --netdata ] wo stack [ install | remove | purge | migrate | upgrade] [ --web | --all | --nginx | --php | --php73 | --mysql | --admin | --adminer | --redis | --phpmyadmin | --phpredisadmin | --wpcli | --utils | --dashboard | --netdata ]
.TP .TP
wo stack [ status | start | stop | reload | restart ] [--all | --nginx | --php | --php73 |--mysql | --web | --memcached | --redis] wo stack [ status | start | stop | reload | restart ] [--all | --nginx | --php | --php73 |--mysql | --web | --redis]
.TP .TP
wo site [ list | info | show | enable | disable | edit | cd | show ] [ example.com ] wo site [ list | info | show | enable | disable | edit | cd | show ] [ example.com ]
.TP .TP
wo site create example.com [ --html | --php | --php73 | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --wpfc | --wpredis | --letsencrypt/-le/--letsencrypt=subdomain]] wo site create example.com [ --html | --php | --php73 | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --wpfc | --wpredis | --letsencrypt/--le/--letsencrypt=subdomain/wildcard]]
.TP .TP
wo site update example.com [ --php | --php73 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --wpfc | --wpredis ] [--password] [--letsencrypt=on/off/subdomain/renew]] wo site update example.com [ --php | --php73 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --wpfc | --wpredis ] [--password] [--le/--letsencrypt=on/off/subdomain/renew]]
.TP .TP
wo site delete example.com [--db | --files | --all | --no-prompt | --force/-f ] wo site delete example.com [--db | --files | --all | --no-prompt | --force/-f ]
.TP .TP
wo debug [ -i | --all=on/off |--nginx=on/off | --rewrite=on/off | --php=on/off | --fpm=on/off | --mysql=on/off ] wo debug [ -i | --all=on/off |--nginx=on/off | --rewrite=on/off | --php=on/off | --fpm=on/off | --mysql=on/off ]
.TP .TP
wo debug example.com [ -i | --all=on/off | --nginx=on/off | --rewrite=on/off | --wp=on/off ] wo debug example.com [ -i | --all=on/off | --nginx=on/off | --rewrite=on/off | --wp=on/off ]
.TP .TP
wo secure [ --auth | --port | --ip ] wo secure [ --auth | --port | --ip ]
.SH DESCRIPTION .SH DESCRIPTION
WordOps aka wo is the opensource project developed with the purpose to automate web-server configuration. WordOps aka wo is the opensource project developed with the purpose to automate web-server configuration.
.br .br
WordOps is the collection of python script that provides automation for the web-server WordOps is the collection of python script that provides automation for the web-server
.br .br
installation, site creation, services debugging & monitoring. installation, site creation, services debugging & monitoring.
.SH OPTIONS .SH OPTIONS
.TP .TP
.B --version .B --version
.br .br
Display WordOps (wo) version information. Display WordOps (wo) version information.
.TP .TP
.B info .B info
.br .br
wo info - Display Nginx, PHP, MySQL and wo common location information wo info - Display Nginx, PHP, MySQL and wo common location information
.br .br
wo site info - Diplay given website details like enable, disable. weboot and log files. wo site info - Diplay given website details like enable, disable. weboot and log files.
.TP .TP
.B --help .B --help
.br .br
Display WordOps (wo) help. Display WordOps (wo) help.
.TP .TP
.B stack .B stack
.TP .TP
.B install [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils ] .B install [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils | --netdata | --dashboard ]
.br .br
Install Nginx PHP5 MySQL Postfix stack Packages if not used with Install Nginx PHP5 MySQL Postfix stack Packages if not used with
.br .br
any options.Installs specific package if used with option. any options.Installs specific package if used with option.
.TP .TP
.B remove [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils ] .B remove [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils | --netdata | --dashboard ]
.br .br
Remove Nginx PHP5 MySQL Postfix stack Packages if not used with Remove Nginx PHP5 MySQL Postfix stack Packages if not used with
.br .br
any options. Remove specific package if used with option. any options. Remove specific package if used with option.
.TP .TP
.B purge [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils ] .B purge [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils | --netdata | --dashboard ]
.br .br
Purge Nginx PHP5 MySQL Postfix stack Packages if not used with any Purge Nginx PHP5 MySQL Postfix stack Packages if not used with any
.br .br
options.Purge specific package if used with option. options.Purge specific package if used with option.
.TP .TP
.B status .B status
.br .br
Display status of NGINX, PHP7.2-FPM, MySQL, Redis-Server services. Display status of NGINX, PHP7.2-FPM, MySQL, Redis-Server services.
.TP .TP
.B start .B start
.br .br
Start services NGINX, PHP7.2-FPM, MySQL, Redis-Server. Start services NGINX, PHP7.2-FPM, MySQL, Redis-Server.
.TP .TP
.B stop .B stop
.br .br
Stop services NGINX, PHP7.2-FPM, MySQL, Redis-Server. Stop services NGINX, PHP7.2-FPM, MySQL, Redis-Server.
.TP .TP
.B reload .B reload
.br .br
Reload services NGINX, PHP7.2-FPM, MySQL, Redis-Server. Reload services NGINX, PHP7.2-FPM, MySQL, Redis-Server.
.TP .TP
.B restart .B restart
.br .br
Restart services NGINX, PHP7.2-FPM, MySQL, Redis-Server. Restart services NGINX, PHP7.2-FPM, MySQL, Redis-Server.
.TP .TP
.B site .B site
.br .br
.TP .TP
.B cd [ example.com ] .B cd [ example.com ]
.br .br
Change directory to webroot of specified site in subshell. Change directory to webroot of specified site in subshell.
.TP .TP
.B log [ example.com ] .B log [ example.com ]
.br .br
monitor access and error logs for site specified. monitor access and error logs for site specified.
.TP .TP
.B list [ --enabled | --disabled ] .B list [ --enabled | --disabled ]
.br .br
Lists all available sites from /etc/nginx/sites-enabled/ Lists all available sites from /etc/nginx/sites-enabled/
.br .br
by default & enable argument. Display sites list from by default & enable argument. Display sites list from
.br .br
/etc/nginx/sites-available/ if used with available option. /etc/nginx/sites-available/ if used with available option.
.TP .TP
.B info [ example.com ] .B info [ example.com ]
.br .br
prints information about site such as access log, error log prints information about site such as access log, error log
.br .br
location and type of site. location and type of site.
.TP .TP
.B show [ example.com ] .B show [ example.com ]
.br .br
Display NGINX configuration of site. Display NGINX configuration of site.
.TP .TP
.B enable [ example.com ] .B enable [ example.com ]
.br .br
Enable site by creating softlink with site file in Enable site by creating softlink with site file in
.br .br
/etc/nginx/sites-available to /etc/nginx/sites-enabled/. /etc/nginx/sites-available to /etc/nginx/sites-enabled/.
.TP .TP
.B disable [ example.com ] .B disable [ example.com ]
.br .br
Disable site by Destroying softlink with site file in Disable site by Destroying softlink with site file in
.br .br
/etc/nginx/sites-available to /etc/nginx/sites-enabled/. /etc/nginx/sites-available to /etc/nginx/sites-enabled/.
.TP .TP
.B edit [ example.com ] .B edit [ example.com ]
.br .br
Edit NGINX configuration of site. Edit NGINX configuration of site.
.TP .TP
.B create [ example.com ] [ --html | --php | --php73 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --wpfc | --wpredis ]] .B create [ example.com ] [ --html | --php | --php73 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --wpfc | --wpredis ]]
.br .br
Create new site according to given options. If no options provided Create new site according to given options. If no options provided
.br .br
create static site with html only. create static site with html only.
.TP .TP
.B update [ example.com ] [ --html | --php | --php73 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [ --wpsc | --wpfc | --wpredis ] [--password]] .B update [ example.com ] [ --html | --php | --php73 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [ --wpsc | --wpfc | --wpredis ] [--password]]
.br .br
Update site configuration according to specified options. Update site configuration according to specified options.
.TP .TP
.B delete [ example.com ] [--no-prompt ] [--force/-f] [ --db | --files | --all ] .B delete [ example.com ] [--no-prompt ] [--force/-f] [ --db | --files | --all ]
.br .br
Delete site i.e webroot, database, ad configuration permanently. Delete site i.e webroot, database, ad configuration permanently.
.TP .TP
.B debug [ -i | --nginx=on/off | --php=on/off | --php73=on/off | --mysql=on/off | --rewrite=on/off | --fpm=on/off | --fpm7=on/off ] .B debug [ -i | --nginx=on/off | --php=on/off | --php73=on/off | --mysql=on/off | --rewrite=on/off | --fpm=on/off | --fpm7=on/off ]
.br .br
Starts server level debugging. If this is used without arguments it will start debugging Starts server level debugging. If this is used without arguments it will start debugging
.br .br
all services.Else it will debug only service provided with argument.This will Stop all services.Else it will debug only service provided with argument.This will Stop
.br .br
Debugging if used with --all=off argument. Debugging if used with --all=off argument.
.TP .TP
.B debug example.com [ -i | --nginx=on/off | --rewrite=on/off | --wp=on/off | --all=on/off ] .B debug example.com [ -i | --nginx=on/off | --rewrite=on/off | --wp=on/off | --all=on/off ]
.br .br
Starts site level debugging. If this is used without arguments it will start debugging all Starts site level debugging. If this is used without arguments it will start debugging all
.br .br
services.Else it will debug only service provided with argument.This will Stop Debugging services.Else it will debug only service provided with argument.This will Stop Debugging
.br .br
if used with --all=off argument. if used with --all=off argument.
.TP .TP
.B secure [ --auth | --port | --ip ] .B secure [ --auth | --port | --ip ]
.br .br
Update security settings. Update security settings.
.TP .TP
.B clean [ --fastcgi | --opcache | --memcached | --redis | --all ] .B clean [ --fastcgi | --opcache | --redis | --all ]
.br .br
Clean NGINX fastCGI cache, Opcache, memcached, Redis cache. Clean NGINX fastCGI cache, Opcache, memcached, Redis cache.
.br .br
Clean NGINX fastCGI cache if no option specified. Clean NGINX fastCGI cache if no option specified.
.SH ARGUMENTS .SH ARGUMENTS
.TP .TP
.B -i .B -i
.br .br
setup intractive mode while used with debug. setup intractive mode while used with debug.
.TP .TP
.B --nginx=on/off .B --nginx=on/off
.br .br
used with wo debug command. used to start or stop nginx debugging. used with wo debug command. used to start or stop nginx debugging.
.TP .TP
.B --php=on/off .B --php=on/off
.br .br
used with wo debug command. used to start or stop php debugging. used with wo debug command. used to start or stop php debugging.
.TP .TP
.B --php73=on/off .B --php73=on/off
.br .br
used with wo debug command. used to start or stop php72 debugging. used with wo debug command. used to start or stop php72 debugging.
.TP .TP
.B --mysql=on/off .B --mysql=on/off
.br .br
used with wo debug command. used to start or stop mysql debugging. used with wo debug command. used to start or stop mysql debugging.
.TP .TP
.B --rewrite=on/off .B --rewrite=on/off
.br .br
used with wo debug command. used to start or stop nginx rewrite rules debugging. used with wo debug command. used to start or stop nginx rewrite rules debugging.
.TP .TP
.B --fpm=on/off .B --fpm=on/off
.br .br
used with wo debug command. used to start or stop fpm debugging. used with wo debug command. used to start or stop fpm debugging.
.TP .TP
.B --wp=on/off .B --wp=on/off
.br .br
used with wo debug command. used to start or stop wordpress site debugging. used with wo debug command. used to start or stop wordpress site debugging.
.TP .TP
.B --all=on/off .B --all=on/off
.br .br
used with wo debug command. used to stop debugging. used with wo debug command. used to stop debugging.
.TP .TP
.B --all=off .B --all=off
.br .br
used with wo debug command. used to stop debugging. used with wo debug command. used to stop debugging.
.TP .TP
.B --html .B --html
.br .br
Create a HTML website. Create a HTML website.
.TP .TP
.B --php .B --php
.br .br
Create a PHP website. Create a PHP website.
.TP .TP
.B --mysql .B --mysql
.br .br
Create a PHP+MySQL website. Create a PHP+MySQL website.
.TP .TP
.B --wp .B --wp
.br .br
Create a WordPress Website. Create a WordPress Website.
.TP .TP
.B --wpsubdir .B --wpsubdir
.br .br
Create a Wordpress Multisite with Sub Directories Setup. Create a Wordpress Multisite with Sub Directories Setup.
.TP .TP
.B --wpsubdomain .B --wpsubdomain
.br .br
Create a Wordpress Multisite with Sub Domains Setup. Create a Wordpress Multisite with Sub Domains Setup.
.br .br
.TP .TP
.B --db .B --db
.br .br
Delete website database. Delete website database.
.br .br
.TP .TP
.B --files .B --files
.br .br
Delete website webroot. Delete website webroot.
.br .br
.TP .TP
.B --no-prompt .B --no-prompt
.br .br
Does not prompt for confirmation when delete command used. Does not prompt for confirmation when delete command used.
.br .br
.TP .TP
.B --force/-f .B --force/-f
.br .br
Delete website webroot and database forcefully.Remove nginx configuration for site. Delete website webroot and database forcefully.Remove nginx configuration for site.
.br .br
.TP .TP
.B --auth .B --auth
.br .br
used with wo secure command. Update credential of HTTP authentication used with wo secure command. Update credential of HTTP authentication
.TP .TP
.B --port .B --port
.br .br
used with wo secure command. Change WordOps admin port 22222. used with wo secure command. Change WordOps admin port 22222.
.TP .TP
.B --ip .B --ip
.br .br
used with wo secure command. Update whitelist IP address used with wo secure command. Update whitelist IP address
.SH WORDPRESS CACHING OPTIONS .SH WORDPRESS CACHING OPTIONS
.TP .TP
.B --wpsc .B --wpsc
.br .br
Install and activate Nginx-helper and WP Super Cache plugin. Install and activate Nginx-helper and WP Super Cache plugin.
.TP .TP
.B --wpfc .B --wpfc
.br .br
Install and activate Nginx-helper plugin with Install and activate Nginx-helper plugin with
.br .br
Nginx FastCGI cache. Nginx FastCGI cache.
.TP .TP
.B --wpredis .B --wpredis
.br .br
Install, activate, configure Nginx-helper and Redis Object Cache Plugin, Configure NGINX for Redis Page Caching. Install, activate, configure Nginx-helper and Redis Object Cache Plugin, Configure NGINX for Redis Page Caching.
.SH FILES .SH FILES
.br .br
/etc/wo/wo.conf /etc/wo/wo.conf
.SH BUGS .SH BUGS
Report bugs at <http://github.com/WordOps/WordOps/issues/> Report bugs at <http://github.com/WordOps/WordOps/issues/>
.SH AUTHOR .SH AUTHOR
.br .br
.B rtCamp Team .B rtCamp Team
.I \<admin@rtcamp.com\> .I \<admin@rtcamp.com\>
.br .br
.B Mitesh Shah .B Mitesh Shah
.I \<Mitesh.Shah@rtcamp.com\> .I \<Mitesh.Shah@rtcamp.com\>
.br .br
.B Manish .B Manish
.I \<Manish.Songirkar@rtcamp.com\> .I \<Manish.Songirkar@rtcamp.com\>
.br .br
.B Gaurav .B Gaurav
.I \<Gaurav.Astikar@rtcamp.com\> .I \<Gaurav.Astikar@rtcamp.com\>
.br .br
.B Harshad .B Harshad
.I \<harshad.yeola@rtcamp.com> .I \<harshad.yeola@rtcamp.com>
.br .br
.B Prabuddha .B Prabuddha
.I \<prabuddha.chakraborty@rtcamp.com\> .I \<prabuddha.chakraborty@rtcamp.com\>
.br .br
.B Shital .B Shital
.I \<shital.patil@rtcamp.com\> .I \<shital.patil@rtcamp.com\>
.br .br
.B Rajdeep Sharma .B Rajdeep Sharma
.I \<rajdeep.sharma@rtcamp.com\> .I \<rajdeep.sharma@rtcamp.com\>
.br .br

View File

@@ -1,293 +1,293 @@
"""WOInfo Plugin for WordOps""" """WOInfo Plugin for WordOps"""
from cement.core.controller import CementBaseController, expose from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook from cement.core import handler, hook
from wo.core.variables import WOVariables from wo.core.variables import WOVariables
from pynginxconfig import NginxConfig from pynginxconfig import NginxConfig
from wo.core.aptget import WOAptGet from wo.core.aptget import WOAptGet
from wo.core.shellexec import WOShellExec from wo.core.shellexec import WOShellExec
from wo.core.logging import Log from wo.core.logging import Log
import os import os
import configparser import configparser
def wo_info_hook(app): def wo_info_hook(app):
pass pass
class WOInfoController(CementBaseController): class WOInfoController(CementBaseController):
class Meta: class Meta:
label = 'info' label = 'info'
stacked_on = 'base' stacked_on = 'base'
stacked_type = 'nested' stacked_type = 'nested'
description = ('Display configuration information related to Nginx,' description = ('Display configuration information related to Nginx,'
' PHP and MySQL') ' PHP and MySQL')
arguments = [ arguments = [
(['--mysql'], (['--mysql'],
dict(help='Get MySQL configuration information', dict(help='Get MySQL configuration information',
action='store_true')), action='store_true')),
(['--php'], (['--php'],
dict(help='Get PHP 7.2 configuration information', dict(help='Get PHP 7.2 configuration information',
action='store_true')), action='store_true')),
(['--php73'], (['--php73'],
dict(help='Get PHP 7.3 configuration information', dict(help='Get PHP 7.3 configuration information',
action='store_true')), action='store_true')),
(['--nginx'], (['--nginx'],
dict(help='Get Nginx configuration information', dict(help='Get Nginx configuration information',
action='store_true')), action='store_true')),
] ]
usage = "wo info [options]" usage = "wo info [options]"
@expose(hide=True) @expose(hide=True)
def info_nginx(self): def info_nginx(self):
"""Display Nginx information""" """Display Nginx information"""
version = os.popen("/usr/sbin/nginx -v 2>&1 | " version = os.popen("/usr/sbin/nginx -v 2>&1 | "
"awk -F '/' '{print $2}' | " "awk -F '/' '{print $2}' | "
"awk -F ' ' '{print $1}' | tr '\n' ' '").read() "awk -F ' ' '{print $1}' | tr '\n' ' '").read()
allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | " allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | "
"cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' '").read() "cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' '").read()
nc = NginxConfig() nc = NginxConfig()
nc.loadf('/etc/nginx/nginx.conf') nc.loadf('/etc/nginx/nginx.conf')
user = nc.get('user')[1] user = nc.get('user')[1]
worker_processes = nc.get('worker_processes')[1] worker_processes = nc.get('worker_processes')[1]
worker_connections = nc.get([('events',), 'worker_connections'])[1] worker_connections = nc.get([('events',), 'worker_connections'])[1]
keepalive_timeout = nc.get([('http',), 'keepalive_timeout'])[1] keepalive_timeout = nc.get([('http',), 'keepalive_timeout'])[1]
fastcgi_read_timeout = nc.get([('http',), fastcgi_read_timeout = nc.get([('http',),
'fastcgi_read_timeout'])[1] 'fastcgi_read_timeout'])[1]
client_max_body_size = nc.get([('http',), client_max_body_size = nc.get([('http',),
'client_max_body_size'])[1] 'client_max_body_size'])[1]
data = dict(version=version, allow=allow, user=user, data = dict(version=version, allow=allow, user=user,
worker_processes=worker_processes, worker_processes=worker_processes,
keepalive_timeout=keepalive_timeout, keepalive_timeout=keepalive_timeout,
worker_connections=worker_connections, worker_connections=worker_connections,
fastcgi_read_timeout=fastcgi_read_timeout, fastcgi_read_timeout=fastcgi_read_timeout,
client_max_body_size=client_max_body_size) client_max_body_size=client_max_body_size)
self.app.render((data), 'info_nginx.mustache') self.app.render((data), 'info_nginx.mustache')
@expose(hide=True) @expose(hide=True)
def info_php(self): def info_php(self):
"""Display PHP information""" """Display PHP information"""
version = os.popen("/usr/bin/php7.2 -v 2>/dev/null | " version = os.popen("/usr/bin/php7.2 -v 2>/dev/null | "
"head -n1 | cut -d' ' -f2 |" "head -n1 | cut -d' ' -f2 |"
" cut -d'+' -f1 | tr -d '\n'").read " cut -d'+' -f1 | tr -d '\n'").read
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('/etc/{0}/fpm/php.ini'.format("php/7.2")) config.read('/etc/{0}/fpm/php.ini'.format("php/7.2"))
expose_php = config['PHP']['expose_php'] expose_php = config['PHP']['expose_php']
memory_limit = config['PHP']['memory_limit'] memory_limit = config['PHP']['memory_limit']
post_max_size = config['PHP']['post_max_size'] post_max_size = config['PHP']['post_max_size']
upload_max_filesize = config['PHP']['upload_max_filesize'] upload_max_filesize = config['PHP']['upload_max_filesize']
max_execution_time = config['PHP']['max_execution_time'] max_execution_time = config['PHP']['max_execution_time']
config.read('/etc/{0}/fpm/pool.d/www.conf'.format("php/7.2")) config.read('/etc/{0}/fpm/pool.d/www.conf'.format("php/7.2"))
www_listen = config['www']['listen'] www_listen = config['www']['listen']
www_ping_path = config['www']['ping.path'] www_ping_path = config['www']['ping.path']
www_pm_status_path = config['www']['pm.status_path'] www_pm_status_path = config['www']['pm.status_path']
www_pm = config['www']['pm'] www_pm = config['www']['pm']
www_pm_max_requests = config['www']['pm.max_requests'] www_pm_max_requests = config['www']['pm.max_requests']
www_pm_max_children = config['www']['pm.max_children'] www_pm_max_children = config['www']['pm.max_children']
www_pm_start_servers = config['www']['pm.start_servers'] www_pm_start_servers = config['www']['pm.start_servers']
www_pm_min_spare_servers = config['www']['pm.min_spare_servers'] www_pm_min_spare_servers = config['www']['pm.min_spare_servers']
www_pm_max_spare_servers = config['www']['pm.max_spare_servers'] www_pm_max_spare_servers = config['www']['pm.max_spare_servers']
www_request_terminate_time = (config['www'] www_request_terminate_time = (config['www']
['request_terminate_timeout']) ['request_terminate_timeout'])
try: try:
www_xdebug = (config['www']['php_admin_flag[xdebug.profiler_enable' www_xdebug = (config['www']['php_admin_flag[xdebug.profiler_enable'
'_trigger]']) '_trigger]'])
except Exception as e: except Exception as e:
www_xdebug = 'off' www_xdebug = 'off'
config.read('/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2")) config.read('/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2"))
debug_listen = config['debug']['listen'] debug_listen = config['debug']['listen']
debug_ping_path = config['debug']['ping.path'] debug_ping_path = config['debug']['ping.path']
debug_pm_status_path = config['debug']['pm.status_path'] debug_pm_status_path = config['debug']['pm.status_path']
debug_pm = config['debug']['pm'] debug_pm = config['debug']['pm']
debug_pm_max_requests = config['debug']['pm.max_requests'] debug_pm_max_requests = config['debug']['pm.max_requests']
debug_pm_max_children = config['debug']['pm.max_children'] debug_pm_max_children = config['debug']['pm.max_children']
debug_pm_start_servers = config['debug']['pm.start_servers'] debug_pm_start_servers = config['debug']['pm.start_servers']
debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers'] debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers']
debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers'] debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers']
debug_request_terminate = (config['debug'] debug_request_terminate = (config['debug']
['request_terminate_timeout']) ['request_terminate_timeout'])
try: try:
debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_' debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_'
'enable_trigger]']) 'enable_trigger]'])
except Exception as e: except Exception as e:
debug_xdebug = 'off' debug_xdebug = 'off'
data = dict(version=version, expose_php=expose_php, data = dict(version=version, expose_php=expose_php,
memory_limit=memory_limit, post_max_size=post_max_size, memory_limit=memory_limit, post_max_size=post_max_size,
upload_max_filesize=upload_max_filesize, upload_max_filesize=upload_max_filesize,
max_execution_time=max_execution_time, max_execution_time=max_execution_time,
www_listen=www_listen, www_ping_path=www_ping_path, www_listen=www_listen, www_ping_path=www_ping_path,
www_pm_status_path=www_pm_status_path, www_pm=www_pm, www_pm_status_path=www_pm_status_path, www_pm=www_pm,
www_pm_max_requests=www_pm_max_requests, www_pm_max_requests=www_pm_max_requests,
www_pm_max_children=www_pm_max_children, www_pm_max_children=www_pm_max_children,
www_pm_start_servers=www_pm_start_servers, www_pm_start_servers=www_pm_start_servers,
www_pm_min_spare_servers=www_pm_min_spare_servers, www_pm_min_spare_servers=www_pm_min_spare_servers,
www_pm_max_spare_servers=www_pm_max_spare_servers, www_pm_max_spare_servers=www_pm_max_spare_servers,
www_request_terminate_timeout=www_request_terminate_time, www_request_terminate_timeout=www_request_terminate_time,
www_xdebug_profiler_enable_trigger=www_xdebug, www_xdebug_profiler_enable_trigger=www_xdebug,
debug_listen=debug_listen, debug_ping_path=debug_ping_path, debug_listen=debug_listen, debug_ping_path=debug_ping_path,
debug_pm_status_path=debug_pm_status_path, debug_pm_status_path=debug_pm_status_path,
debug_pm=debug_pm, debug_pm=debug_pm,
debug_pm_max_requests=debug_pm_max_requests, debug_pm_max_requests=debug_pm_max_requests,
debug_pm_max_children=debug_pm_max_children, debug_pm_max_children=debug_pm_max_children,
debug_pm_start_servers=debug_pm_start_servers, debug_pm_start_servers=debug_pm_start_servers,
debug_pm_min_spare_servers=debug_pm_min_spare_servers, debug_pm_min_spare_servers=debug_pm_min_spare_servers,
debug_pm_max_spare_servers=debug_pm_max_spare_servers, debug_pm_max_spare_servers=debug_pm_max_spare_servers,
debug_request_terminate_timeout=debug_request_terminate, debug_request_terminate_timeout=debug_request_terminate,
debug_xdebug_profiler_enable_trigger=debug_xdebug) debug_xdebug_profiler_enable_trigger=debug_xdebug)
self.app.render((data), 'info_php.mustache') self.app.render((data), 'info_php.mustache')
@expose(hide=True) @expose(hide=True)
def info_php73(self): def info_php73(self):
"""Display PHP information""" """Display PHP information"""
version = os.popen("/usr/bin/php7.3 -v 2>/dev/null | " version = os.popen("/usr/bin/php7.3 -v 2>/dev/null | "
"head -n1 | cut -d' ' -f2 |" "head -n1 | cut -d' ' -f2 |"
" cut -d'+' -f1 | tr -d '\n'").read " cut -d'+' -f1 | tr -d '\n'").read
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('/etc/php/7.3/fpm/php.ini') config.read('/etc/php/7.3/fpm/php.ini')
expose_php = config['PHP']['expose_php'] expose_php = config['PHP']['expose_php']
memory_limit = config['PHP']['memory_limit'] memory_limit = config['PHP']['memory_limit']
post_max_size = config['PHP']['post_max_size'] post_max_size = config['PHP']['post_max_size']
upload_max_filesize = config['PHP']['upload_max_filesize'] upload_max_filesize = config['PHP']['upload_max_filesize']
max_execution_time = config['PHP']['max_execution_time'] max_execution_time = config['PHP']['max_execution_time']
config.read('/etc/php/7.3/fpm/pool.d/www.conf') config.read('/etc/php/7.3/fpm/pool.d/www.conf')
www_listen = config['www']['listen'] www_listen = config['www']['listen']
www_ping_path = config['www']['ping.path'] www_ping_path = config['www']['ping.path']
www_pm_status_path = config['www']['pm.status_path'] www_pm_status_path = config['www']['pm.status_path']
www_pm = config['www']['pm'] www_pm = config['www']['pm']
www_pm_max_requests = config['www']['pm.max_requests'] www_pm_max_requests = config['www']['pm.max_requests']
www_pm_max_children = config['www']['pm.max_children'] www_pm_max_children = config['www']['pm.max_children']
www_pm_start_servers = config['www']['pm.start_servers'] www_pm_start_servers = config['www']['pm.start_servers']
www_pm_min_spare_servers = config['www']['pm.min_spare_servers'] www_pm_min_spare_servers = config['www']['pm.min_spare_servers']
www_pm_max_spare_servers = config['www']['pm.max_spare_servers'] www_pm_max_spare_servers = config['www']['pm.max_spare_servers']
www_request_terminate_time = (config['www'] www_request_terminate_time = (config['www']
['request_terminate_timeout']) ['request_terminate_timeout'])
try: try:
www_xdebug = (config['www']['php_admin_flag[xdebug.profiler_enable' www_xdebug = (config['www']['php_admin_flag[xdebug.profiler_enable'
'_trigger]']) '_trigger]'])
except Exception as e: except Exception as e:
www_xdebug = 'off' www_xdebug = 'off'
config.read('/etc/php/7.3/fpm/pool.d/debug.conf') config.read('/etc/php/7.3/fpm/pool.d/debug.conf')
debug_listen = config['debug']['listen'] debug_listen = config['debug']['listen']
debug_ping_path = config['debug']['ping.path'] debug_ping_path = config['debug']['ping.path']
debug_pm_status_path = config['debug']['pm.status_path'] debug_pm_status_path = config['debug']['pm.status_path']
debug_pm = config['debug']['pm'] debug_pm = config['debug']['pm']
debug_pm_max_requests = config['debug']['pm.max_requests'] debug_pm_max_requests = config['debug']['pm.max_requests']
debug_pm_max_children = config['debug']['pm.max_children'] debug_pm_max_children = config['debug']['pm.max_children']
debug_pm_start_servers = config['debug']['pm.start_servers'] debug_pm_start_servers = config['debug']['pm.start_servers']
debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers'] debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers']
debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers'] debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers']
debug_request_terminate = (config['debug'] debug_request_terminate = (config['debug']
['request_terminate_timeout']) ['request_terminate_timeout'])
try: try:
debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_' debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_'
'enable_trigger]']) 'enable_trigger]'])
except Exception as e: except Exception as e:
debug_xdebug = 'off' debug_xdebug = 'off'
data = dict(version=version, expose_php=expose_php, data = dict(version=version, expose_php=expose_php,
memory_limit=memory_limit, post_max_size=post_max_size, memory_limit=memory_limit, post_max_size=post_max_size,
upload_max_filesize=upload_max_filesize, upload_max_filesize=upload_max_filesize,
max_execution_time=max_execution_time, max_execution_time=max_execution_time,
www_listen=www_listen, www_ping_path=www_ping_path, www_listen=www_listen, www_ping_path=www_ping_path,
www_pm_status_path=www_pm_status_path, www_pm=www_pm, www_pm_status_path=www_pm_status_path, www_pm=www_pm,
www_pm_max_requests=www_pm_max_requests, www_pm_max_requests=www_pm_max_requests,
www_pm_max_children=www_pm_max_children, www_pm_max_children=www_pm_max_children,
www_pm_start_servers=www_pm_start_servers, www_pm_start_servers=www_pm_start_servers,
www_pm_min_spare_servers=www_pm_min_spare_servers, www_pm_min_spare_servers=www_pm_min_spare_servers,
www_pm_max_spare_servers=www_pm_max_spare_servers, www_pm_max_spare_servers=www_pm_max_spare_servers,
www_request_terminate_timeout=www_request_terminate_time, www_request_terminate_timeout=www_request_terminate_time,
www_xdebug_profiler_enable_trigger=www_xdebug, www_xdebug_profiler_enable_trigger=www_xdebug,
debug_listen=debug_listen, debug_ping_path=debug_ping_path, debug_listen=debug_listen, debug_ping_path=debug_ping_path,
debug_pm_status_path=debug_pm_status_path, debug_pm_status_path=debug_pm_status_path,
debug_pm=debug_pm, debug_pm=debug_pm,
debug_pm_max_requests=debug_pm_max_requests, debug_pm_max_requests=debug_pm_max_requests,
debug_pm_max_children=debug_pm_max_children, debug_pm_max_children=debug_pm_max_children,
debug_pm_start_servers=debug_pm_start_servers, debug_pm_start_servers=debug_pm_start_servers,
debug_pm_min_spare_servers=debug_pm_min_spare_servers, debug_pm_min_spare_servers=debug_pm_min_spare_servers,
debug_pm_max_spare_servers=debug_pm_max_spare_servers, debug_pm_max_spare_servers=debug_pm_max_spare_servers,
debug_request_terminate_timeout=debug_request_terminate, debug_request_terminate_timeout=debug_request_terminate,
debug_xdebug_profiler_enable_trigger=debug_xdebug) debug_xdebug_profiler_enable_trigger=debug_xdebug)
self.app.render((data), 'info_php.mustache') self.app.render((data), 'info_php.mustache')
@expose(hide=True) @expose(hide=True)
def info_mysql(self): def info_mysql(self):
"""Display MySQL information""" """Display MySQL information"""
version = os.popen("/usr/bin/mysql -V | awk '{print($5)}' | " version = os.popen("/usr/bin/mysql -V | awk '{print($5)}' | "
"cut -d ',' " "cut -d ',' "
"-f1 | tr -d '\n'").read() "-f1 | tr -d '\n'").read()
host = "localhost" host = "localhost"
port = os.popen("/usr/bin/mysql -e \"show variables\" | " port = os.popen("/usr/bin/mysql -e \"show variables\" | "
"grep ^port | awk " "grep ^port | awk "
"'{print($2)}' | tr -d '\n'").read() "'{print($2)}' | tr -d '\n'").read()
wait_timeout = os.popen("/usr/bin/mysql -e \"show variables\" | grep " wait_timeout = os.popen("/usr/bin/mysql -e \"show variables\" | grep "
"^wait_timeout | awk '{print($2)}' | " "^wait_timeout | awk '{print($2)}' | "
"tr -d '\n'").read() "tr -d '\n'").read()
interactive_timeout = os.popen("/usr/bin/mysql -e " interactive_timeout = os.popen("/usr/bin/mysql -e "
"\"show variables\" | grep " "\"show variables\" | grep "
"^interactive_timeout | awk " "^interactive_timeout | awk "
"'{print($2)}' | tr -d '\n'").read() "'{print($2)}' | tr -d '\n'").read()
max_used_connections = os.popen("/usr/bin/mysql -e " max_used_connections = os.popen("/usr/bin/mysql -e "
"\"show global status\" | " "\"show global status\" | "
"grep Max_used_connections | awk " "grep Max_used_connections | awk "
"'{print($2)}' | tr -d '\n'").read() "'{print($2)}' | tr -d '\n'").read()
datadir = os.popen("/usr/bin/mysql -e \"show variables\" | " datadir = os.popen("/usr/bin/mysql -e \"show variables\" | "
"grep datadir | awk" "grep datadir | awk"
" '{print($2)}' | tr -d '\n'").read() " '{print($2)}' | tr -d '\n'").read()
socket = os.popen("/usr/bin/mysql -e \"show variables\" | " socket = os.popen("/usr/bin/mysql -e \"show variables\" | "
"grep \"^socket\" | " "grep \"^socket\" | "
"awk '{print($2)}' | tr -d '\n'").read() "awk '{print($2)}' | tr -d '\n'").read()
data = dict(version=version, host=host, port=port, data = dict(version=version, host=host, port=port,
wait_timeout=wait_timeout, wait_timeout=wait_timeout,
interactive_timeout=interactive_timeout, interactive_timeout=interactive_timeout,
max_used_connections=max_used_connections, max_used_connections=max_used_connections,
datadir=datadir, socket=socket) datadir=datadir, socket=socket)
self.app.render((data), 'info_mysql.mustache') self.app.render((data), 'info_mysql.mustache')
@expose(hide=True) @expose(hide=True)
def default(self): def default(self):
"""default function for info""" """default function for info"""
if (not self.app.pargs.nginx and not self.app.pargs.php and if (not self.app.pargs.nginx and not self.app.pargs.php and
not self.app.pargs.mysql and not self.app.pargs.php73): not self.app.pargs.mysql and not self.app.pargs.php73):
self.app.pargs.nginx = True self.app.pargs.nginx = True
self.app.pargs.php = True self.app.pargs.php = True
self.app.pargs.mysql = True self.app.pargs.mysql = True
if WOAptGet.is_installed(self, 'php7.3-fpm'): if WOAptGet.is_installed(self, 'php7.3-fpm'):
self.app.pargs.php73 = True self.app.pargs.php73 = True
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-wo')): 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")
if self.app.pargs.php: if self.app.pargs.php:
if WOAptGet.is_installed(self, 'php7.2-fpm'): if WOAptGet.is_installed(self, 'php7.2-fpm'):
self.info_php() self.info_php()
else: else:
Log.error(self, "PHP 7.2 is not installed") Log.error(self, "PHP 7.2 is not installed")
if self.app.pargs.php73: if self.app.pargs.php73:
if WOAptGet.is_installed(self, 'php7.3-fpm'): if WOAptGet.is_installed(self, 'php7.3-fpm'):
self.info_php73() self.info_php73()
else: else:
Log.error(self, "PHP 7.3 is not installed") Log.error(self, "PHP 7.3 is not installed")
if self.app.pargs.mysql: if self.app.pargs.mysql:
if WOShellExec.cmd_exec(self, "mysqladmin ping"): if WOShellExec.cmd_exec(self, "mysqladmin ping"):
self.info_mysql() self.info_mysql()
else: else:
Log.error(self, "MySQL is not installed") Log.error(self, "MySQL is not installed")
def load(app): def load(app):
# register the plugin class.. this only happens if the plugin is enabled # register the plugin class.. this only happens if the plugin is enabled
handler.register(WOInfoController) handler.register(WOInfoController)
# register a hook (function) to run after arguments are parsed. # register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', wo_info_hook) hook.register('post_argument_parsing', wo_info_hook)

View File

@@ -1,52 +1,52 @@
"""Maintenance Plugin for WordOps""" """Maintenance Plugin for WordOps"""
from cement.core.controller import CementBaseController, expose from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook from cement.core import handler, hook
from wo.core.logging import Log from wo.core.logging import Log
from wo.core.variables import WOVariables from wo.core.variables import WOVariables
from wo.core.aptget import WOAptGet from wo.core.aptget import WOAptGet
from wo.core.apt_repo import WORepo from wo.core.apt_repo import WORepo
from wo.core.services import WOService from wo.core.services import WOService
from wo.core.shellexec import WOShellExec from wo.core.shellexec import WOShellExec
def wo_maintenance_hook(app): def wo_maintenance_hook(app):
pass pass
class WOMaintenanceController(CementBaseController): class WOMaintenanceController(CementBaseController):
class Meta: class Meta:
label = 'maintenance' label = 'maintenance'
stacked_on = 'base' stacked_on = 'base'
stacked_type = 'nested' stacked_type = 'nested'
description = ('update server packages to latest version') description = ('update server packages to latest version')
usage = "wo maintenance" usage = "wo maintenance"
@expose(hide=True) @expose(hide=True)
def default(self): def default(self):
try: try:
Log.info(self, "updating apt-cache, please wait...") Log.info(self, "updating apt-cache, please wait...")
WOShellExec.cmd_exec(self, "apt-get update") WOShellExec.cmd_exec(self, "apt-get update")
Log.info(self, "updating packages, please wait...") Log.info(self, "updating packages, please wait...")
WOShellExec.cmd_exec(self, "DEBIAN_FRONTEND=noninteractive " WOShellExec.cmd_exec(self, "DEBIAN_FRONTEND=noninteractive "
"apt-get -o " "apt-get -o "
"Dpkg::Options::='--force-confmiss' " "Dpkg::Options::='--force-confmiss' "
"-o Dpkg::Options::='--force-confold' " "-o Dpkg::Options::='--force-confold' "
"-y dist-upgrade") "-y dist-upgrade")
Log.info(self, "cleaning-up packages, please wait...") Log.info(self, "cleaning-up packages, please wait...")
WOShellExec.cmd_exec(self, "apt-get -y --purge autoremove") WOShellExec.cmd_exec(self, "apt-get -y --purge autoremove")
WOShellExec.cmd_exec(self, "apt-get -y autoclean") WOShellExec.cmd_exec(self, "apt-get -y autoclean")
except OSError as e: except OSError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Package updates failed !") Log.error(self, "Package updates failed !")
except Exception as e: except Exception as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Packages updates failed !") Log.error(self, "Packages updates failed !")
def load(app): def load(app):
# register the plugin class.. this only happens if the plugin is enabled # register the plugin class.. this only happens if the plugin is enabled
handler.register(WOMaintenanceController) handler.register(WOMaintenanceController)
# register a hook (function) to run after arguments are parsed. # register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', wo_maintenance_hook) hook.register('post_argument_parsing', wo_maintenance_hook)

File diff suppressed because it is too large Load Diff

View File

@@ -370,7 +370,7 @@ class WOStackController(CementBaseController):
# php73 conf # php73 conf
if not os.path.isfile("/etc/nginx/common/php73.conf"): if not os.path.isfile("/etc/nginx/common/php73.conf"):
# data = dict() # data = dict()
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/php73.conf') 'file /etc/nginx/common/php73.conf')
wo_nginx = open('/etc/nginx/common/php73.conf', wo_nginx = open('/etc/nginx/common/php73.conf',
@@ -1418,6 +1418,7 @@ class WOStackController(CementBaseController):
self.app.pargs.web = True self.app.pargs.web = True
self.app.pargs.admin = True self.app.pargs.admin = True
self.app.pargs.php73 = True self.app.pargs.php73 = True
self.app.pargs.redis = True
if self.app.pargs.web: if self.app.pargs.web:
self.app.pargs.nginx = True self.app.pargs.nginx = True

View File

@@ -38,6 +38,8 @@ class WOStackUpgradeController(CementBaseController):
dict(help='Upgrade Redis', action='store_true')), dict(help='Upgrade Redis', action='store_true')),
(['--netdata'], (['--netdata'],
dict(help='Upgrade Netdata', action='store_true')), dict(help='Upgrade Netdata', action='store_true')),
(['--phpmyadmin'],
dict(help='Upgrade phpMyAdmin', action='store_true')),
(['--no-prompt'], (['--no-prompt'],
dict(help="Upgrade Packages without any prompt", dict(help="Upgrade Packages without any prompt",
action='store_true')), action='store_true')),
@@ -83,7 +85,9 @@ class WOStackUpgradeController(CementBaseController):
if ((not self.app.pargs.web) and (not self.app.pargs.nginx) and if ((not self.app.pargs.web) and (not self.app.pargs.nginx) and
(not self.app.pargs.php) and (not self.app.pargs.mysql) and (not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.all) and (not self.app.pargs.wpcli) and (not self.app.pargs.all) and (not self.app.pargs.wpcli) and
(not self.app.pargs.netdata) and (not self.app.pargs.redis)): (not self.app.pargs.netdata) and
(not self.app.pargs.phpmyadmin) and
(not self.app.pargs.redis)):
self.app.pargs.web = True self.app.pargs.web = True
if self.app.pargs.all: if self.app.pargs.all:
@@ -144,6 +148,18 @@ class WOStackUpgradeController(CementBaseController):
'kickstart-static64.sh', 'kickstart-static64.sh',
'/var/lib/wo/tmp/kickstart.sh', '/var/lib/wo/tmp/kickstart.sh',
'Netdata']] 'Netdata']]
if self.app.pargs.phpmyadmin:
if os.path.isdir('/var/www/22222/htdocs/db/pma'):
packages = packages + \
[["https://files.phpmyadmin.net"
"/phpMyAdmin/{0}/"
"phpMyAdmin-{0}-"
"all-languages"
".zip".format(WOVariables.wo_phpmyadmin),
"/var/lib/wo/tmp/pma.tar.gz",
"PHPMyAdmin"]]
else:
Log.error(self, "phpMyAdmin isn't installed")
if len(packages) or len(apt_packages): if len(packages) or len(apt_packages):
@@ -190,6 +206,24 @@ class WOStackUpgradeController(CementBaseController):
WOShellExec.cmd_exec(self, "/bin/bash /var/lib/wo/tmp/" WOShellExec.cmd_exec(self, "/bin/bash /var/lib/wo/tmp/"
"kickstart.sh " "kickstart.sh "
"--dont-wait") "--dont-wait")
if self.app.pargs.phpmyadmin:
Log.info(self, "Upgrading phpMyAdmin, please wait...")
WOExtract.extract(
self, '/var/lib/wo/tmp/pma.tar.gz', '/var/lib/wo/tmp/')
shutil.copyfile('{0}22222/htdocs/db/pma'
'/config.inc.php'
.format(WOVariables.wo_webroot),
'/var/lib/wo/tmp/phpMyAdmin-{0}'
'-all-languages/config.inc.php'
.format(WOVariables.wo_phpmyadmin)
)
WOFileUtils.remove('{0}22222/htdocs/db/pma'
.format(WOVariables.wo_webroot))
shutil.move('/var/lib/wo/tmp/phpMyAdmin-{0}'
'-all-languages/'
.format(WOVariables.wo_phpmyadmin),
'{0}22222/htdocs/db/pma/'
.format(WOVariables.wo_webroot))
Log.info(self, "Successfully updated packages") Log.info(self, "Successfully updated packages")
else: else:

View File

@@ -1,186 +1,187 @@
"""WordOps core variable module""" """WordOps core variable module"""
import platform import platform
import socket import socket
import configparser import configparser
import os import os
import psutil import psutil
import datetime import datetime
class WOVariables(): class WOVariables():
"""Intialization of core variables""" """Intialization of core variables"""
# WordOps version # WordOps version
wo_version = "3.9.5.4" wo_version = "3.9.5.4"
# WordOps packages versions # WordOps packages versions
wo_wp_cli = "2.2.0" wo_wp_cli = "2.2.0"
wo_adminer = "4.7.1" wo_adminer = "4.7.1"
wo_phpmyadmin = "4.9.0.1"
# Get WPCLI path
wo_wpcli_path = os.popen('command -v wp | tr "\n" " "').read() # Get WPCLI path
if wo_wpcli_path == '': wo_wpcli_path = os.popen('command -v wp | tr "\n" " "').read()
wo_wpcli_path = '/usr/local/bin/wp ' if wo_wpcli_path == '':
wo_wpcli_path = '/usr/local/bin/wp '
# get wan network interface name
wo_wan = os.popen("/sbin/ip -4 route get 8.8.8.8 | " # get wan network interface name
"grep -oP \"dev [^[:space:]]+ \" " wo_wan = os.popen("/sbin/ip -4 route get 8.8.8.8 | "
"| cut -d ' ' -f 2").read() "grep -oP \"dev [^[:space:]]+ \" "
if wo_wan == '': "| cut -d ' ' -f 2").read()
wo_wan = 'eth0' if wo_wan == '':
wo_wan = 'eth0'
# Current date and time of System
wo_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S') # Current date and time of System
wo_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S')
# WordOps core variables
wo_platform_distro = os.popen("lsb_release -si " # WordOps core variables
"| tr -d \'\\n\'").read().lower() wo_platform_distro = os.popen("lsb_release -si "
wo_platform_version = platform.linux_distribution()[1] "| tr -d \'\\n\'").read().lower()
wo_platform_codename = os.popen("lsb_release -sc | tr -d \'\\n\'").read() wo_platform_version = platform.linux_distribution()[1]
wo_platform_codename = os.popen("lsb_release -sc | tr -d \'\\n\'").read()
# Get timezone of system
if os.path.isfile('/etc/timezone'): # Get timezone of system
with open("/etc/timezone", "r") as tzfile: if os.path.isfile('/etc/timezone'):
wo_timezone = tzfile.read().replace('\n', '') with open("/etc/timezone", "r") as tzfile:
if wo_timezone == "Etc/UTC": wo_timezone = tzfile.read().replace('\n', '')
wo_timezone = "UTC" if wo_timezone == "Etc/UTC":
else: wo_timezone = "UTC"
wo_timezone = "Europe/Amsterdam" else:
wo_timezone = "Europe/Amsterdam"
# Get FQDN of system
wo_fqdn = socket.getfqdn() # Get FQDN of system
wo_fqdn = socket.getfqdn()
# WordOps default webroot path
wo_webroot = '/var/www/' # WordOps default webroot path
wo_webroot = '/var/www/'
# WordOps default renewal SSL certificates path
wo_ssl_archive = '/etc/letsencrypt/renewal' # WordOps default renewal SSL certificates path
wo_ssl_archive = '/etc/letsencrypt/renewal'
# WordOps default live SSL certificates path
wo_ssl_live = '/etc/letsencrypt/live' # WordOps default live SSL certificates path
wo_ssl_live = '/etc/letsencrypt/live'
# PHP user
wo_php_user = 'www-data' # PHP user
wo_php_user = 'www-data'
# Get git user name and EMail
config = configparser.ConfigParser() # Get git user name and EMail
config.read(os.path.expanduser("~")+'/.gitconfig') config = configparser.ConfigParser()
try: config.read(os.path.expanduser("~")+'/.gitconfig')
wo_user = config['user']['name'] try:
wo_email = config['user']['email'] wo_user = config['user']['name']
except Exception as e: wo_email = config['user']['email']
wo_user = input("Enter your name: ") except Exception as e:
wo_email = input("Enter your email: ") wo_user = input("Enter your name: ")
os.system("/usr/bin/git config --global user.name {0}".format(wo_user)) wo_email = input("Enter your email: ")
os.system( os.system("/usr/bin/git config --global user.name {0}".format(wo_user))
"/usr/bin/git config --global user.email {0}".format(wo_email)) os.system(
"/usr/bin/git config --global user.email {0}".format(wo_email))
# MySQL hostname
wo_mysql_host = "" # MySQL hostname
config = configparser.RawConfigParser() wo_mysql_host = ""
if os.path.exists('/etc/mysql/conf.d/my.cnf'): config = configparser.RawConfigParser()
cnfpath = "/etc/mysql/conf.d/my.cnf" if os.path.exists('/etc/mysql/conf.d/my.cnf'):
else: cnfpath = "/etc/mysql/conf.d/my.cnf"
cnfpath = os.path.expanduser("~")+"/.my.cnf" else:
if [cnfpath] == config.read(cnfpath): cnfpath = os.path.expanduser("~")+"/.my.cnf"
try: if [cnfpath] == config.read(cnfpath):
wo_mysql_host = config.get('client', 'host') try:
except configparser.NoOptionError as e: wo_mysql_host = config.get('client', 'host')
wo_mysql_host = "localhost" except configparser.NoOptionError as e:
else: wo_mysql_host = "localhost"
wo_mysql_host = "localhost" else:
wo_mysql_host = "localhost"
# WordOps stack installation variables
# Nginx repo and packages # WordOps stack installation variables
if wo_platform_distro == 'ubuntu': # Nginx repo and packages
if wo_platform_codename == 'trusty': if wo_platform_distro == 'ubuntu':
wo_nginx_repo = ("deb http://download.opensuse.org" if wo_platform_codename == 'trusty':
"/repositories/home:" wo_nginx_repo = ("deb http://download.opensuse.org"
"/virtubox:/WordOps/xUbuntu_14.04/ /") "/repositories/home:"
else: "/virtubox:/WordOps/xUbuntu_14.04/ /")
wo_nginx_repo = "ppa:wordops/nginx-wo" else:
elif wo_platform_distro == 'debian': wo_nginx_repo = "ppa:wordops/nginx-wo"
if wo_platform_codename == 'jessie': elif wo_platform_distro == 'debian':
wo_nginx_repo = ("deb http://download.opensuse.org" if wo_platform_codename == 'jessie':
"/repositories/home:" wo_nginx_repo = ("deb http://download.opensuse.org"
"/virtubox:/WordOps/Debian_8.0/ /") "/repositories/home:"
elif wo_platform_codename == 'stretch': "/virtubox:/WordOps/Debian_8.0/ /")
wo_nginx_repo = ("deb http://download.opensuse.org" elif wo_platform_codename == 'stretch':
"/repositories/home:" wo_nginx_repo = ("deb http://download.opensuse.org"
"/virtubox:/WordOps/Debian_9.0/ /") "/repositories/home:"
else: "/virtubox:/WordOps/Debian_9.0/ /")
wo_nginx_repo = ("deb http://download.opensuse.org/repositories/home:" else:
"/virtubox:/WordOps/Raspbian_9.0/ /") wo_nginx_repo = ("deb http://download.opensuse.org/repositories/home:"
"/virtubox:/WordOps/Raspbian_9.0/ /")
wo_nginx = ["nginx-custom", "nginx-wo"]
wo_nginx_key = '188C9FB063F0247A' wo_nginx = ["nginx-custom", "nginx-wo"]
wo_nginx_key = '188C9FB063F0247A'
# PHP repo and packages
if wo_platform_distro == 'ubuntu': # PHP repo and packages
wo_php_repo = "ppa:ondrej/php" if wo_platform_distro == 'ubuntu':
wo_php = ["php7.2-fpm", "php7.2-curl", "php7.2-gd", "php7.2-imap", wo_php_repo = "ppa:ondrej/php"
"php7.2-readline", "php7.2-common", "php7.2-recode", wo_php = ["php7.2-fpm", "php7.2-curl", "php7.2-gd", "php7.2-imap",
"php7.2-cli", "php7.2-mbstring", "php7.2-readline", "php7.2-common", "php7.2-recode",
"php7.2-bcmath", "php7.2-mysql", "php7.2-opcache", "php7.2-cli", "php7.2-mbstring",
"php7.2-zip", "php7.2-xml", "php7.2-soap"] "php7.2-bcmath", "php7.2-mysql", "php7.2-opcache",
wo_php73 = ["php7.3-fpm", "php7.3-curl", "php7.3-gd", "php7.3-imap", "php7.2-zip", "php7.2-xml", "php7.2-soap"]
"php7.3-readline", "php7.3-common", "php7.3-recode", wo_php73 = ["php7.3-fpm", "php7.3-curl", "php7.3-gd", "php7.3-imap",
"php7.3-cli", "php7.3-mbstring", "php7.3-readline", "php7.3-common", "php7.3-recode",
"php7.3-bcmath", "php7.3-mysql", "php7.3-opcache", "php7.3-cli", "php7.3-mbstring",
"php7.3-zip", "php7.3-xml", "php7.3-soap"] "php7.3-bcmath", "php7.3-mysql", "php7.3-opcache",
wo_php_extra = ["php-memcached", "php-imagick", "php7.3-zip", "php7.3-xml", "php7.3-soap"]
"graphviz", "php-xdebug", "php-msgpack", "php-redis"] wo_php_extra = ["php-memcached", "php-imagick",
wo_php_key = '' "graphviz", "php-xdebug", "php-msgpack", "php-redis"]
else: wo_php_key = ''
wo_php_repo = ( else:
"deb https://packages.sury.org/php/ {codename} main" wo_php_repo = (
.format(codename=wo_platform_codename)) "deb https://packages.sury.org/php/ {codename} main"
wo_php = ["php7.2-fpm", "php7.2-curl", "php7.2-gd", "php7.2-imap", .format(codename=wo_platform_codename))
"php7.2-readline", "php7.2-common", "php7.2-recode", wo_php = ["php7.2-fpm", "php7.2-curl", "php7.2-gd", "php7.2-imap",
"php7.2-cli", "php7.2-mbstring", "php7.2-readline", "php7.2-common", "php7.2-recode",
"php7.2-bcmath", "php7.2-mysql", "php7.2-opcache", "php7.2-cli", "php7.2-mbstring",
"php7.2-zip", "php7.2-xml", "php7.2-soap"] "php7.2-bcmath", "php7.2-mysql", "php7.2-opcache",
wo_php73 = ["php7.3-fpm", "php7.3-curl", "php7.3-gd", "php7.3-imap", "php7.2-zip", "php7.2-xml", "php7.2-soap"]
"php7.3-readline", "php7.3-common", "php7.3-recode", wo_php73 = ["php7.3-fpm", "php7.3-curl", "php7.3-gd", "php7.3-imap",
"php7.3-cli", "php7.3-mbstring", "php7.3-readline", "php7.3-common", "php7.3-recode",
"php7.3-bcmath", "php7.3-mysql", "php7.3-opcache", "php7.3-cli", "php7.3-mbstring",
"php7.3-zip", "php7.3-xml", "php7.3-soap"] "php7.3-bcmath", "php7.3-mysql", "php7.3-opcache",
wo_php_extra = ["php-memcached", "php-imagick", "php7.3-zip", "php7.3-xml", "php7.3-soap"]
"graphviz", "php-xdebug", "php-msgpack", "php-redis"] wo_php_extra = ["php-memcached", "php-imagick",
"graphviz", "php-xdebug", "php-msgpack", "php-redis"]
wo_php_key = 'AC0E47584A7A714D'
wo_php_key = 'AC0E47584A7A714D'
# MySQL repo and packages
if wo_platform_distro == 'ubuntu': # MySQL repo and packages
wo_mysql_repo = ("deb [arch=amd64,ppc64el] " if wo_platform_distro == 'ubuntu':
"http://sfo1.mirrors.digitalocean.com/mariadb/repo/" wo_mysql_repo = ("deb [arch=amd64,ppc64el] "
"10.3/ubuntu {codename} main" "http://sfo1.mirrors.digitalocean.com/mariadb/repo/"
.format(codename=wo_platform_codename)) "10.3/ubuntu {codename} main"
else: .format(codename=wo_platform_codename))
wo_mysql_repo = ("deb [arch=amd64,ppc64el] " else:
"http://sfo1.mirrors.digitalocean.com/mariadb/repo/" wo_mysql_repo = ("deb [arch=amd64,ppc64el] "
"10.3/debian {codename} main" "http://sfo1.mirrors.digitalocean.com/mariadb/repo/"
.format(codename=wo_platform_codename)) "10.3/debian {codename} main"
wo_mysql = ["mariadb-server", "percona-toolkit", "python3-mysqldb"] .format(codename=wo_platform_codename))
wo_mysql = ["mariadb-server", "percona-toolkit", "python3-mysqldb"]
wo_fail2ban = "fail2ban"
wo_fail2ban = "fail2ban"
# Redis repo details
if wo_platform_distro == 'ubuntu': # Redis repo details
wo_redis_repo = ("ppa:chris-lea/redis-server") if wo_platform_distro == 'ubuntu':
wo_redis_repo = ("ppa:chris-lea/redis-server")
else:
wo_redis_repo = ("deb https://packages.sury.org/php/ {codename} all" else:
.format(codename=wo_platform_codename)) wo_redis_repo = ("deb https://packages.sury.org/php/ {codename} all"
.format(codename=wo_platform_codename))
wo_redis = ['redis-server', 'php-redis']
wo_redis = ['redis-server', 'php-redis']
# Repo path
wo_repo_file = "wo-repo.list" # Repo path
wo_repo_file_path = ("/etc/apt/sources.list.d/" + wo_repo_file) wo_repo_file = "wo-repo.list"
wo_repo_file_path = ("/etc/apt/sources.list.d/" + wo_repo_file)
# Application dabase file path
basedir = os.path.abspath(os.path.dirname('/var/lib/wo/')) # Application dabase file path
wo_db_uri = 'sqlite:///' + os.path.join(basedir, 'dbase.db') basedir = os.path.abspath(os.path.dirname('/var/lib/wo/'))
wo_db_uri = 'sqlite:///' + os.path.join(basedir, 'dbase.db')
def __init__(self):
pass def __init__(self):
pass