fixing up init script exit codes

This commit is contained in:
Haneysmith, Nathan 2015-06-04 11:01:04 -07:00
parent 5ca8d590bd
commit 77215182f7
2 changed files with 21 additions and 12 deletions

View File

@ -38,7 +38,12 @@ DAEMON=/usr/sbin/$NAME
if [ `id -u` -ne 0 ]; then
echo "You need root privileges to run this script"
exit 1
exit 4
fi
if [ ! -x $DAEMON ]; then
echo "Program not installed or not executable"
exit 5
fi
. /lib/lsb/init-functions
@ -54,9 +59,6 @@ fi
DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR}"
# Check DAEMON exists
test -x $DAEMON || exit 0
case "$1" in
start)
@ -137,7 +139,7 @@ case "$1" in
;;
*)
log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
exit 3
;;
esac

View File

@ -35,6 +35,16 @@ MAX_OPEN_FILES=10000
PID_FILE=/var/run/$NAME.pid
DAEMON=/usr/sbin/$NAME
if [ `id -u` -ne 0 ]; then
echo "You need root privileges to run this script"
exit 4
fi
if [ ! -x $DAEMON ]; then
echo "Program not installed or not executable"
exit 5
fi
#
# init.d / servicectl compatibility (openSUSE)
#
@ -55,9 +65,6 @@ fi
DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR}"
# Check DAEMON exists
test -x $DAEMON || exit 0
function isRunning() {
status -p $PID_FILE $NAME > /dev/null 2>&1
}
@ -69,7 +76,7 @@ case "$1" in
isRunning
if [ $? -eq 0 ]; then
echo "Already running."
exit 2
exit 0
fi
# Prepare environment
@ -90,7 +97,7 @@ case "$1" in
# check if pid file has been written two
if ! [[ -s $PID_FILE ]]; then
echo "FAILED"
exit 3
exit 1
fi
i=0
timeout=10
@ -101,7 +108,7 @@ case "$1" in
i=$(($i + 1))
if [ $i -gt $timeout ]; then
echo "FAILED"
exit 4
exit 1
fi
done
fi
@ -141,6 +148,6 @@ case "$1" in
;;
*)
echo -n "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
exit 3
;;
esac