1#! /bin/sh
2# OpenLDAP: pkg/ldap/tests/scripts/startup_nis_ldap_server.sh,v 1.14.2.5 2010/04/13 20:24:00 kurt Exp
3## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4##
5## Copyright 1998-2010 The OpenLDAP Foundation.
6## All rights reserved.
7##
8## Redistribution and use in source and binary forms, with or without
9## modification, are permitted only as authorized by the OpenLDAP
10## Public License.
11##
12## A copy of this license is available in the file LICENSE in the
13## top-level directory of the distribution or, alternatively, at
14## <http://www.OpenLDAP.org/license.html>.
15
16if [ $# -eq 0 ]; then
17	SRCDIR="."
18else
19	SRCDIR=$1; shift
20fi
21if [ $# -eq 1 ]; then
22	BDB2=$1; shift
23fi
24
25. $SRCDIR/scripts/defines.sh $SRCDIR $BDB2
26
27# Sample NIS database in LDIF format
28NIS_LDIF=$SRCDIR/data/nis_sample.ldif
29
30# Sample configuration file for your LDAP server
31if test "$BACKEND" = "bdb2" ; then
32	NIS_CONF=$DATADIR/slapd-bdb2-nis-master.conf
33else
34	NIS_CONF=$DATADIR/slapd-nis-master.conf
35fi
36
37echo "Cleaning up in $DBDIR..."
38
39rm -f $DBDIR/[!C]*
40
41echo "Running slapadd to build slapd database..."
42$SLAPADD -f $NIS_CONF -l $NIS_LDIF
43RC=$?
44if [ $RC != 0 ]; then
45	echo "slapadd failed!"
46	exit $RC
47fi
48
49echo "Starting slapd on TCP/IP port $PORT..."
50$SLAPD -f $NIS_CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
51PID=$!
52
53echo ">>>>> LDAP server with NIS schema is up! PID=$PID"
54
55
56exit 0
57