diff options
author | Christian Marangi <ansuelsmth@gmail.com> | 2023-06-11 04:29:54 +0200 |
---|---|---|
committer | Christian Marangi <ansuelsmth@gmail.com> | 2023-06-11 04:36:12 +0200 |
commit | add3cbfcd3dfb1ce64d5d6f67a831c6410b99776 (patch) | |
tree | 5f054f17d9ef5b5c6a03554495376bdaa7dd9b8e /net | |
parent | 15271cb46794f79681b993ffe719400d02c71d3b (diff) |
nginx: fix problem with migration of uci conf template
Fix some problem with migration of uci conf template and include of
module.d directive.
Fix 2 case:
- uci.conf.template not versioned but with the include module.d
resulting in double include module.d
- uci.conf.template version 1.1 with the include module.d at the end
of the config. This is problematic for nginx as modules must be
included before any http directive.
Handle this 2 case to restore a working uci.conf.template configuration
on migrated config.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/nginx/Makefile | 2 | ||||
-rw-r--r-- | net/nginx/files/nginx.init | 21 |
2 files changed, 19 insertions, 4 deletions
diff --git a/net/nginx/Makefile b/net/nginx/Makefile index 061d82346..162c19565 100644 --- a/net/nginx/Makefile +++ b/net/nginx/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=nginx PKG_VERSION:=1.24.0 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=nginx-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://nginx.org/download/ diff --git a/net/nginx/files/nginx.init b/net/nginx/files/nginx.init index 9e3ed0a7a..c84e0496c 100644 --- a/net/nginx/files/nginx.init +++ b/net/nginx/files/nginx.init @@ -9,7 +9,7 @@ G_OPTS="daemon off;" NGINX_UTIL="/usr/bin/nginx-util" UCI_CONF_TEMPLATE="/etc/nginx/uci.conf.template" -LATEST_UCI_CONF_VERSION="1.1" +LATEST_UCI_CONF_VERSION="1.2" eval $("${NGINX_UTIL}" get_env) @@ -23,10 +23,25 @@ nginx_check_luci_template() { return fi + # Fix wrong entry for the module.d include + if [ "$UCI_CONF_VERSION" = "1.1" ]; then + # Remove any entry + sed -i '/^include module\.d\/\*\.module;/d' $UCI_CONF_TEMPLATE + # Put the include before events {} + sed -i 's/events {/include module.d\/*.module;\n\nevents {/' $UCI_CONF_TEMPLATE + fi + + if [ "$UCI_CONF_VERSION" != "$LATEST_UCI_CONF_VERSION" ]; then + sed -i "s/# UCI_CONF_VERSION=.*/# UCI_CONF_VERSION=$LATEST_UCI_CONF_VERSION/" $UCI_CONF_TEMPLATE + fi + if [ -z "$UCI_CONF_VERSION" ]; then + # Handle funny case with template with the include module but no version + if ! grep -q -e '^include module\.d/\*\.module;$' $UCI_CONF_TEMPLATE; then + sed -i 's/events {/include module.d\/*.module;\n\nevents {/' $UCI_CONF_TEMPLATE + fi echo "" >> $UCI_CONF_TEMPLATE - echo "include module.d/*.module;" >> $UCI_CONF_TEMPLATE - echo "# UCI_CONF_VERSION=1.1" >> $UCI_CONF_TEMPLATE + echo "# UCI_CONF_VERSION=1.2" >> $UCI_CONF_TEMPLATE fi } |