xref: /netbsd-src/external/bsd/openldap/dist/tests/scripts/startup_nis_ldap_server.sh (revision e670fd5c413e99c2f6a37901bb21c537fcd322d2)
12de962bdSlukem#! /bin/sh
2d11b170bStron# $OpenLDAP$
32de962bdSlukem## This work is part of OpenLDAP Software <http://www.openldap.org/>.
42de962bdSlukem##
5*e670fd5cSchristos## Copyright 1998-2021 The OpenLDAP Foundation.
62de962bdSlukem## All rights reserved.
72de962bdSlukem##
82de962bdSlukem## Redistribution and use in source and binary forms, with or without
92de962bdSlukem## modification, are permitted only as authorized by the OpenLDAP
102de962bdSlukem## Public License.
112de962bdSlukem##
122de962bdSlukem## A copy of this license is available in the file LICENSE in the
132de962bdSlukem## top-level directory of the distribution or, alternatively, at
142de962bdSlukem## <http://www.OpenLDAP.org/license.html>.
152de962bdSlukem
162de962bdSlukemif [ $# -eq 0 ]; then
172de962bdSlukem	SRCDIR="."
182de962bdSlukemelse
192de962bdSlukem	SRCDIR=$1; shift
202de962bdSlukemfi
212de962bdSlukemif [ $# -eq 1 ]; then
222de962bdSlukem	BDB2=$1; shift
232de962bdSlukemfi
242de962bdSlukem
252de962bdSlukem. $SRCDIR/scripts/defines.sh $SRCDIR $BDB2
262de962bdSlukem
272de962bdSlukem# Sample NIS database in LDIF format
282de962bdSlukemNIS_LDIF=$SRCDIR/data/nis_sample.ldif
292de962bdSlukem
302de962bdSlukem# Sample configuration file for your LDAP server
312de962bdSlukemif test "$BACKEND" = "bdb2" ; then
32*e670fd5cSchristos	NIS_CONF=$DATADIR/slapd-bdb2-nis-provider.conf
332de962bdSlukemelse
34*e670fd5cSchristos	NIS_CONF=$DATADIR/slapd-nis-provider.conf
352de962bdSlukemfi
362de962bdSlukem
372de962bdSlukemecho "Cleaning up in $DBDIR..."
382de962bdSlukem
392de962bdSlukemrm -f $DBDIR/[!C]*
402de962bdSlukem
412de962bdSlukemecho "Running slapadd to build slapd database..."
422de962bdSlukem$SLAPADD -f $NIS_CONF -l $NIS_LDIF
432de962bdSlukemRC=$?
442de962bdSlukemif [ $RC != 0 ]; then
452de962bdSlukem	echo "slapadd failed!"
462de962bdSlukem	exit $RC
472de962bdSlukemfi
482de962bdSlukem
492de962bdSlukemecho "Starting slapd on TCP/IP port $PORT..."
50*e670fd5cSchristos$SLAPD -f $NIS_CONF -p $PORT -d $LVL > $PROVIDERLOG 2>&1 &
512de962bdSlukemPID=$!
522de962bdSlukem
532de962bdSlukemecho ">>>>> LDAP server with NIS schema is up! PID=$PID"
542de962bdSlukem
552de962bdSlukem
562de962bdSlukemexit 0
57