Add upgrade script for phpmyadmin
This commit is contained in:
@@ -1,293 +1,293 @@
|
||||
"""WOInfo Plugin for WordOps"""
|
||||
|
||||
from cement.core.controller import CementBaseController, expose
|
||||
from cement.core import handler, hook
|
||||
from wo.core.variables import WOVariables
|
||||
from pynginxconfig import NginxConfig
|
||||
from wo.core.aptget import WOAptGet
|
||||
from wo.core.shellexec import WOShellExec
|
||||
from wo.core.logging import Log
|
||||
import os
|
||||
import configparser
|
||||
|
||||
|
||||
def wo_info_hook(app):
|
||||
pass
|
||||
|
||||
|
||||
class WOInfoController(CementBaseController):
|
||||
class Meta:
|
||||
label = 'info'
|
||||
stacked_on = 'base'
|
||||
stacked_type = 'nested'
|
||||
description = ('Display configuration information related to Nginx,'
|
||||
' PHP and MySQL')
|
||||
arguments = [
|
||||
(['--mysql'],
|
||||
dict(help='Get MySQL configuration information',
|
||||
action='store_true')),
|
||||
(['--php'],
|
||||
dict(help='Get PHP 7.2 configuration information',
|
||||
action='store_true')),
|
||||
(['--php73'],
|
||||
dict(help='Get PHP 7.3 configuration information',
|
||||
action='store_true')),
|
||||
(['--nginx'],
|
||||
dict(help='Get Nginx configuration information',
|
||||
action='store_true')),
|
||||
]
|
||||
usage = "wo info [options]"
|
||||
|
||||
@expose(hide=True)
|
||||
def info_nginx(self):
|
||||
"""Display Nginx information"""
|
||||
version = os.popen("/usr/sbin/nginx -v 2>&1 | "
|
||||
"awk -F '/' '{print $2}' | "
|
||||
"awk -F ' ' '{print $1}' | tr '\n' ' '").read()
|
||||
allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | "
|
||||
"cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' '").read()
|
||||
nc = NginxConfig()
|
||||
nc.loadf('/etc/nginx/nginx.conf')
|
||||
user = nc.get('user')[1]
|
||||
worker_processes = nc.get('worker_processes')[1]
|
||||
worker_connections = nc.get([('events',), 'worker_connections'])[1]
|
||||
keepalive_timeout = nc.get([('http',), 'keepalive_timeout'])[1]
|
||||
fastcgi_read_timeout = nc.get([('http',),
|
||||
'fastcgi_read_timeout'])[1]
|
||||
client_max_body_size = nc.get([('http',),
|
||||
'client_max_body_size'])[1]
|
||||
data = dict(version=version, allow=allow, user=user,
|
||||
worker_processes=worker_processes,
|
||||
keepalive_timeout=keepalive_timeout,
|
||||
worker_connections=worker_connections,
|
||||
fastcgi_read_timeout=fastcgi_read_timeout,
|
||||
client_max_body_size=client_max_body_size)
|
||||
self.app.render((data), 'info_nginx.mustache')
|
||||
|
||||
@expose(hide=True)
|
||||
def info_php(self):
|
||||
"""Display PHP information"""
|
||||
version = os.popen("/usr/bin/php7.2 -v 2>/dev/null | "
|
||||
"head -n1 | cut -d' ' -f2 |"
|
||||
" cut -d'+' -f1 | tr -d '\n'").read
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/{0}/fpm/php.ini'.format("php/7.2"))
|
||||
expose_php = config['PHP']['expose_php']
|
||||
memory_limit = config['PHP']['memory_limit']
|
||||
post_max_size = config['PHP']['post_max_size']
|
||||
upload_max_filesize = config['PHP']['upload_max_filesize']
|
||||
max_execution_time = config['PHP']['max_execution_time']
|
||||
|
||||
config.read('/etc/{0}/fpm/pool.d/www.conf'.format("php/7.2"))
|
||||
www_listen = config['www']['listen']
|
||||
www_ping_path = config['www']['ping.path']
|
||||
www_pm_status_path = config['www']['pm.status_path']
|
||||
www_pm = config['www']['pm']
|
||||
www_pm_max_requests = config['www']['pm.max_requests']
|
||||
www_pm_max_children = config['www']['pm.max_children']
|
||||
www_pm_start_servers = config['www']['pm.start_servers']
|
||||
www_pm_min_spare_servers = config['www']['pm.min_spare_servers']
|
||||
www_pm_max_spare_servers = config['www']['pm.max_spare_servers']
|
||||
www_request_terminate_time = (config['www']
|
||||
['request_terminate_timeout'])
|
||||
try:
|
||||
www_xdebug = (config['www']['php_admin_flag[xdebug.profiler_enable'
|
||||
'_trigger]'])
|
||||
except Exception as e:
|
||||
www_xdebug = 'off'
|
||||
|
||||
config.read('/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2"))
|
||||
debug_listen = config['debug']['listen']
|
||||
debug_ping_path = config['debug']['ping.path']
|
||||
debug_pm_status_path = config['debug']['pm.status_path']
|
||||
debug_pm = config['debug']['pm']
|
||||
debug_pm_max_requests = config['debug']['pm.max_requests']
|
||||
debug_pm_max_children = config['debug']['pm.max_children']
|
||||
debug_pm_start_servers = config['debug']['pm.start_servers']
|
||||
debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers']
|
||||
debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers']
|
||||
debug_request_terminate = (config['debug']
|
||||
['request_terminate_timeout'])
|
||||
try:
|
||||
debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_'
|
||||
'enable_trigger]'])
|
||||
except Exception as e:
|
||||
debug_xdebug = 'off'
|
||||
|
||||
data = dict(version=version, expose_php=expose_php,
|
||||
memory_limit=memory_limit, post_max_size=post_max_size,
|
||||
upload_max_filesize=upload_max_filesize,
|
||||
max_execution_time=max_execution_time,
|
||||
www_listen=www_listen, www_ping_path=www_ping_path,
|
||||
www_pm_status_path=www_pm_status_path, www_pm=www_pm,
|
||||
www_pm_max_requests=www_pm_max_requests,
|
||||
www_pm_max_children=www_pm_max_children,
|
||||
www_pm_start_servers=www_pm_start_servers,
|
||||
www_pm_min_spare_servers=www_pm_min_spare_servers,
|
||||
www_pm_max_spare_servers=www_pm_max_spare_servers,
|
||||
www_request_terminate_timeout=www_request_terminate_time,
|
||||
www_xdebug_profiler_enable_trigger=www_xdebug,
|
||||
debug_listen=debug_listen, debug_ping_path=debug_ping_path,
|
||||
debug_pm_status_path=debug_pm_status_path,
|
||||
debug_pm=debug_pm,
|
||||
debug_pm_max_requests=debug_pm_max_requests,
|
||||
debug_pm_max_children=debug_pm_max_children,
|
||||
debug_pm_start_servers=debug_pm_start_servers,
|
||||
debug_pm_min_spare_servers=debug_pm_min_spare_servers,
|
||||
debug_pm_max_spare_servers=debug_pm_max_spare_servers,
|
||||
debug_request_terminate_timeout=debug_request_terminate,
|
||||
debug_xdebug_profiler_enable_trigger=debug_xdebug)
|
||||
self.app.render((data), 'info_php.mustache')
|
||||
|
||||
@expose(hide=True)
|
||||
def info_php73(self):
|
||||
"""Display PHP information"""
|
||||
version = os.popen("/usr/bin/php7.3 -v 2>/dev/null | "
|
||||
"head -n1 | cut -d' ' -f2 |"
|
||||
" cut -d'+' -f1 | tr -d '\n'").read
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/7.3/fpm/php.ini')
|
||||
expose_php = config['PHP']['expose_php']
|
||||
memory_limit = config['PHP']['memory_limit']
|
||||
post_max_size = config['PHP']['post_max_size']
|
||||
upload_max_filesize = config['PHP']['upload_max_filesize']
|
||||
max_execution_time = config['PHP']['max_execution_time']
|
||||
|
||||
config.read('/etc/php/7.3/fpm/pool.d/www.conf')
|
||||
www_listen = config['www']['listen']
|
||||
www_ping_path = config['www']['ping.path']
|
||||
www_pm_status_path = config['www']['pm.status_path']
|
||||
www_pm = config['www']['pm']
|
||||
www_pm_max_requests = config['www']['pm.max_requests']
|
||||
www_pm_max_children = config['www']['pm.max_children']
|
||||
www_pm_start_servers = config['www']['pm.start_servers']
|
||||
www_pm_min_spare_servers = config['www']['pm.min_spare_servers']
|
||||
www_pm_max_spare_servers = config['www']['pm.max_spare_servers']
|
||||
www_request_terminate_time = (config['www']
|
||||
['request_terminate_timeout'])
|
||||
try:
|
||||
www_xdebug = (config['www']['php_admin_flag[xdebug.profiler_enable'
|
||||
'_trigger]'])
|
||||
except Exception as e:
|
||||
www_xdebug = 'off'
|
||||
|
||||
config.read('/etc/php/7.3/fpm/pool.d/debug.conf')
|
||||
debug_listen = config['debug']['listen']
|
||||
debug_ping_path = config['debug']['ping.path']
|
||||
debug_pm_status_path = config['debug']['pm.status_path']
|
||||
debug_pm = config['debug']['pm']
|
||||
debug_pm_max_requests = config['debug']['pm.max_requests']
|
||||
debug_pm_max_children = config['debug']['pm.max_children']
|
||||
debug_pm_start_servers = config['debug']['pm.start_servers']
|
||||
debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers']
|
||||
debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers']
|
||||
debug_request_terminate = (config['debug']
|
||||
['request_terminate_timeout'])
|
||||
try:
|
||||
debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_'
|
||||
'enable_trigger]'])
|
||||
except Exception as e:
|
||||
debug_xdebug = 'off'
|
||||
|
||||
data = dict(version=version, expose_php=expose_php,
|
||||
memory_limit=memory_limit, post_max_size=post_max_size,
|
||||
upload_max_filesize=upload_max_filesize,
|
||||
max_execution_time=max_execution_time,
|
||||
www_listen=www_listen, www_ping_path=www_ping_path,
|
||||
www_pm_status_path=www_pm_status_path, www_pm=www_pm,
|
||||
www_pm_max_requests=www_pm_max_requests,
|
||||
www_pm_max_children=www_pm_max_children,
|
||||
www_pm_start_servers=www_pm_start_servers,
|
||||
www_pm_min_spare_servers=www_pm_min_spare_servers,
|
||||
www_pm_max_spare_servers=www_pm_max_spare_servers,
|
||||
www_request_terminate_timeout=www_request_terminate_time,
|
||||
www_xdebug_profiler_enable_trigger=www_xdebug,
|
||||
debug_listen=debug_listen, debug_ping_path=debug_ping_path,
|
||||
debug_pm_status_path=debug_pm_status_path,
|
||||
debug_pm=debug_pm,
|
||||
debug_pm_max_requests=debug_pm_max_requests,
|
||||
debug_pm_max_children=debug_pm_max_children,
|
||||
debug_pm_start_servers=debug_pm_start_servers,
|
||||
debug_pm_min_spare_servers=debug_pm_min_spare_servers,
|
||||
debug_pm_max_spare_servers=debug_pm_max_spare_servers,
|
||||
debug_request_terminate_timeout=debug_request_terminate,
|
||||
debug_xdebug_profiler_enable_trigger=debug_xdebug)
|
||||
self.app.render((data), 'info_php.mustache')
|
||||
|
||||
@expose(hide=True)
|
||||
def info_mysql(self):
|
||||
"""Display MySQL information"""
|
||||
version = os.popen("/usr/bin/mysql -V | awk '{print($5)}' | "
|
||||
"cut -d ',' "
|
||||
"-f1 | tr -d '\n'").read()
|
||||
host = "localhost"
|
||||
port = os.popen("/usr/bin/mysql -e \"show variables\" | "
|
||||
"grep ^port | awk "
|
||||
"'{print($2)}' | tr -d '\n'").read()
|
||||
wait_timeout = os.popen("/usr/bin/mysql -e \"show variables\" | grep "
|
||||
"^wait_timeout | awk '{print($2)}' | "
|
||||
"tr -d '\n'").read()
|
||||
interactive_timeout = os.popen("/usr/bin/mysql -e "
|
||||
"\"show variables\" | grep "
|
||||
"^interactive_timeout | awk "
|
||||
"'{print($2)}' | tr -d '\n'").read()
|
||||
max_used_connections = os.popen("/usr/bin/mysql -e "
|
||||
"\"show global status\" | "
|
||||
"grep Max_used_connections | awk "
|
||||
"'{print($2)}' | tr -d '\n'").read()
|
||||
datadir = os.popen("/usr/bin/mysql -e \"show variables\" | "
|
||||
"grep datadir | awk"
|
||||
" '{print($2)}' | tr -d '\n'").read()
|
||||
socket = os.popen("/usr/bin/mysql -e \"show variables\" | "
|
||||
"grep \"^socket\" | "
|
||||
"awk '{print($2)}' | tr -d '\n'").read()
|
||||
data = dict(version=version, host=host, port=port,
|
||||
wait_timeout=wait_timeout,
|
||||
interactive_timeout=interactive_timeout,
|
||||
max_used_connections=max_used_connections,
|
||||
datadir=datadir, socket=socket)
|
||||
self.app.render((data), 'info_mysql.mustache')
|
||||
|
||||
@expose(hide=True)
|
||||
def default(self):
|
||||
"""default function for info"""
|
||||
if (not self.app.pargs.nginx and not self.app.pargs.php and
|
||||
not self.app.pargs.mysql and not self.app.pargs.php73):
|
||||
self.app.pargs.nginx = True
|
||||
self.app.pargs.php = True
|
||||
self.app.pargs.mysql = True
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
self.app.pargs.php73 = True
|
||||
|
||||
if self.app.pargs.nginx:
|
||||
if (WOAptGet.is_installed(self, 'nginx-custom') or
|
||||
WOAptGet.is_installed(self, 'nginx-wo')):
|
||||
self.info_nginx()
|
||||
else:
|
||||
Log.error(self, "Nginx is not installed")
|
||||
|
||||
if self.app.pargs.php:
|
||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
self.info_php()
|
||||
else:
|
||||
Log.error(self, "PHP 7.2 is not installed")
|
||||
|
||||
if self.app.pargs.php73:
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
self.info_php73()
|
||||
else:
|
||||
Log.error(self, "PHP 7.3 is not installed")
|
||||
|
||||
if self.app.pargs.mysql:
|
||||
if WOShellExec.cmd_exec(self, "mysqladmin ping"):
|
||||
self.info_mysql()
|
||||
else:
|
||||
Log.error(self, "MySQL is not installed")
|
||||
|
||||
|
||||
def load(app):
|
||||
# register the plugin class.. this only happens if the plugin is enabled
|
||||
handler.register(WOInfoController)
|
||||
|
||||
# register a hook (function) to run after arguments are parsed.
|
||||
hook.register('post_argument_parsing', wo_info_hook)
|
||||
"""WOInfo Plugin for WordOps"""
|
||||
|
||||
from cement.core.controller import CementBaseController, expose
|
||||
from cement.core import handler, hook
|
||||
from wo.core.variables import WOVariables
|
||||
from pynginxconfig import NginxConfig
|
||||
from wo.core.aptget import WOAptGet
|
||||
from wo.core.shellexec import WOShellExec
|
||||
from wo.core.logging import Log
|
||||
import os
|
||||
import configparser
|
||||
|
||||
|
||||
def wo_info_hook(app):
|
||||
pass
|
||||
|
||||
|
||||
class WOInfoController(CementBaseController):
|
||||
class Meta:
|
||||
label = 'info'
|
||||
stacked_on = 'base'
|
||||
stacked_type = 'nested'
|
||||
description = ('Display configuration information related to Nginx,'
|
||||
' PHP and MySQL')
|
||||
arguments = [
|
||||
(['--mysql'],
|
||||
dict(help='Get MySQL configuration information',
|
||||
action='store_true')),
|
||||
(['--php'],
|
||||
dict(help='Get PHP 7.2 configuration information',
|
||||
action='store_true')),
|
||||
(['--php73'],
|
||||
dict(help='Get PHP 7.3 configuration information',
|
||||
action='store_true')),
|
||||
(['--nginx'],
|
||||
dict(help='Get Nginx configuration information',
|
||||
action='store_true')),
|
||||
]
|
||||
usage = "wo info [options]"
|
||||
|
||||
@expose(hide=True)
|
||||
def info_nginx(self):
|
||||
"""Display Nginx information"""
|
||||
version = os.popen("/usr/sbin/nginx -v 2>&1 | "
|
||||
"awk -F '/' '{print $2}' | "
|
||||
"awk -F ' ' '{print $1}' | tr '\n' ' '").read()
|
||||
allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | "
|
||||
"cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' '").read()
|
||||
nc = NginxConfig()
|
||||
nc.loadf('/etc/nginx/nginx.conf')
|
||||
user = nc.get('user')[1]
|
||||
worker_processes = nc.get('worker_processes')[1]
|
||||
worker_connections = nc.get([('events',), 'worker_connections'])[1]
|
||||
keepalive_timeout = nc.get([('http',), 'keepalive_timeout'])[1]
|
||||
fastcgi_read_timeout = nc.get([('http',),
|
||||
'fastcgi_read_timeout'])[1]
|
||||
client_max_body_size = nc.get([('http',),
|
||||
'client_max_body_size'])[1]
|
||||
data = dict(version=version, allow=allow, user=user,
|
||||
worker_processes=worker_processes,
|
||||
keepalive_timeout=keepalive_timeout,
|
||||
worker_connections=worker_connections,
|
||||
fastcgi_read_timeout=fastcgi_read_timeout,
|
||||
client_max_body_size=client_max_body_size)
|
||||
self.app.render((data), 'info_nginx.mustache')
|
||||
|
||||
@expose(hide=True)
|
||||
def info_php(self):
|
||||
"""Display PHP information"""
|
||||
version = os.popen("/usr/bin/php7.2 -v 2>/dev/null | "
|
||||
"head -n1 | cut -d' ' -f2 |"
|
||||
" cut -d'+' -f1 | tr -d '\n'").read
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/{0}/fpm/php.ini'.format("php/7.2"))
|
||||
expose_php = config['PHP']['expose_php']
|
||||
memory_limit = config['PHP']['memory_limit']
|
||||
post_max_size = config['PHP']['post_max_size']
|
||||
upload_max_filesize = config['PHP']['upload_max_filesize']
|
||||
max_execution_time = config['PHP']['max_execution_time']
|
||||
|
||||
config.read('/etc/{0}/fpm/pool.d/www.conf'.format("php/7.2"))
|
||||
www_listen = config['www']['listen']
|
||||
www_ping_path = config['www']['ping.path']
|
||||
www_pm_status_path = config['www']['pm.status_path']
|
||||
www_pm = config['www']['pm']
|
||||
www_pm_max_requests = config['www']['pm.max_requests']
|
||||
www_pm_max_children = config['www']['pm.max_children']
|
||||
www_pm_start_servers = config['www']['pm.start_servers']
|
||||
www_pm_min_spare_servers = config['www']['pm.min_spare_servers']
|
||||
www_pm_max_spare_servers = config['www']['pm.max_spare_servers']
|
||||
www_request_terminate_time = (config['www']
|
||||
['request_terminate_timeout'])
|
||||
try:
|
||||
www_xdebug = (config['www']['php_admin_flag[xdebug.profiler_enable'
|
||||
'_trigger]'])
|
||||
except Exception as e:
|
||||
www_xdebug = 'off'
|
||||
|
||||
config.read('/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2"))
|
||||
debug_listen = config['debug']['listen']
|
||||
debug_ping_path = config['debug']['ping.path']
|
||||
debug_pm_status_path = config['debug']['pm.status_path']
|
||||
debug_pm = config['debug']['pm']
|
||||
debug_pm_max_requests = config['debug']['pm.max_requests']
|
||||
debug_pm_max_children = config['debug']['pm.max_children']
|
||||
debug_pm_start_servers = config['debug']['pm.start_servers']
|
||||
debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers']
|
||||
debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers']
|
||||
debug_request_terminate = (config['debug']
|
||||
['request_terminate_timeout'])
|
||||
try:
|
||||
debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_'
|
||||
'enable_trigger]'])
|
||||
except Exception as e:
|
||||
debug_xdebug = 'off'
|
||||
|
||||
data = dict(version=version, expose_php=expose_php,
|
||||
memory_limit=memory_limit, post_max_size=post_max_size,
|
||||
upload_max_filesize=upload_max_filesize,
|
||||
max_execution_time=max_execution_time,
|
||||
www_listen=www_listen, www_ping_path=www_ping_path,
|
||||
www_pm_status_path=www_pm_status_path, www_pm=www_pm,
|
||||
www_pm_max_requests=www_pm_max_requests,
|
||||
www_pm_max_children=www_pm_max_children,
|
||||
www_pm_start_servers=www_pm_start_servers,
|
||||
www_pm_min_spare_servers=www_pm_min_spare_servers,
|
||||
www_pm_max_spare_servers=www_pm_max_spare_servers,
|
||||
www_request_terminate_timeout=www_request_terminate_time,
|
||||
www_xdebug_profiler_enable_trigger=www_xdebug,
|
||||
debug_listen=debug_listen, debug_ping_path=debug_ping_path,
|
||||
debug_pm_status_path=debug_pm_status_path,
|
||||
debug_pm=debug_pm,
|
||||
debug_pm_max_requests=debug_pm_max_requests,
|
||||
debug_pm_max_children=debug_pm_max_children,
|
||||
debug_pm_start_servers=debug_pm_start_servers,
|
||||
debug_pm_min_spare_servers=debug_pm_min_spare_servers,
|
||||
debug_pm_max_spare_servers=debug_pm_max_spare_servers,
|
||||
debug_request_terminate_timeout=debug_request_terminate,
|
||||
debug_xdebug_profiler_enable_trigger=debug_xdebug)
|
||||
self.app.render((data), 'info_php.mustache')
|
||||
|
||||
@expose(hide=True)
|
||||
def info_php73(self):
|
||||
"""Display PHP information"""
|
||||
version = os.popen("/usr/bin/php7.3 -v 2>/dev/null | "
|
||||
"head -n1 | cut -d' ' -f2 |"
|
||||
" cut -d'+' -f1 | tr -d '\n'").read
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/7.3/fpm/php.ini')
|
||||
expose_php = config['PHP']['expose_php']
|
||||
memory_limit = config['PHP']['memory_limit']
|
||||
post_max_size = config['PHP']['post_max_size']
|
||||
upload_max_filesize = config['PHP']['upload_max_filesize']
|
||||
max_execution_time = config['PHP']['max_execution_time']
|
||||
|
||||
config.read('/etc/php/7.3/fpm/pool.d/www.conf')
|
||||
www_listen = config['www']['listen']
|
||||
www_ping_path = config['www']['ping.path']
|
||||
www_pm_status_path = config['www']['pm.status_path']
|
||||
www_pm = config['www']['pm']
|
||||
www_pm_max_requests = config['www']['pm.max_requests']
|
||||
www_pm_max_children = config['www']['pm.max_children']
|
||||
www_pm_start_servers = config['www']['pm.start_servers']
|
||||
www_pm_min_spare_servers = config['www']['pm.min_spare_servers']
|
||||
www_pm_max_spare_servers = config['www']['pm.max_spare_servers']
|
||||
www_request_terminate_time = (config['www']
|
||||
['request_terminate_timeout'])
|
||||
try:
|
||||
www_xdebug = (config['www']['php_admin_flag[xdebug.profiler_enable'
|
||||
'_trigger]'])
|
||||
except Exception as e:
|
||||
www_xdebug = 'off'
|
||||
|
||||
config.read('/etc/php/7.3/fpm/pool.d/debug.conf')
|
||||
debug_listen = config['debug']['listen']
|
||||
debug_ping_path = config['debug']['ping.path']
|
||||
debug_pm_status_path = config['debug']['pm.status_path']
|
||||
debug_pm = config['debug']['pm']
|
||||
debug_pm_max_requests = config['debug']['pm.max_requests']
|
||||
debug_pm_max_children = config['debug']['pm.max_children']
|
||||
debug_pm_start_servers = config['debug']['pm.start_servers']
|
||||
debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers']
|
||||
debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers']
|
||||
debug_request_terminate = (config['debug']
|
||||
['request_terminate_timeout'])
|
||||
try:
|
||||
debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_'
|
||||
'enable_trigger]'])
|
||||
except Exception as e:
|
||||
debug_xdebug = 'off'
|
||||
|
||||
data = dict(version=version, expose_php=expose_php,
|
||||
memory_limit=memory_limit, post_max_size=post_max_size,
|
||||
upload_max_filesize=upload_max_filesize,
|
||||
max_execution_time=max_execution_time,
|
||||
www_listen=www_listen, www_ping_path=www_ping_path,
|
||||
www_pm_status_path=www_pm_status_path, www_pm=www_pm,
|
||||
www_pm_max_requests=www_pm_max_requests,
|
||||
www_pm_max_children=www_pm_max_children,
|
||||
www_pm_start_servers=www_pm_start_servers,
|
||||
www_pm_min_spare_servers=www_pm_min_spare_servers,
|
||||
www_pm_max_spare_servers=www_pm_max_spare_servers,
|
||||
www_request_terminate_timeout=www_request_terminate_time,
|
||||
www_xdebug_profiler_enable_trigger=www_xdebug,
|
||||
debug_listen=debug_listen, debug_ping_path=debug_ping_path,
|
||||
debug_pm_status_path=debug_pm_status_path,
|
||||
debug_pm=debug_pm,
|
||||
debug_pm_max_requests=debug_pm_max_requests,
|
||||
debug_pm_max_children=debug_pm_max_children,
|
||||
debug_pm_start_servers=debug_pm_start_servers,
|
||||
debug_pm_min_spare_servers=debug_pm_min_spare_servers,
|
||||
debug_pm_max_spare_servers=debug_pm_max_spare_servers,
|
||||
debug_request_terminate_timeout=debug_request_terminate,
|
||||
debug_xdebug_profiler_enable_trigger=debug_xdebug)
|
||||
self.app.render((data), 'info_php.mustache')
|
||||
|
||||
@expose(hide=True)
|
||||
def info_mysql(self):
|
||||
"""Display MySQL information"""
|
||||
version = os.popen("/usr/bin/mysql -V | awk '{print($5)}' | "
|
||||
"cut -d ',' "
|
||||
"-f1 | tr -d '\n'").read()
|
||||
host = "localhost"
|
||||
port = os.popen("/usr/bin/mysql -e \"show variables\" | "
|
||||
"grep ^port | awk "
|
||||
"'{print($2)}' | tr -d '\n'").read()
|
||||
wait_timeout = os.popen("/usr/bin/mysql -e \"show variables\" | grep "
|
||||
"^wait_timeout | awk '{print($2)}' | "
|
||||
"tr -d '\n'").read()
|
||||
interactive_timeout = os.popen("/usr/bin/mysql -e "
|
||||
"\"show variables\" | grep "
|
||||
"^interactive_timeout | awk "
|
||||
"'{print($2)}' | tr -d '\n'").read()
|
||||
max_used_connections = os.popen("/usr/bin/mysql -e "
|
||||
"\"show global status\" | "
|
||||
"grep Max_used_connections | awk "
|
||||
"'{print($2)}' | tr -d '\n'").read()
|
||||
datadir = os.popen("/usr/bin/mysql -e \"show variables\" | "
|
||||
"grep datadir | awk"
|
||||
" '{print($2)}' | tr -d '\n'").read()
|
||||
socket = os.popen("/usr/bin/mysql -e \"show variables\" | "
|
||||
"grep \"^socket\" | "
|
||||
"awk '{print($2)}' | tr -d '\n'").read()
|
||||
data = dict(version=version, host=host, port=port,
|
||||
wait_timeout=wait_timeout,
|
||||
interactive_timeout=interactive_timeout,
|
||||
max_used_connections=max_used_connections,
|
||||
datadir=datadir, socket=socket)
|
||||
self.app.render((data), 'info_mysql.mustache')
|
||||
|
||||
@expose(hide=True)
|
||||
def default(self):
|
||||
"""default function for info"""
|
||||
if (not self.app.pargs.nginx and not self.app.pargs.php and
|
||||
not self.app.pargs.mysql and not self.app.pargs.php73):
|
||||
self.app.pargs.nginx = True
|
||||
self.app.pargs.php = True
|
||||
self.app.pargs.mysql = True
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
self.app.pargs.php73 = True
|
||||
|
||||
if self.app.pargs.nginx:
|
||||
if (WOAptGet.is_installed(self, 'nginx-custom') or
|
||||
WOAptGet.is_installed(self, 'nginx-wo')):
|
||||
self.info_nginx()
|
||||
else:
|
||||
Log.error(self, "Nginx is not installed")
|
||||
|
||||
if self.app.pargs.php:
|
||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
self.info_php()
|
||||
else:
|
||||
Log.error(self, "PHP 7.2 is not installed")
|
||||
|
||||
if self.app.pargs.php73:
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
self.info_php73()
|
||||
else:
|
||||
Log.error(self, "PHP 7.3 is not installed")
|
||||
|
||||
if self.app.pargs.mysql:
|
||||
if WOShellExec.cmd_exec(self, "mysqladmin ping"):
|
||||
self.info_mysql()
|
||||
else:
|
||||
Log.error(self, "MySQL is not installed")
|
||||
|
||||
|
||||
def load(app):
|
||||
# register the plugin class.. this only happens if the plugin is enabled
|
||||
handler.register(WOInfoController)
|
||||
|
||||
# register a hook (function) to run after arguments are parsed.
|
||||
hook.register('post_argument_parsing', wo_info_hook)
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
"""Maintenance Plugin for WordOps"""
|
||||
|
||||
from cement.core.controller import CementBaseController, expose
|
||||
from cement.core import handler, hook
|
||||
from wo.core.logging import Log
|
||||
from wo.core.variables import WOVariables
|
||||
from wo.core.aptget import WOAptGet
|
||||
from wo.core.apt_repo import WORepo
|
||||
from wo.core.services import WOService
|
||||
from wo.core.shellexec import WOShellExec
|
||||
|
||||
|
||||
def wo_maintenance_hook(app):
|
||||
pass
|
||||
|
||||
|
||||
class WOMaintenanceController(CementBaseController):
|
||||
class Meta:
|
||||
label = 'maintenance'
|
||||
stacked_on = 'base'
|
||||
stacked_type = 'nested'
|
||||
description = ('update server packages to latest version')
|
||||
usage = "wo maintenance"
|
||||
|
||||
@expose(hide=True)
|
||||
def default(self):
|
||||
|
||||
try:
|
||||
Log.info(self, "updating apt-cache, please wait...")
|
||||
WOShellExec.cmd_exec(self, "apt-get update")
|
||||
Log.info(self, "updating packages, please wait...")
|
||||
WOShellExec.cmd_exec(self, "DEBIAN_FRONTEND=noninteractive "
|
||||
"apt-get -o "
|
||||
"Dpkg::Options::='--force-confmiss' "
|
||||
"-o Dpkg::Options::='--force-confold' "
|
||||
"-y dist-upgrade")
|
||||
Log.info(self, "cleaning-up packages, please wait...")
|
||||
WOShellExec.cmd_exec(self, "apt-get -y --purge autoremove")
|
||||
WOShellExec.cmd_exec(self, "apt-get -y autoclean")
|
||||
except OSError as e:
|
||||
Log.debug(self, str(e))
|
||||
Log.error(self, "Package updates failed !")
|
||||
except Exception as e:
|
||||
Log.debug(self, str(e))
|
||||
Log.error(self, "Packages updates failed !")
|
||||
|
||||
|
||||
def load(app):
|
||||
# register the plugin class.. this only happens if the plugin is enabled
|
||||
handler.register(WOMaintenanceController)
|
||||
# register a hook (function) to run after arguments are parsed.
|
||||
hook.register('post_argument_parsing', wo_maintenance_hook)
|
||||
"""Maintenance Plugin for WordOps"""
|
||||
|
||||
from cement.core.controller import CementBaseController, expose
|
||||
from cement.core import handler, hook
|
||||
from wo.core.logging import Log
|
||||
from wo.core.variables import WOVariables
|
||||
from wo.core.aptget import WOAptGet
|
||||
from wo.core.apt_repo import WORepo
|
||||
from wo.core.services import WOService
|
||||
from wo.core.shellexec import WOShellExec
|
||||
|
||||
|
||||
def wo_maintenance_hook(app):
|
||||
pass
|
||||
|
||||
|
||||
class WOMaintenanceController(CementBaseController):
|
||||
class Meta:
|
||||
label = 'maintenance'
|
||||
stacked_on = 'base'
|
||||
stacked_type = 'nested'
|
||||
description = ('update server packages to latest version')
|
||||
usage = "wo maintenance"
|
||||
|
||||
@expose(hide=True)
|
||||
def default(self):
|
||||
|
||||
try:
|
||||
Log.info(self, "updating apt-cache, please wait...")
|
||||
WOShellExec.cmd_exec(self, "apt-get update")
|
||||
Log.info(self, "updating packages, please wait...")
|
||||
WOShellExec.cmd_exec(self, "DEBIAN_FRONTEND=noninteractive "
|
||||
"apt-get -o "
|
||||
"Dpkg::Options::='--force-confmiss' "
|
||||
"-o Dpkg::Options::='--force-confold' "
|
||||
"-y dist-upgrade")
|
||||
Log.info(self, "cleaning-up packages, please wait...")
|
||||
WOShellExec.cmd_exec(self, "apt-get -y --purge autoremove")
|
||||
WOShellExec.cmd_exec(self, "apt-get -y autoclean")
|
||||
except OSError as e:
|
||||
Log.debug(self, str(e))
|
||||
Log.error(self, "Package updates failed !")
|
||||
except Exception as e:
|
||||
Log.debug(self, str(e))
|
||||
Log.error(self, "Packages updates failed !")
|
||||
|
||||
|
||||
def load(app):
|
||||
# register the plugin class.. this only happens if the plugin is enabled
|
||||
handler.register(WOMaintenanceController)
|
||||
# register a hook (function) to run after arguments are parsed.
|
||||
hook.register('post_argument_parsing', wo_maintenance_hook)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -370,7 +370,7 @@ class WOStackController(CementBaseController):
|
||||
|
||||
# php73 conf
|
||||
if not os.path.isfile("/etc/nginx/common/php73.conf"):
|
||||
# data = dict()
|
||||
# data = dict()
|
||||
Log.debug(self, 'Writting the nginx configuration to '
|
||||
'file /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.admin = True
|
||||
self.app.pargs.php73 = True
|
||||
self.app.pargs.redis = True
|
||||
|
||||
if self.app.pargs.web:
|
||||
self.app.pargs.nginx = True
|
||||
|
||||
@@ -38,6 +38,8 @@ class WOStackUpgradeController(CementBaseController):
|
||||
dict(help='Upgrade Redis', action='store_true')),
|
||||
(['--netdata'],
|
||||
dict(help='Upgrade Netdata', action='store_true')),
|
||||
(['--phpmyadmin'],
|
||||
dict(help='Upgrade phpMyAdmin', action='store_true')),
|
||||
(['--no-prompt'],
|
||||
dict(help="Upgrade Packages without any prompt",
|
||||
action='store_true')),
|
||||
@@ -83,7 +85,9 @@ class WOStackUpgradeController(CementBaseController):
|
||||
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.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
|
||||
|
||||
if self.app.pargs.all:
|
||||
@@ -144,6 +148,18 @@ class WOStackUpgradeController(CementBaseController):
|
||||
'kickstart-static64.sh',
|
||||
'/var/lib/wo/tmp/kickstart.sh',
|
||||
'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):
|
||||
|
||||
@@ -190,6 +206,24 @@ class WOStackUpgradeController(CementBaseController):
|
||||
WOShellExec.cmd_exec(self, "/bin/bash /var/lib/wo/tmp/"
|
||||
"kickstart.sh "
|
||||
"--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")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user