diff options
| author | Nathan Kinder <nkinder@redhat.com> | 2009-08-14 08:28:01 -0700 |
|---|---|---|
| committer | Nathan Kinder <nkinder@redhat.com> | 2009-08-14 08:28:01 -0700 |
| commit | 1cc186ad31449aebff4fa220bff7c90a45472fcd (patch) | |
| tree | f96ddf1eaf1455dd8c210a7d81153d0286a2704b /ldap/admin/src/scripts/stop-dirsrv.in | |
| parent | 20d6a63f0a776f0726a24fdcddf94399b9d880b1 (diff) | |
| download | ds-1cc186ad31449aebff4fa220bff7c90a45472fcd.tar.gz ds-1cc186ad31449aebff4fa220bff7c90a45472fcd.tar.xz ds-1cc186ad31449aebff4fa220bff7c90a45472fcd.zip | |
Add centralized start/stop/restart scipts.
This adds centralized start, stop, and restart scripts
for ns-slapd. These scripts live in the sbin directory
and will act upon all instances if an instance identifier
is not specified (similar to the init script). The
instance specific scripts have been modified to call the
new centralized scripts.
The instance specific parameters needed by the new scripts
are located in the instance specific initconfig scripts,
which are now created by setup-ds.pl with values mapped
from the inf file.
Diffstat (limited to 'ldap/admin/src/scripts/stop-dirsrv.in')
| -rwxr-xr-x | ldap/admin/src/scripts/stop-dirsrv.in | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in new file mode 100755 index 00000000..8ba8d5df --- /dev/null +++ b/ldap/admin/src/scripts/stop-dirsrv.in @@ -0,0 +1,72 @@ +#!/bin/sh + +# Script that stops the ns-slapd server. +# Exit status can be: +# 0: Server stopped successfully +# 1: Server could not be stopped +# 2: Server was not running + +stop_instance() { + SERV_ID=$1 + + # source env. for this instance + if [ -f @initconfigdir@/@package_name@-$SERV_ID ]; then + . @initconfigdir@/@package_name@-$SERV_ID + else + echo Instance $SERV_ID not found. + return 1 + fi + + PIDFILE=$RUN_DIR/$PRODUCT_NAME-$SERV_ID.pid + if test ! -f $PIDFILE ; then + echo No ns-slapd PID file found. Server is probably not running + return 2 + fi + PID=`cat $PIDFILE` + # see if the server is already stopped + kill -0 $PID > /dev/null 2>&1 || { + echo Server not running + if test -f $PIDFILE ; then + rm -f $PIDFILE + fi + return 2 + } + # server is running - kill it + kill $PID + loop_counter=1 + # wait for 10 minutes (600 times 1 second) + max_count=600 + while test $loop_counter -le $max_count; do + loop_counter=`expr $loop_counter + 1` + if kill -0 $PID > /dev/null 2>&1 ; then + sleep 1; + else + if test -f $PIDFILE ; then + rm -f $PIDFILE + fi + return 0 + fi + done + if test -f $PIDFILE ; then + echo Server still running!! Failed to stop the ns-slapd process: $PID. Please check the errors log for problems. + fi + return 1 +} + +if [ "$#" -eq 0 ]; then + # We're stopping all instances. + ret=0 + for i in @initconfigdir@/@package_name@-*; do + inst=`echo $i | sed -e 's,@initconfigdir@/@package_name@-,,g'` + echo Stopping instance \"$inst\" + stop_instance $inst + if [ "$?" -ne 0 ]; then + ret=$? + fi + done + exit $ret +else + # We're stopping a single instance. + stop_instance $* + exit $? +fi |
