[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts template-bak2db, NONE, 1.1 template-db2bak, NONE, 1.1 template-db2index, NONE, 1.1 template-db2ldif, NONE, 1.1 template-ldif2db, NONE, 1.1 template-ldif2ldap, NONE, 1.1 template-monitor, NONE, 1.1 template-restoreconfig, NONE, 1.1 template-saveconfig, NONE, 1.1 template-start-slapd, NONE, 1.1 template-stop-slapd, NONE, 1.1 template-suffix2instance, NONE, 1.1 template-vlvindex, NONE, 1.1

Noriko Hosoi (nhosoi) fedora-directory-commits at redhat.com
Fri Oct 27 16:45:21 UTC 2006


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv4149

Added Files:
	template-bak2db template-db2bak template-db2index 
	template-db2ldif template-ldif2db template-ldif2ldap 
	template-monitor template-restoreconfig template-saveconfig 
	template-start-slapd template-stop-slapd 
	template-suffix2instance template-vlvindex 
Log Message:
Resolves: #212098
Summary: Use autoconf to generate task perl script templates
Comment #10, #11, #14
Note: This is a generated file by autoconf.  Checking this file in to support
the old style build.  When migrating to the autotoolized build is completed,
this file is supposed to be removed from CVS.



--- NEW FILE template-bak2db ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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 ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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 ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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 ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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 ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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 ---
#!/bin/sh

prefix="{{DS-ROOT}}"
PATH=$prefix/usr/lib/mozldap6:/usr/lib/mozldap6
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:/usr/lib/dirsec:$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:/usr/lib/dirsec:$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export SHLIB_PATH

ldapmodify -a -p {{SERVER-PORT}} -D "$1" -w "$2" -f $3


--- NEW FILE template-monitor ---
#!/bin/sh

PATH=$prefix/usr/lib/mozldap6:/usr/lib/mozldap6
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:/usr/lib/dirsec:$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:/usr/lib/dirsec:$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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 ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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 ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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 ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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 ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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 ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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-vlvindex ---
#!/bin/sh

prefix="{{DS-ROOT}}"
LD_LIBRARY_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
export LD_LIBRARY_PATH
SHLIB_PATH=$prefix/usr/lib/dirsec:$prefix/usr/lib:/usr/lib/dirsec
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}} "$@"




More information about the Fedora-directory-commits mailing list