Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11321/ldap/admin/src/scripts
Modified Files: template-verify-db.pl.in Added Files: template-bak2db.in template-db2bak.in template-db2index.in template-db2ldif.in template-ldif2db.in template-ldif2ldap.in template-monitor.in template-restoreconfig.in template-saveconfig.in template-start-slapd.in template-stop-slapd.in template-suffix2instance.in template-upgradedb.in template-vlvindex.in Log Message: Resolves: #212098 Summary: Use autoconf to generate task perl script templates Comment #10, #11, #14
--- NEW FILE template-bak2db.in --- #!/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
--- NEW FILE template-db2bak.in --- #!/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
--- NEW FILE template-db2index.in --- #!/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
--- NEW FILE template-db2ldif.in --- #!/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
--- NEW FILE template-ldif2db.in --- #!/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 $?
--- NEW FILE template-ldif2ldap.in --- #!/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
--- NEW FILE template-monitor.in --- #!/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=*"
--- NEW FILE template-restoreconfig.in --- #!/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 $?
--- NEW FILE template-saveconfig.in --- #!/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
--- NEW FILE template-start-slapd.in --- #!/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
--- NEW FILE template-stop-slapd.in --- #!/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
--- NEW FILE template-suffix2instance.in --- #!/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
--- NEW FILE template-upgradedb.in --- #!/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
--- NEW FILE template-vlvindex.in --- #!/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}} "$@"
Index: template-verify-db.pl.in =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-verify-db.pl.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- template-verify-db.pl.in 25 Oct 2006 20:36:46 -0000 1.1 +++ template-verify-db.pl.in 26 Oct 2006 17:45:28 -0000 1.2 @@ -111,7 +111,6 @@
# 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';