6642N/A#! /bin/sh
6642N/A#
6642N/A# OPENDJ SERVICE SCRIPT
6642N/A#
6642N/A
6642N/A#
6642N/A# CDDL HEADER START
6642N/A#
6642N/A# The contents of this file are subject to the terms of the
6642N/A# Common Development and Distribution License, Version 1.0 only
6642N/A# (the "License"). You may not use this file except in compliance
6642N/A# with the License.
6642N/A#
6642N/A# You can obtain a copy of the license at
6642N/A# trunk/opendj3/legal-notices/CDDLv1_0.txt
6642N/A# or http://forgerock.org/license/CDDLv1.0.html.
6642N/A# See the License for the specific language governing permissions
6642N/A# and limitations under the License.
6642N/A#
6642N/A# When distributing Covered Code, include this CDDL HEADER in each
6642N/A# file and include the License file at
6642N/A# trunk/opendj3/legal-notices/CDDLv1_0.txt. If applicable,
6642N/A# add the following below this CDDL HEADER, with the fields enclosed
6642N/A# by brackets "[]" replaced with your own identifying information:
6642N/A# Portions Copyright [yyyy] [name of copyright owner]
6642N/A#
6642N/A# CDDL HEADER END
6642N/A#
6642N/A# Copyright 2013 ForgeRock AS
6642N/A#
6642N/A
6642N/A
6642N/A# chkconfig: 2345 80 05
6642N/A# description: Starts and stops opendj LDAPv3 service.
6642N/A#
6642N/A### BEGIN INIT INFO
6642N/A# Provides: opendj
6642N/A# Required-Start:
6642N/A# Required-Stop:
6642N/A# Default-Start: 2 3 4 5
6642N/A# Default-Stop: 0 1 6
6642N/A# Short-Description: This is the opendj daemon
6642N/A# Description: OpenDJ is an LDAPv3 compliant directory service, developed for the Java
6642N/A# platform, providing a high performance, highly available and secure store
6642N/A# for the identities managed by enterprises. Its easy installation process,
6642N/A# combined with the power of the Java platform makes OpenDJ one of the
6642N/A# simplest and fastest directory servers to deploy and manage.
6642N/A### END INIT INFO
6642N/A
6642N/A# Set up source function library depending on the distribution
6642N/Aif [ -f /etc/redhat-release ]
6642N/Athen
6642N/A # Redhat
6642N/A . /etc/init.d/functions
6642N/Aelif [ -f /etc/SuSE-release ]
6642N/Athen
6642N/A # SuSE
6642N/A . /etc/rc.status
6642N/Aelif [ -f /etc/lsb-release ]
6642N/Athen
6642N/A # Debian
6642N/A . /lib/lsb/init-functions
6642N/Aelse
6642N/A # Other dist.
6642N/A if [ -f /etc/init.d/functions.sh ]
6642N/A then
6642N/A . /etc/init.d/functions.sh
6642N/A fi
6642N/Afi
6642N/A
6642N/A
6642N/A# Sets the script vars
6642N/AINSTALL_ROOT="/opt/opendj/"
6642N/Aexport INSTALL_ROOT
6642N/ADAEMON=opendj
6642N/A# Original PID file
6642N/AORIGINPIDFILE=/opt/opendj/logs/server.pid
6642N/A# Pid file is a symlink to /opt/opendj/log/server.pid
6642N/APIDFILE=/var/run/opendj.pid
6642N/ARETVAL=0
6642N/A
6642N/A# If the daemon is not there, then exit / LSB return code.
6642N/Atest -x "$INSTALL_ROOT/bin/start-ds" || exit 5
6642N/A
6642N/A# /var/run is deleted after reboot (eg. debian)
6642N/A# recreates the symlink if needed.
6642N/Atest -h "$PIDFILE" || ln -s $ORIGINPIDFILE $PIDFILE
6642N/A
6642N/A#Starts the server and creates pid file.
6642N/Astart() {
6642N/A echo -n $"Starting $DAEMON: "
6642N/A # Server is running
6642N/A if [ -e $PIDFILE ]
6642N/A then
6642N/A echo "> Already running."
6642N/A return 0
6642N/A else
6642N/A "$INSTALL_ROOT"/bin/start-ds --quiet
6642N/A RETVAL=$?
6642N/A if [ $RETVAL = 0 ]
6642N/A then
6642N/A echo "> SUCCESS."
6642N/A else
6642N/A echo "> FAILURE."
6642N/A fi
6642N/A echo ""
6642N/A return $RETVAL
6642N/A fi
6642N/A}
6642N/A
6642N/A#Stops the server and removes pid file.
6642N/Astop() {
6642N/A echo -n $"Stopping $DAEMON: "
6642N/A # Server is running
6642N/A if [ -e $PIDFILE ]
6642N/A then
6642N/A "$INSTALL_ROOT"/bin/stop-ds --quiet
6642N/A RETVAL=$?
6642N/A if [ $RETVAL = 0 ]
6642N/A then
6642N/A echo "> SUCCESS."
6642N/A else
6642N/A echo "> FAILURE."
6642N/A fi
6642N/A echo ""
6642N/A return $RETVAL
6642N/A else
6642N/A echo "> Already stopped."
6642N/A echo ""
6642N/A return 3
6642N/A fi
6642N/A}
6642N/A
6642N/A# Displays the service status
6642N/Astatus() {
6642N/A echo -n $"$DAEMON status: "
6642N/A if [ -e $PIDFILE ]
6642N/A then
6642N/A echo "> Running."
6642N/A return 0
6642N/A else
6642N/A echo "> Stopped."
6642N/A return 3
6642N/A fi
6642N/A}
6642N/A
6642N/Acase "$1" in
6642N/A start)
6642N/A start
6642N/A ;;
6642N/A stop)
6642N/A stop
6642N/A ;;
6642N/A restart)
6642N/A stop
6642N/A sleep 5
6642N/A start
6642N/A ;;
6642N/A force-reload)
6642N/A # Not implemented.
6642N/A ;;
6642N/A status)
6642N/A status
6642N/A ;;
6642N/A *)
6642N/A echo $"Usage: /etc/init.d/$DAEMON {start|restart|stop|force-reload|status}"
6642N/A exit 1
6642N/A ;;
6642N/Aesac
6642N/A
6642N/Aexit $RETVAL