mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
11.30.2015 0f164790d80dc48ccd1d779307ef88d8dceb4844
OPENDJ-1772: Code cleanup in opendj sysv service file
1 files modified
42 ■■■■■ changed files
opendj-server-legacy/resource/sysv/opendj 42 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/resource/sysv/opendj
@@ -26,7 +26,7 @@
#
# CDDL HEADER END
#
#      Copyright 2013 ForgeRock AS
#      Copyright 2013-2015 ForgeRock AS
#
@@ -48,33 +48,29 @@
### END INIT INFO
# Set up source function library depending on the distribution
if [ -f /etc/redhat-release ]
then
if [ -f /etc/redhat-release ] ; then
    # Redhat
    . /etc/init.d/functions
elif [ -f /etc/SuSE-release ]
then
elif [ -f /etc/SuSE-release ] ; then
    # SuSE
    . /etc/rc.status
elif [ -f /etc/lsb-release ]
then
elif [ -f /etc/lsb-release ] ; then
    # Debian
    . /lib/lsb/init-functions
else
elif [ -f /etc/init.d/functions.sh ] ; then
    # Other dist.
    if [ -f /etc/init.d/functions.sh ]
    then
        . /etc/init.d/functions.sh
    fi
fi
# Sets the script vars
INSTALL_ROOT="/opt/opendj/"
export INSTALL_ROOT
DAEMON=opendj
# Original PID file
ORIGINPIDFILE=/opt/opendj/logs/server.pid
# Pid file is a symlink to /opt/opendj/log/server.pid
PIDFILE=/var/run/opendj.pid
RETVAL=0
@@ -82,23 +78,20 @@
# If the daemon is not there, then exit / LSB return code.
test -x "$INSTALL_ROOT/bin/start-ds" || exit 5
# /var/run is deleted after reboot (eg. debian)
# recreates the symlink if needed.
# Recreates the symlink if needed (/var/run is deleted after reboot (eg. debian)).
test -h "$PIDFILE" || ln -s $ORIGINPIDFILE $PIDFILE
#Starts the server and creates pid file.
start() {
    echo -n $"Starting $DAEMON: "
    echo -n "Starting $DAEMON: "
    # Server is running
    if [ -e $PIDFILE ]
    then
    if [ -e $PIDFILE ] ; then
        echo "> Already running."
        return 0
    else 
        "$INSTALL_ROOT"/bin/start-ds --quiet
        RETVAL=$?
        if [ $RETVAL = 0 ]
        then
        if [ $RETVAL = 0 ] ; then
            echo "> SUCCESS."
        else
            echo "> FAILURE."
@@ -110,14 +103,13 @@
#Stops the server and removes pid file.
stop() {
    echo -n $"Stopping $DAEMON: "
    # Server is running
    echo -n "Stopping $DAEMON: "
    if [ -e $PIDFILE ]
    then
        # Server is running
        "$INSTALL_ROOT"/bin/stop-ds --quiet
        RETVAL=$?
        if [ $RETVAL = 0 ]
        then
        if [ $RETVAL = 0 ] ; then
            echo "> SUCCESS."
        else
            echo "> FAILURE."
@@ -134,8 +126,7 @@
# Displays the service status
status() {
    echo -n $"$DAEMON status: "
    if [ -e $PIDFILE ]
    then
    if [ -e $PIDFILE ] ; then
        echo "> Running."
        return 0
    else             
@@ -158,12 +149,13 @@
    ;;
    force-reload)
        # Not implemented.
        echo "Not implemented."
    ;;
    status)
        status
    ;;
    *)
        echo $"Usage: /etc/init.d/$DAEMON {start|restart|stop|force-reload|status}"
        echo "Usage: /etc/init.d/$DAEMON {start|restart|stop|force-reload|status}"
        exit 1
    ;;
esac