www/nginx: migrate to NAME_setup use

Restructure the call flow a bit and extract fpm-related bits.

NAME_reload doesn't support NAME_setup in 2.7.2 but soon it will,
which makes it more useful than NAME_prepend.  ;)

PR: https://github.com/opnsense/core/issues/5917
This commit is contained in:
Franco Fichtner
2022-08-19 08:05:22 +02:00
parent c67637014e
commit 9f80395a3b
5 changed files with 14 additions and 16 deletions
+1
View File
@@ -1,5 +1,6 @@
PLUGIN_NAME= nginx
PLUGIN_VERSION= 1.29
PLUGIN_REVISION= 1
PLUGIN_COMMENT= Nginx HTTP server and reverse proxy
PLUGIN_DEPENDS= nginx
PLUGIN_MAINTAINER= franz.fabian.94@gmail.com
@@ -41,7 +41,7 @@ class M1_24_0 extends BaseModelMigration
{
$cfgObj = Config::getInstance()->object();
$ports = array();
foreach ($cfgObj->OPNsense->Nginx->http_server as $cfg_http_server) {
foreach ($cfgObj->OPNsense->Nginx->http_server ?? [] as $cfg_http_server) {
$uuid = (string)$cfg_http_server->attributes()['uuid'];
$ports['http_port'] = (isset($cfg_http_server->listen_http_port) && $cfg_http_server->listen_http_port != '') ? $cfg_http_server->listen_http_port : null;
$ports['https_port'] = (isset($cfg_http_server->listen_https_port) && $cfg_http_server->listen_https_port != '') ? $cfg_http_server->listen_https_port : null;
@@ -49,7 +49,7 @@ class M1_24_0 extends BaseModelMigration
$http_server->listen_http_address = (isset($ports['http_port'])) ? $ports['http_port'] . ',[::]:' . $ports['http_port'] : null;
$http_server->listen_https_address = (isset($ports['https_port'])) ? $ports['https_port'] . ',[::]:' . $ports['https_port'] : null;
}
foreach ($cfgObj->OPNsense->Nginx->stream_server as $cfg_stream_server) {
foreach ($cfgObj->OPNsense->Nginx->stream_server ?? [] as $cfg_stream_server) {
$uuid = (string)$cfg_stream_server->attributes()['uuid'];
$port = (isset($cfg_stream_server->listen_port) && $cfg_stream_server->listen_port != '') ? $cfg_stream_server->listen_port : null;
$server = $model->getNodeByReference('stream_server.' . $uuid);
@@ -318,3 +318,5 @@ file_put_contents(
empty($tls_fingerprint_database) ? '{}' : json_encode($tls_fingerprint_database)
);
chmod('/usr/local/etc/nginx/tls_fingerprints.json', 0644);
passthru('/usr/local/etc/rc.d/php-fpm start');
@@ -1,5 +1,5 @@
[start]
command:/usr/local/opnsense/scripts/nginx/setup.php;/usr/local/etc/rc.d/php-fpm start;/usr/local/etc/rc.d/nginx start
command:/usr/local/etc/rc.d/nginx start
parameters:
type:script
message:starting nginx
@@ -11,18 +11,19 @@ type:script
message:stopping nginx
[restart]
command:/usr/local/opnsense/scripts/nginx/setup.php;/usr/local/etc/rc.d/php-fpm restart;/usr/local/etc/rc.d/nginx restart
command:/usr/local/etc/rc.d/nginx restart
parameters:
type:script
message:restarting nginx
[status]
command:/usr/local/etc/rc.d/nginx status;exit 0
[reload]
command:/usr/local/etc/rc.d/nginx reload
parameters:
type:script_output
type:script
message:reloading nginx
[phpstatus]
command:/usr/local/etc/rc.d/php-fpm status; exit 0
[status]
command:/usr/local/etc/rc.d/nginx status; exit 0
parameters:
type:script_output
@@ -66,9 +67,3 @@ type:script
command:/usr/local/opnsense/scripts/nginx/vts.php
parameters:
type:script_output
[reload]
command:/usr/local/opnsense/scripts/nginx/setup.php;/usr/local/etc/rc.d/php-fpm restart;/usr/local/etc/rc.d/nginx reload
parameters:
type:script_output
message:reloading nginx
@@ -1,2 +1,2 @@
nginx_setup="/usr/local/opnsense/scripts/nginx/setup.php"
nginx_enable="YES"
nginx_var_script="/usr/local/opnsense/scripts/nginx/setup.php"