Package: nginx-common
Severity: normal
Tags: patch
Attached is a patch to make the init script show a fail message when
test_nginx_config fails:
# /etc/init.d/nginx reload
[FAIL] Reloading nginx configuration: nginx failed!
The init script only returned a status code when testing the nginx
configuration failed. No failure message at all. Therefor run test_nginx_config
after calling log_daemon_msg.
From 456a73f4d2fb4d51f2ce091f6b81df60b8e6a086 Mon Sep 17 00:00:00 2001
From: Pim van den Berg pim.van.den.b...@mendix.com
Date: Mon, 28 Oct 2013 12:23:11 +0100
Subject: [PATCH] initscript: show a proper message when test_nginx_config
fails
The init script only returned a status code when testing the nginx
configuration failed. No failure message at all. Therefor run test_nginx_config
after calling log_daemon_msg.
Because of the set -e the init script return 1 immediately after executing
$DAEMON -t $DAEMON_OPTS. It didn't even get to the exit $retvar.
---
debian/nginx-common.nginx.init | 16
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/debian/nginx-common.nginx.init b/debian/nginx-common.nginx.init
index c8a8887..d269632 100644
--- a/debian/nginx-common.nginx.init
+++ b/debian/nginx-common.nginx.init
@@ -39,12 +39,16 @@ if [ -n $ULIMIT ]; then
fi
test_nginx_config() {
+ set +e
$DAEMON -t $DAEMON_OPTS /dev/null 21
retvar=$?
+
if [ $retvar -ne 0 ]
then
+ log_end_msg $retvar
exit $retvar
fi
+ set -e
}
start() {
@@ -59,8 +63,8 @@ stop() {
case $1 in
start)
- test_nginx_config
log_daemon_msg Starting $DESC $NAME
+ test_nginx_config
start
log_end_msg $?
;;
@@ -72,8 +76,8 @@ case $1 in
;;
restart|force-reload)
- test_nginx_config
log_daemon_msg Restarting $DESC $NAME
+ test_nginx_config
stop
sleep 1
start
@@ -81,8 +85,8 @@ case $1 in
;;
reload)
- test_nginx_config
log_daemon_msg Reloading $DESC configuration $NAME
+ test_nginx_config
start-stop-daemon --stop --signal HUP --quiet --pidfile $PID \
--oknodo --exec $DAEMON
log_end_msg $?
@@ -90,11 +94,7 @@ case $1 in
configtest|testconfig)
log_daemon_msg Testing $DESC configuration
- if test_nginx_config; then
- log_daemon_msg $NAME
- else
- exit $?
- fi
+ test_nginx_config
log_end_msg $?
;;
--
1.7.10.4