From 4a63950c8d692c1b3e7945b21030482ff258d2bd Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Thu, 2 Jan 2025 15:28:02 -0800 Subject: [PATCH] Respect custom configuration file locations This allows administrator to redefine a custom location for a configuration file to be used during upgrade and startup. References: https://github.com/nginx/pkg-oss/issues/24 --- debian/debian/nginx-debug.default | 5 ++++- debian/debian/nginx-debug.service | 4 +++- debian/debian/nginx.default | 5 ++++- debian/debian/nginx.service | 4 +++- rpm/SOURCES/nginx-debug.service | 4 +++- rpm/SOURCES/nginx.service | 4 +++- rpm/SOURCES/nginx.upgrade.sh | 2 +- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/debian/debian/nginx-debug.default b/debian/debian/nginx-debug.default index c514ef76..25eb7c9d 100644 --- a/debian/debian/nginx-debug.default +++ b/debian/debian/nginx-debug.default @@ -1,8 +1,11 @@ -# Defaults for nginx initscript +# Defaults for nginx-debug # sourced by /etc/init.d/nginx-debug +# included by nginx-debug systemd service NAME="nginx-debug" DESC="nginx-debug" DAEMON="/usr/sbin/nginx-debug" # Additional options that are passed to nginx DAEMON_OPTS="" + +# CONFFILE="/etc/nginx/nginx.conf" diff --git a/debian/debian/nginx-debug.service b/debian/debian/nginx-debug.service index 5ae4759a..d3f10b13 100644 --- a/debian/debian/nginx-debug.service +++ b/debian/debian/nginx-debug.service @@ -7,7 +7,9 @@ Wants=network-online.target [Service] Type=forking PIDFile=/var/run/nginx.pid -ExecStart=/usr/sbin/nginx-debug -c /etc/nginx/nginx.conf +Environment="CONFFILE=/etc/nginx/nginx.conf" +EnvironmentFile=-/etc/default/nginx-debug +ExecStart=/usr/sbin/nginx-debug -c ${CONFFILE} ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)" ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)" diff --git a/debian/debian/nginx.default b/debian/debian/nginx.default index cadb439b..d3efe511 100644 --- a/debian/debian/nginx.default +++ b/debian/debian/nginx.default @@ -1,5 +1,8 @@ -# Defaults for nginx initscript +# Defaults for nginx # sourced by /etc/init.d/nginx +# included by nginx systemd service # Additional options that are passed to nginx DAEMON_ARGS="" + +# CONFFILE="/etc/nginx/nginx.conf" diff --git a/debian/debian/nginx.service b/debian/debian/nginx.service index 833aa455..ec737969 100644 --- a/debian/debian/nginx.service +++ b/debian/debian/nginx.service @@ -7,7 +7,9 @@ Wants=network-online.target [Service] Type=forking PIDFile=/var/run/nginx.pid -ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf +Environment="CONFFILE=/etc/nginx/nginx.conf" +EnvironmentFile=-/etc/default/nginx +ExecStart=/usr/sbin/nginx -c ${CONFFILE} ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)" ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)" diff --git a/rpm/SOURCES/nginx-debug.service b/rpm/SOURCES/nginx-debug.service index af0bba40..825dca53 100644 --- a/rpm/SOURCES/nginx-debug.service +++ b/rpm/SOURCES/nginx-debug.service @@ -7,7 +7,9 @@ Wants=network-online.target [Service] Type=forking PIDFile=/var/run/nginx.pid -ExecStart=/usr/sbin/nginx-debug -c /etc/nginx/nginx.conf +Environment="conffile=/etc/nginx/nginx.conf" +EnvironmentFile=-/etc/sysconfig/nginx +ExecStart=/usr/sbin/nginx-debug -c ${conffile} ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)" ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)" diff --git a/rpm/SOURCES/nginx.service b/rpm/SOURCES/nginx.service index e509a2ee..c426d532 100644 --- a/rpm/SOURCES/nginx.service +++ b/rpm/SOURCES/nginx.service @@ -7,7 +7,9 @@ Wants=network-online.target [Service] Type=forking PIDFile=/var/run/nginx.pid -ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf +Environment="conffile=/etc/nginx/nginx.conf" +EnvironmentFile=-/etc/sysconfig/nginx +ExecStart=/usr/sbin/nginx -c ${conffile} ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)" ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)" diff --git a/rpm/SOURCES/nginx.upgrade.sh b/rpm/SOURCES/nginx.upgrade.sh index 25f5c22a..7a881c60 100644 --- a/rpm/SOURCES/nginx.upgrade.sh +++ b/rpm/SOURCES/nginx.upgrade.sh @@ -8,7 +8,7 @@ fi prog=nginx nginx=/usr/sbin/nginx -conffile=/etc/nginx/nginx.conf +conffile=${conffile:-/etc/nginx/nginx.conf} pidfile=`/usr/bin/systemctl show -p PIDFile nginx.service | sed 's/^PIDFile=//' | tr ' ' '\n'` SLEEPSEC=${SLEEPSEC:-1} UPGRADEWAITLOOPS=${UPGRADEWAITLOOPS:-5}