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/start-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/start-dirsrv.in')
| -rwxr-xr-x | ldap/admin/src/scripts/start-dirsrv.in | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in new file mode 100755 index 00000000..fb9bfdb0 --- /dev/null +++ b/ldap/admin/src/scripts/start-dirsrv.in @@ -0,0 +1,112 @@ +#!/bin/sh + +# Script that starts the ns-slapd server. +# Exit status can be: +# 0: Server started successfully +# 1: Server could not be started +# 2: Server already running + +# Starts a single instance +start_instance() { + # The first argument is the server ID. Anything + # after that is an argument to ns-slapd. + SERV_ID=$1 + shift + + # 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 + + prefix="$DS_ROOT" + LD_LIBRARY_PATH=$prefix$SERVER_DIR:$prefix@nss_libdir@:$prefix@libdir@:@nss_libdir@ + export LD_LIBRARY_PATH + SHLIB_PATH=$prefix$SERVER_DIR:$prefix@nss_libdir@:$prefix@libdir@:@nss_libdir@ + export SHLIB_PATH + + DS_CONFIG_DIR=$CONFIG_DIR + export DS_CONFIG_DIR + PIDFILE=$RUN_DIR/$PRODUCT_NAME-$SERV_ID.pid + STARTPIDFILE=$RUN_DIR/$PRODUCT_NAME-$SERV_ID.startpid + if test -f $STARTPIDFILE ; then + PID=`cat $STARTPIDFILE` + if kill -0 $PID > /dev/null 2>&1 ; then + echo There is an ns-slapd process already running: $PID + return 2; + else + rm -f $STARTPIDFILE + fi + fi + if test -f $PIDFILE ; then + PID=`cat $PIDFILE` + if kill -0 $PID > /dev/null 2>&1 ; then + echo There is an ns-slapd running: $PID + return 2; + else + rm -f $PIDFILE + fi + fi + cd $SERVERBIN_DIR; ./ns-slapd -D $CONFIG_DIR -i $PIDFILE -w $STARTPIDFILE "$@" + if [ $? -ne 0 ]; then + return 1 + fi + + loop_counter=1 + # wait for 10 seconds for the start pid file to appear + max_count=${STARTPID_TIME:-10} + while test $loop_counter -le $max_count; do + loop_counter=`expr $loop_counter + 1` + if test ! -f $STARTPIDFILE ; then + sleep 1; + else + PID=`cat $STARTPIDFILE` + fi + done + if test ! -f $STARTPIDFILE ; then + echo Server failed to start !!! Please check errors log for problems + return 1 + fi + loop_counter=1 + # wait for 10 minutes (600 times 1 seconds) + max_count=${PID_TIME:-600} + while test $loop_counter -le $max_count; do + loop_counter=`expr $loop_counter + 1` + if test ! -f $PIDFILE ; then + if kill -0 $PID > /dev/null 2>&1 ; then + sleep 1 + else + echo Server failed to start !!! Please check errors log for problems + return 1 + fi + else + PID=`cat $PIDFILE` + return 0; + fi + done + echo Server not running!! Failed to start ns-slapd process. Please check the errors log for problems. + return 1 +} + +# source env. for all instances +[ -f @initconfigdir@/@package_name@ ] && . @initconfigdir@/@package_name@ + +if [ "$#" -eq 0 ]; then + # We're starting all instances. + ret=0 + for i in @initconfigdir@/@package_name@-*; do + inst=`echo $i | sed -e 's,@initconfigdir@/@package_name@-,,g'` + echo Starting instance \"$inst\" + start_instance $inst + if [ "$?" -ne 0 ]; then + ret=$? + fi + done + exit $ret +else + # We're starting a single instance. + start_instance $* + exit $? +fi |
