diff options
Diffstat (limited to 'ldap/admin/src')
| -rw-r--r-- | ldap/admin/src/initconfig.in | 9 | ||||
| -rw-r--r-- | ldap/admin/src/scripts/DSCreate.pm.in | 33 | ||||
| -rw-r--r-- | ldap/admin/src/scripts/restart-dirsrv.in | 47 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/start-dirsrv.in | 112 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/stop-dirsrv.in | 72 | ||||
| -rw-r--r-- | ldap/admin/src/scripts/template-restart-slapd.in | 18 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-start-slapd.in | 75 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-stop-slapd.in | 36 | ||||
| -rw-r--r-- | ldap/admin/src/template-initconfig.in | 18 |
9 files changed, 292 insertions, 128 deletions
diff --git a/ldap/admin/src/initconfig.in b/ldap/admin/src/initconfig.in index 2bcc6289..7f9dd8f7 100644 --- a/ldap/admin/src/initconfig.in +++ b/ldap/admin/src/initconfig.in @@ -1,10 +1,9 @@ # This file is sourced by @package_name@ upon startup to set # the default environment for all directory server instances. -# To set instance specific defaults, make a copy of this -# file in the same directory called @package_name@-instance -# where "instance" is the name of your directory server -# instance e.g. @package_name@-localhost for the -# slapd-localhost instance +# To set instance specific defaults, use the file in the same +# directory called @package_name@-instance where "instance" +# is the name of your directory server instance e.g. +# @package_name@-localhost for the slapd-localhost instance. # In order to make more file descriptors available # to the directory server, first make sure the system diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in index 66183e88..d33f13af 100644 --- a/ldap/admin/src/scripts/DSCreate.pm.in +++ b/ldap/admin/src/scripts/DSCreate.pm.in @@ -421,6 +421,16 @@ sub createConfigFile { sub makeOtherConfigFiles { my $inf = shift; my @errs; + my %maptable = ( + "DS-ROOT" => $inf->{General}->{prefix}, + "SERVER-DIR" => $inf->{General}->{ServerRoot}, + "CONFIG-DIR" => $inf->{slapd}->{config_dir}, + "INST-DIR" => $inf->{slapd}->{inst_dir}, + "RUN-DIR" => $inf->{slapd}->{run_dir}, + "PRODUCT-NAME" => "slapd", + "SERVERBIN-DIR" => $inf->{slapd}->{sbindir}, + ); + # install certmap.conf at <configdir> my $src = "$inf->{General}->{prefix}@configdir@/certmap.conf"; my $dest = "$inf->{slapd}->{config_dir}/certmap.conf"; @@ -444,6 +454,29 @@ sub makeOtherConfigFiles { return @errs; } + # install instance specific initconfig script + $src = "$inf->{General}->{prefix}@configdir@/template-initconfig"; + $dest = "$inf->{General}->{prefix}@initconfigdir@/@package_name@-$inf->{slapd}->{ServerIdentifier}"; + $! = 0; # clear errno + + if (!open(SRC, "< $src")) { + return ("error_opening_scripttmpl", $src, $!); + } + if (!open(DEST, "> $dest")) { + return ("error_opening_scripttmpl", $dest, $!); + } + my $contents; # slurp entire file into memory + read SRC, $contents, int(-s $src); + close(SRC); + while (my ($key, $val) = each %maptable) { + $contents =~ s/\{\{$key\}\}/$val/g; + } + print DEST $contents; + close(DEST); + if (@errs = changeOwnerMode($inf, 4, $dest)) { + return @errs; + } + return (); } diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in new file mode 100644 index 00000000..29203fd5 --- /dev/null +++ b/ldap/admin/src/scripts/restart-dirsrv.in @@ -0,0 +1,47 @@ +#!/bin/sh + +# Script that restarts the ns-slapd server. +# Exit status can be: +# 0: Server restarted successfully +# 1: Server could not be started +# 2: Server started successfully (was not running) +# 3: Server could not be stopped + +restart_instance() { + SERV_ID=$1 + + server_already_stopped=0 + @sbindir@/stop-dirsrv $SERV_ID + status=$? + if [ $status -eq 1 ] ; then + return 3; + else + if [ $status -eq 2 ] ; then + server_already_stopped=1 + fi + fi + @sbindir@/start-dirsrv $SERV_ID + status=$? + if [ $server_already_stopped -eq 1 ] && [ $status -eq 0 ] ; then + return 2; + fi + return $status +} + +if [ "$#" -eq 0 ]; then + # We're restarting all instances. + ret=0 + for i in @initconfigdir@/@package_name@-*; do + inst=`echo $i | sed -e 's,@initconfigdir@/@package_name@-,,g'` + echo Restarting instance \"$inst\" + restart_instance $inst + if [ "$?" -ne 0 ]; then + ret=$? + fi + done + exit $ret +else + # We're restarting a single instance. + restart_instance $* + exit $? +fi 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 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 diff --git a/ldap/admin/src/scripts/template-restart-slapd.in b/ldap/admin/src/scripts/template-restart-slapd.in index 6f5c0c89..19e24141 100644 --- a/ldap/admin/src/scripts/template-restart-slapd.in +++ b/ldap/admin/src/scripts/template-restart-slapd.in @@ -7,19 +7,5 @@ # 2: Server started successfully (was not running) # 3: Server could not be stopped -server_already_stopped=0 -{{INST-DIR}}/stop-slapd -status=$? -if [ $status -eq 1 ] ; then - exit 3; -else - if [ $status -eq 2 ] ; then - server_already_stopped=1 - fi -fi -{{INST-DIR}}/start-slapd -status=$? -if [ $server_already_stopped -eq 1 ] && [ $status -eq 0 ] ; then - exit 2; -fi -exit $status +@sbindir@/restart-dirsrv {{SERV-ID}} "$@" +exit $? diff --git a/ldap/admin/src/scripts/template-start-slapd.in b/ldap/admin/src/scripts/template-start-slapd.in index 223d6ed1..7608d373 100755 --- a/ldap/admin/src/scripts/template-start-slapd.in +++ b/ldap/admin/src/scripts/template-start-slapd.in @@ -1,81 +1,10 @@ #!/bin/sh -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 - -# source env. for all instances -[ -f @initconfigdir@/@package_name@ ] && . @initconfigdir@/@package_name@ - -# source env. for this instance -[ -f @initconfigdir@/@package_name@-{{SERV-ID}} ] && . @initconfigdir@/@package_name@-{{SERV-ID}} - # 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 -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 - exit 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 - exit 2; - else - rm -f $PIDFILE - fi -fi -cd {{SERVERBIN-DIR}}; ./ns-slapd -D {{CONFIG-DIR}} -i $PIDFILE -w $STARTPIDFILE "$@" -if [ $? -ne 0 ]; then - exit 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 - exit 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 - exit 1 - fi - else - PID=`cat $PIDFILE` - exit 0; - fi -done -echo Server not running!! Failed to start ns-slapd process. Please check the errors log for problems. -exit 1 +@sbindir@/start-dirsrv {{SERV-ID}} "$@" +exit $? diff --git a/ldap/admin/src/scripts/template-stop-slapd.in b/ldap/admin/src/scripts/template-stop-slapd.in index cc9f9681..35314646 100755 --- a/ldap/admin/src/scripts/template-stop-slapd.in +++ b/ldap/admin/src/scripts/template-stop-slapd.in @@ -6,37 +6,5 @@ # 1: Server could not be stopped # 2: Server was not running -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 - exit 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 - exit 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 - exit 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 -exit 1 +@sbindir@/stop-dirsrv {{SERV-ID}} "$@" +exit $? diff --git a/ldap/admin/src/template-initconfig.in b/ldap/admin/src/template-initconfig.in new file mode 100644 index 00000000..49458858 --- /dev/null +++ b/ldap/admin/src/template-initconfig.in @@ -0,0 +1,18 @@ +# This file is sourced by @package_name@ upon startup to set +# the default environment for a single specific directory +# server instances. To set defaults for all instances, edit +# the file in the same directory called @package_name@. + +# These settings are used by the start-dirsrv and +# start-slapd scripts (as well as their associates stop +# and restart scripts). Do not edit them unless you know +# what you are doing. +SERVER_DIR={{SERVER-DIR}} ; export SERVER_DIR +SERVERBIN_DIR={{SERVERBIN-DIR}} ; export SERVERBIN_DIR +CONFIG_DIR={{CONFIG-DIR}} ; export CONFIG_DIR +INST_DIR={{INST-DIR}} ; export INST_DIR +RUN_DIR={{RUN-DIR}} ; export RUN_DIR +DS_ROOT={{DS-ROOT}} ; export DS_ROOT +PRODUCT_NAME={{PRODUCT-NAME}} ; export PRODUCT_NAME + +# Put custom instance specific settings below here. |
