diff options
| author | Noriko Hosoi <nhosoi@redhat.com> | 2006-10-26 17:45:28 +0000 |
|---|---|---|
| committer | Noriko Hosoi <nhosoi@redhat.com> | 2006-10-26 17:45:28 +0000 |
| commit | 7453f55416dd6e4904907598920605b610eccd67 (patch) | |
| tree | 7c8b90739ca114ec243d1d699fb7eb32f378a33d /ldap/admin/src/scripts | |
| parent | 1c02a56cfc3185d4db4a336f6a2be11bc55c1c8f (diff) | |
| download | ds-7453f55416dd6e4904907598920605b610eccd67.tar.gz ds-7453f55416dd6e4904907598920605b610eccd67.tar.xz ds-7453f55416dd6e4904907598920605b610eccd67.zip | |
Resolves: #212098
Summary: Use autoconf to generate task perl script templates
Comment #10, #11, #14
Diffstat (limited to 'ldap/admin/src/scripts')
| -rwxr-xr-x | ldap/admin/src/scripts/template-bak2db.in | 39 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-db2bak.in | 17 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-db2index.in | 21 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-db2ldif.in | 41 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-ldif2db.in | 20 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-ldif2ldap.in | 10 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-monitor.in | 13 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-restoreconfig.in | 17 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-saveconfig.in | 18 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-start-slapd.in | 77 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-stop-slapd.in | 48 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-suffix2instance.in | 16 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-upgradedb.in | 18 | ||||
| -rw-r--r-- | ldap/admin/src/scripts/template-verify-db.pl.in | 1 | ||||
| -rwxr-xr-x | ldap/admin/src/scripts/template-vlvindex.in | 17 |
15 files changed, 372 insertions, 1 deletions
diff --git a/ldap/admin/src/scripts/template-bak2db.in b/ldap/admin/src/scripts/template-bak2db.in new file mode 100755 index 00000000..e0e39408 --- /dev/null +++ b/ldap/admin/src/scripts/template-bak2db.in @@ -0,0 +1,39 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +if [ $# -lt 1 ] || [ $# -gt 3 ] +then + echo "Usage: bak2db archivedir [-n backendname]" + exit 1 +else + archivedir=$1 + shift +fi +while getopts "n:" flag +do + case $flag in + n) bename=$OPTARG;; + *) echo "Usage: bak2db archivedir [-n backendname]"; exit 2;; + esac +done + +if [ 1 = `expr $archivedir : "\/"` ] +then + archivedir=$archivedir +else + # relative + archivedir=`pwd`/$archivedir +fi + +cd {{SERVER-DIR}} +if [ "$#" -eq 2 ] +then + ./ns-slapd archive2db -D {{CONFIG-DIR}} -a $archivedir -n $bename +else + ./ns-slapd archive2db -D {{CONFIG-DIR}} -a $archivedir +fi diff --git a/ldap/admin/src/scripts/template-db2bak.in b/ldap/admin/src/scripts/template-db2bak.in new file mode 100755 index 00000000..73508d3d --- /dev/null +++ b/ldap/admin/src/scripts/template-db2bak.in @@ -0,0 +1,17 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +cd {{SERVER-DIR}} +if [ "$#" -eq 1 ] +then + bak_dir=$1 +else + bak_dir={{BAK-DIR}}/`date +%Y_%m_%d_%H_%M_%S` +fi + +./ns-slapd db2archive -D {{CONFIG-DIR}} -a $bak_dir diff --git a/ldap/admin/src/scripts/template-db2index.in b/ldap/admin/src/scripts/template-db2index.in new file mode 100755 index 00000000..b13c7965 --- /dev/null +++ b/ldap/admin/src/scripts/template-db2index.in @@ -0,0 +1,21 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +cd {{SERVER-DIR}} +if [ $# -eq 0 ] +then + bak_dir={{BAK-DIR}}/reindex_`date +%Y_%m_%d_%H_%M_%S` + ./ns-slapd upgradedb -D {{CONFIG-DIR}} -f -a "$bak_dir" +elif [ $# -lt 4 ] +then + echo "Usage: db2index [-n backend_instance | {-s includesuffix}* -t attribute[:indextypes[:matchingrules]] -T vlvattribute]" + exit 1 +else + ./ns-slapd db2index -D {{CONFIG-DIR}} "$@" +fi + diff --git a/ldap/admin/src/scripts/template-db2ldif.in b/ldap/admin/src/scripts/template-db2ldif.in new file mode 100755 index 00000000..846655ad --- /dev/null +++ b/ldap/admin/src/scripts/template-db2ldif.in @@ -0,0 +1,41 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +cd {{SERVER-DIR}} +if [ "$#" -lt 2 ]; +then + echo "Usage: db2ldif {-n backend_instance}* | {-s includesuffix}*" + echo " [{-x excludesuffix}*] [-a outputfile]" + echo " [-N] [-r] [-C] [-u] [-U] [-m] [-M] [-1]" + echo "Note: either \"-n backend_instance\" or \"-s includesuffix\" is required." + exit 1 +fi + +set_ldif=0 +ldif_file="mydummy" +for arg in "$@" +do + if [ "$arg" = '-a' ]; + then + set_ldif=1 + elif [ $set_ldif -eq 1 ]; + then + ldif_file=$arg + set_ldif=2 + fi +done +if [ $ldif_file = "mydummy" ] +then + ldif_file={{LDIF-DIR}}/laputa-`date +%Y_%m_%d_%H%M%S`.ldif +fi +if [ $set_ldif -eq 2 ] +then +./ns-slapd db2ldif -D {{CONFIG-DIR}} "$@" +else +./ns-slapd db2ldif -D {{CONFIG-DIR}} -a $ldif_file "$@" +fi diff --git a/ldap/admin/src/scripts/template-ldif2db.in b/ldap/admin/src/scripts/template-ldif2db.in new file mode 100755 index 00000000..65a2e215 --- /dev/null +++ b/ldap/admin/src/scripts/template-ldif2db.in @@ -0,0 +1,20 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +cd {{SERVER-DIR}} +if [ $# -lt 4 ] +then + echo "Usage: ldif2db -n backend_instance | {-s includesuffix}* [{-x excludesuffix}*]" + echo " {-i ldiffile}* [-O]" + echo "Note: either \"-n backend_instance\" or \"-s includesuffix\" and \"-i ldiffile\" are required." + exit 1 +fi + +echo importing data ... +./ns-slapd ldif2db -D {{CONFIG-DIR}} "$@" 2>&1 +exit $? diff --git a/ldap/admin/src/scripts/template-ldif2ldap.in b/ldap/admin/src/scripts/template-ldif2ldap.in new file mode 100755 index 00000000..0983396a --- /dev/null +++ b/ldap/admin/src/scripts/template-ldif2ldap.in @@ -0,0 +1,10 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +PATH=$prefix@ldapsdk_bindir@:@ldapsdk_bindir@ +LD_LIBRARY_PATH=$prefix@ldapsdk_libdir@:@ldapsdk_libdir@:$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@ldapsdk_libdir@:@ldapsdk_libdir@:$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +ldapmodify -a -p {{SERVER-PORT}} -D "$1" -w "$2" -f $3 diff --git a/ldap/admin/src/scripts/template-monitor.in b/ldap/admin/src/scripts/template-monitor.in new file mode 100755 index 00000000..487aac49 --- /dev/null +++ b/ldap/admin/src/scripts/template-monitor.in @@ -0,0 +1,13 @@ +#!/bin/sh + +PATH=$prefix@ldapsdk_bindir@:@ldapsdk_bindir@ +LD_LIBRARY_PATH=$prefix@ldapsdk_libdir@:@ldapsdk_libdir@:$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@ldapsdk_libdir@:@ldapsdk_libdir@:$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +if [ "x$1" != "x" ]; +then MDN="$1"; +else MDN="cn=monitor"; + fi +ldapsearch -p {{SERVER-PORT}} -b "$MDN" -s base "objectClass=*" diff --git a/ldap/admin/src/scripts/template-restoreconfig.in b/ldap/admin/src/scripts/template-restoreconfig.in new file mode 100755 index 00000000..9f7be2d2 --- /dev/null +++ b/ldap/admin/src/scripts/template-restoreconfig.in @@ -0,0 +1,17 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +cd {{SERVER-DIR}} +conf_ldif=`ls -1t {{BAK-DIR}}/{{SERV-ID}}-*.ldif | head -1` +if [ -z "$conf_ldif" ] +then + echo No configuration to restore in {{BAK-DIR}} ; exit 1 +fi +echo Restoring $conf_ldif +./ns-slapd ldif2db -D {{CONFIG-DIR}} -i $conf_ldif -n NetscapeRoot 2>&1 +exit $? diff --git a/ldap/admin/src/scripts/template-saveconfig.in b/ldap/admin/src/scripts/template-saveconfig.in new file mode 100755 index 00000000..8d9f7c11 --- /dev/null +++ b/ldap/admin/src/scripts/template-saveconfig.in @@ -0,0 +1,18 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +cd {{SERVER-DIR}} +echo saving configuration ... +conf_ldif={{BAK-DIR}}/{{SERV-ID}}-`date +%Y_%m_%d_%H%M%S`.ldif +./ns-slapd db2ldif -N -D {{CONFIG-DIR}} -s "o=NetscapeRoot" -a $conf_ldif -n NetscapeRoot 2>&1 +if [ "$?" -ge 1 ] +then + echo Error occurred while saving configuration + exit 1 +fi +exit 0 diff --git a/ldap/admin/src/scripts/template-start-slapd.in b/ldap/admin/src/scripts/template-start-slapd.in new file mode 100755 index 00000000..b408fd8f --- /dev/null +++ b/ldap/admin/src/scripts/template-start-slapd.in @@ -0,0 +1,77 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +# 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 + +NETSITE_ROOT={{SERVER-DIR}} +export NETSITE_ROOT +DS_CONFIG_DIR={{CONFIG-DIR}} +export DS_CONFIG_DIR +PIDFILE={{RUN-DIR}}/pid +STARTPIDFILE={{RUN-DIR}}/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 {{SERVER-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=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=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 diff --git a/ldap/admin/src/scripts/template-stop-slapd.in b/ldap/admin/src/scripts/template-stop-slapd.in new file mode 100755 index 00000000..f7c3e9ae --- /dev/null +++ b/ldap/admin/src/scripts/template-stop-slapd.in @@ -0,0 +1,48 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +# 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 + +PIDFILE={{RUN-DIR}}/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 diff --git a/ldap/admin/src/scripts/template-suffix2instance.in b/ldap/admin/src/scripts/template-suffix2instance.in new file mode 100755 index 00000000..1a2ce325 --- /dev/null +++ b/ldap/admin/src/scripts/template-suffix2instance.in @@ -0,0 +1,16 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +cd {{SERVER-DIR}} +if [ $# -lt 2 ] +then + echo Usage: suffix2instance {-s includesuffix}* + exit 1 +fi + +./ns-slapd suffix2instance -D {{CONFIG-DIR}} "$@" 2>&1 diff --git a/ldap/admin/src/scripts/template-upgradedb.in b/ldap/admin/src/scripts/template-upgradedb.in new file mode 100755 index 00000000..621d562c --- /dev/null +++ b/ldap/admin/src/scripts/template-upgradedb.in @@ -0,0 +1,18 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +cd {{SERVER-DIR}} +if [ "$#" -eq 1 ] +then + bak_dir=$1 +else + bak_dir={{BAK-DIR}}/upgradedb_`date +%Y_%m_%d_%H_%M_%S` +fi + +echo upgrade index files ... +./ns-slapd upgradedb -D {{CONFIG-DIR}} -a $bak_dir diff --git a/ldap/admin/src/scripts/template-verify-db.pl.in b/ldap/admin/src/scripts/template-verify-db.pl.in index 8cf45afa..756a1050 100644 --- a/ldap/admin/src/scripts/template-verify-db.pl.in +++ b/ldap/admin/src/scripts/template-verify-db.pl.in @@ -111,7 +111,6 @@ print("*****************************************************************\n"); # get dirs having DBVERSION my $dbdirs = getDbDir("."); -my $brand_ds = {{DS-BRAND}}; my $prefix = "{{DS-ROOT}}"; $ENV{'PATH'} = '$prefix@db_bindir@:$prefix/usr/lib:@db_bindir@:/usr/lib'; diff --git a/ldap/admin/src/scripts/template-vlvindex.in b/ldap/admin/src/scripts/template-vlvindex.in new file mode 100755 index 00000000..472fc15a --- /dev/null +++ b/ldap/admin/src/scripts/template-vlvindex.in @@ -0,0 +1,17 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +LD_LIBRARY_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export LD_LIBRARY_PATH +SHLIB_PATH=$prefix@nss_libdir@:$prefix/usr/lib:@nss_libdir@ +export SHLIB_PATH + +cd {{SERVER-DIR}} +if [ $# -lt 4 ] +then + echo "Usage: vlvindex -n backend_instance | {-s includesuffix}* -T attribute" + echo Note: either \"-n backend_instance\" or \"-s includesuffix\" are required. + exit 1 +fi + +./ns-slapd db2index -D {{CONFIG-DIR}} "$@" |
