Improve wo info

This commit is contained in:
VirtuBox
2024-06-01 12:00:22 +02:00
parent 960758c485
commit 92023c09db

View File

@@ -69,89 +69,38 @@ class WOInfoController(CementBaseController):
@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 | " pargs = self.app.pargs
"head -n1 | cut -d' ' -f2 |" if WOAptGet.is_installed(self, 'php7.4-fpm'):
" cut -d'+' -f1 | tr -d '\n'").read pargs.php74 = True
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']
if os.path.exists('/etc/php/7.2/fpm/pool.d/www.conf'):
config.read('/etc/php/7.2/fpm/pool.d/www.conf')
else: else:
Log.error(self, 'php-fpm pool config not found') Log.info(self, "PHP 7.4 is not installed")
if config.has_section('www'): if WOAptGet.is_installed(self, 'php8.0-fpm'):
wconfig = config['www'] pargs.php80 = True
elif config.has_section('www-php72'):
wconfig = config['www-php72']
else: else:
Log.error(self, 'Unable to parse configuration') Log.info(self, "PHP 8.0 is not installed")
www_listen = wconfig['listen'] if WOAptGet.is_installed(self, 'php8.1-fpm'):
www_ping_path = wconfig['ping.path'] pargs.php81 = True
www_pm_status_path = wconfig['pm.status_path'] else:
www_pm = wconfig['pm'] Log.info(self, "PHP 8.1 is not installed")
www_pm_max_requests = wconfig['pm.max_requests'] if WOAptGet.is_installed(self, 'php8.2-fpm'):
www_pm_max_children = wconfig['pm.max_children'] pargs.php82 = True
www_pm_start_servers = wconfig['pm.start_servers'] else:
www_pm_min_spare_servers = wconfig['pm.min_spare_servers'] Log.info(self, "PHP 8.2 is not installed")
www_pm_max_spare_servers = wconfig['pm.max_spare_servers'] if WOAptGet.is_installed(self, 'php8.3-fpm'):
www_request_terminate_time = (wconfig pargs.php83 = True
['request_terminate_timeout']) else:
try: Log.info(self, "PHP 8.3 is not installed")
www_xdebug = (
wconfig['php_admin_flag[xdebug.profiler_enable'
'_trigger]'])
except Exception as e:
Log.debug(self, "{0}".format(e))
www_xdebug = 'off'
config.read('/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2")) if pargs.php74:
debug_listen = config['debug']['listen'] self.info_php74()
debug_ping_path = config['debug']['ping.path'] if pargs.php80:
debug_pm_status_path = config['debug']['pm.status_path'] self.info_php80()
debug_pm = config['debug']['pm'] if pargs.php81:
debug_pm_max_requests = config['debug']['pm.max_requests'] self.info_php81()
debug_pm_max_children = config['debug']['pm.max_children'] if pargs.php82:
debug_pm_start_servers = config['debug']['pm.start_servers'] self.info_php82()
debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers'] if pargs.php83:
debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers'] self.info_php83()
debug_request_terminate = (config['debug']
['request_terminate_timeout'])
try:
debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_'
'enable_trigger]'])
except Exception as e:
Log.debug(self, "{0}".format(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) @expose(hide=True)
def info_php74(self): def info_php74(self):
@@ -631,16 +580,7 @@ class WOInfoController(CementBaseController):
not pargs.php81 and not pargs.php82 and not pargs.php83): not pargs.php81 and not pargs.php82 and not pargs.php83):
pargs.nginx = True pargs.nginx = True
pargs.mysql = True pargs.mysql = True
if WOAptGet.is_installed(self, 'php7.4-fpm'): pargs.php = True
pargs.php74 = True
if WOAptGet.is_installed(self, 'php8.0-fpm'):
pargs.php80 = True
if WOAptGet.is_installed(self, 'php8.1-fpm'):
pargs.php81 = True
if WOAptGet.is_installed(self, 'php8.2-fpm'):
pargs.php82 = True
if WOAptGet.is_installed(self, 'php8.3-fpm'):
pargs.php83 = True
if pargs.nginx: if pargs.nginx:
if ((not WOAptGet.is_installed(self, 'nginx-custom')) and if ((not WOAptGet.is_installed(self, 'nginx-custom')) and
@@ -649,35 +589,8 @@ class WOInfoController(CementBaseController):
else: else:
self.info_nginx() self.info_nginx()
if pargs.php74: if pargs.php:
if WOAptGet.is_installed(self, 'php7.4-fpm'): self.info_php()
self.info_php74()
else:
Log.info(self, "PHP 7.4 is not installed")
if pargs.php80:
if WOAptGet.is_installed(self, 'php8.0-fpm'):
self.info_php80()
else:
Log.info(self, "PHP 8.0 is not installed")
if pargs.php81:
if WOAptGet.is_installed(self, 'php8.1-fpm'):
self.info_php81()
else:
Log.info(self, "PHP 8.1 is not installed")
if pargs.php82:
if WOAptGet.is_installed(self, 'php8.2-fpm'):
self.info_php82()
else:
Log.info(self, "PHP 8.2 is not installed")
if pargs.php83:
if WOAptGet.is_installed(self, 'php8.3-fpm'):
self.info_php83()
else:
Log.info(self, "PHP 8.3 is not installed")
if pargs.mysql: if pargs.mysql:
if WOShellExec.cmd_exec(self, "/usr/bin/mysqladmin ping"): if WOShellExec.cmd_exec(self, "/usr/bin/mysqladmin ping"):