#!/bin/sh # # fedora-ds This script takes care of starting and stopping # the Fedora Directory Server, an LDAP server. # # chkconfig: - 27 73 # description: LDAP stands for Lightweight Directory Access Protocol, used \ # for implementing the industry standard directory services. # Set this to the instance name this init script should start. instance="ldap" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 title="slapd-$instance" instance_path="/opt/fedora-ds/slapd-$instance" lockfile=/var/lock/subsys/fedora-ds-$instance start() { action $"Starting $title: " "$instance_path/start-slapd" retval=$? [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { action $"Stopping $title: " "$instance_path/stop-slapd" retval=$? [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { stop [ $? -eq 0 ] && start } reload() { restart } force_reload() { restart } fdr_status() { # This is all copied from /etc/init.d/functions' status(), with a # few parts changed to take into account the fact that there's no # unique command name associated with a particular FDS instance. local pid pid_file pid_file="$instance_path/logs/pid" if [ -f "$pid_file" ] ; then read pid < "$pid_file" if [ -e "/proc/$pid" ]; then echo $"${title} (pid $pid) is running..." return 0 elif [ -n "$pid" ]; then echo $"${title} dead but pid file exists" return 1 fi fi # See if the lockfile exists if [ -f "$lockfile" ]; then echo $"${title} dead but subsys locked" return 2 fi echo $"${title} is stopped" return 3 } case "$1" in start|stop|restart|reload) $1 ;; force-reload) force_reload ;; status) fdr_status ;; condrestart|try-restart) [ ! -f $lockfile ] || restart ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}" exit 2 esac