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