wrappers/initscript.in | 36 +++++++++++++++++++++++++++++++-----
wrappers/ldap-agent-initscript.in | 20 +++++++++++++++++---
2 files changed, 48 insertions(+), 8 deletions(-)
New commits:
commit 5a41728cf75eea021b73b166aea12a00f39eebd8
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Tue Feb 1 15:00:40 2011 -0800
Bug 668862 - init scripts return wrong error code
The dirsrv init script returns an exit code of 0 when no instances
are configured or if an invalid instance name is specified. This
patch makes the dirsrv init script return the proper exit codes.
The exit codes for the status action are different than the codes
for non-status actions per the Fedora SysV init script packaging
guidelines.
In addition, the dirsrv and dirsrv-snmp inistscripts need to return
a non-0 exit code when networking is disabled or if the binaries
do not exist. This patch handles those cases as well.
diff --git a/wrappers/initscript.in b/wrappers/initscript.in
index 65874d6..147b2d6 100644
--- a/wrappers/initscript.in
+++ b/wrappers/initscript.in
@@ -23,7 +23,13 @@ fi
if [ "${NETWORKING}" = "no" ]
then
echo "Networking is down"
- exit 0
+ if [ "$1" = "status" ]; then
+ # exit code 4 means unknown status for status action
+ exit 4
+ else
+ # exit code 1 means unspecified error for non-status actions
+ exit 1
+ fi
fi
# figure out which echo we're using
@@ -87,8 +93,16 @@ piddir="@localstatedir@/run/@package_name@"
# Instance basedir
instbase="@instconfigdir@"
-
-[ -f $exec ] || exit 0
+# Check that ns-slapd exists
+if [ ! -f $exec ] ; then
+ if [ "$1" = "status" ]; then
+ # exit code 4 means unknown status for status action
+ exit 4
+ else
+ # exit code 5 means program is not installed for non-status actions
+ exit 5
+ fi
+fi
umask 077
@@ -107,7 +121,13 @@ done
if [ -z "$INSTANCES" ]; then
echo " *** Error: no $prog instances configured"
- exit 0
+ if [ "$1" = "status" ]; then
+ # exit code 4 means unknown status for status action
+ exit 4
+ else
+ # exit code 6 means program is not configured for non-status actions
+ exit 6
+ fi
fi
if [ -n "$2" ]; then
@@ -119,7 +139,13 @@ if [ -n "$2" ]; then
if [ "$2" != "$INSTANCES" ]; then
echo_n "$2 is an invalid @package_name@ instance"
failure; echo
- exit 1
+ if [ "$1" = "status" ]; then
+ # exit code 4 means unknown status for status action
+ exit 4
+ else
+ # exit code 2 means invalid argument for non-status actions
+ exit 2
+ fi
fi
fi
diff --git a/wrappers/ldap-agent-initscript.in b/wrappers/ldap-agent-initscript.in
index d4e791f..dd8ee97 100644
--- a/wrappers/ldap-agent-initscript.in
+++ b/wrappers/ldap-agent-initscript.in
@@ -22,7 +22,13 @@ fi
if [ "${NETWORKING}" = "no" ]
then
echo "Networking is down"
- exit 0
+ if [ "$1" = "status" ]; then
+ # exit code 4 means unknown status for status action
+ exit 4
+ else
+ # exit code 1 means unspecified error for non-status actions
+ exit 1
+ fi
fi
# figure out which echo we're using
@@ -61,8 +67,16 @@ pidfile="@localstatedir(a)/run/ldap-agent.pid"
configfile="@sysconfdir@/@package_name(a)/config/ldap-agent.conf"
-
-[ -f $exec ] || exit 0
+# Check if ldap-agent exists
+if [ ! -f $exec ]; then
+ if [ "$1" = "status" ]; then
+ # exit code 4 means unknown status for status action
+ exit 4
+ else
+ # exit code 5 means program is not installed for non-status actions
+ exit 5
+ fi
+fi
umask 077
Show replies by date