[OpenLDAP] Start/stop script
version 0.6-3
Presentation
With the init script slapd, launching and halting OpenLDAP (directory and replication daemon) is easier. It requires the following tools:
logger, to send messages to syslog.
BerkeleyDB, for recovering and archiving tools.
OpenLDAP, for server software of course, but also for indexing, safeguard and test utilities.
It is possible (and recommended) to configure this script by using an external file, named as the init script, and installed in the directory /etc/default.
This script is designed to OpenLDAP 2.2.x and 2.3.x, adapting the configuration to one or the other versions.
Usage
This script has to be run this way:
# /etc/init.d/slapd action
With action in:
-
start:- Do a check of the configuration.
- Start
slurpd if replicas are configured. - Start
slapd, recovering data if asked.
-
stop:- Stop
slapd and save data if asked. - Stop
slurpd if running.
-
forcestop:- If PID are recovered, a
kill -KILL is done on them. - Else a
killall -KILL is done on binaries names.
-
restart:- Launch
stop action commands. - Launch
start action commands.
-
configtest: configuration is checked (utility slaptest). -
db_recover: database is repaired (utility db_recover). -
reindex: database is reindexed (utility slapindex). -
removelogs: old database logs are deleted (utility db_archive). -
backup: data are saved in LDIF format (utility slapcat).
Installation
For a Linux system and most of UNIX, this script has to be executable and installed in directory /etc/init.d:
# mv slapd /etc/init.d
# chmod +x /etc/init.d/slapd
In order to start the service at system launching and stop it at shutdown, the following symbolic links must be created (adapt to your distribution):
# ln -s /etc/init.d/slapd /etc/rc2.d/S90slapd
# ln -s /etc/init.d/slapd /etc/rc3.d/S90slapd
# ln -s /etc/init.d/slapd /etc/rc4.d/S90slapd
# ln -s /etc/init.d/slapd /etc/rc5.d/S90slapd
# ln -s /etc/init.d/slapd /etc/rc0.d/K10slapd
# ln -s /etc/init.d/slapd /etc/rc6.d/K10slapd
On RedHat, simply do :
# chkconfig --add slapd
The configuration file must be installed in the directory /etc/default, it is also recommended to protect his visibility:
# mkdir -p /etc/default
# mv slapd.default /etc/default/slapd
# chmod 600 /etc/default/slapd
If you run more than one OpenLDAP instance on the same machine, you just have to name differently the init scripts (eg: slapd_proxy et slapd_data) and apply these naming rules to configuration files installed in /etc/default. Of course, symbolic links must be updated too.
Configuration
It is strongly recommended to use the external file installed in /etc/default rather than modify the init script directly.
The following parameters are mandatory:
IP: listening address (interface) of OpenLDAP. The wildcard * can be used to design all interfaces.
PORT: listening port of OpenLDAP. If more than one, please use SLAPD_SERVICES parameter.
SLAPD_PATH: installation directory of OpenLDAP.
DATA_PATH: database files directory, as written in the parameter directory of slapd.conf. You can set auto to get all databases written in slapd.conf.
SLAPD_PID_FILE: PID file of slapd, as written in the parameter pidfile of slapd.conf.
SLAPD_CONF: main configuration file.
SLAPD_SERVICES: URI LDAP list, space separated, on which listen OpenLDAP.
SLAPD_BIN: slapd binary path.
SLAPCAT_BIN: slapcat utility path.
SLAPINDEX_BIN: slapindex utility path.
SLAPTEST_BIN: slaptest utility path.
SLURPD_PID_FILE: PID file of slurpd, as written in the parameter replica-pidfile of slapd.conf.
SLURPD_BIN: slurpd binary path.
BDB_PATH: installation directory of BerkeleyDB.
DB_ARCHIVE_BIN: db_archive utility path.
DB_RECOVER_BIN: db_recover.
RECOVER_AT_STARTUP: activate database recovering before starting slapd. This is useless and disadvised for OpenLDAP 2.3.x, bur strongly recommended for OpenLDAP 2.2.x.
BACKUP_AT_SHUTDOWN: activate data save after stopping slapd.
BACKUP_PATH: save directory.
BACKUP_FILE: LDIF save file path. If fixed, the file will be erased with each new save. You can include the date in the name to avoid this behavior.
TIMEOUT: time to wait the end of a process. After, a message invit to use the forcestop action.
FD_LIMIT: max number of opened file descriptors.
The followinf parameters are optional (they can contain the value ""):
SLAPD_PARAMS: other options for slapd. Options -h, -f, -u and -g are already registered.
SLAPD_CONF_DIR: configuration directory (which is corresponding to the -F option of slapd binary). It is null by default, if not OpenLDAP will run by using the configuration directory instead of the traditionnal static configuration file specified by SLAPD_CONF variable.
SLAPD_USER: user owner of process slapd and slurpd.
SLAPD_GROUP: group owner of process slapd and slurpd.
SLURPD_PARAMS: other options for slurpd. Option -f is already registered.
Download
Init script:

- Init script
- Version 0.6-3
Configuration file for a default installation:

- Configuration File
Copyright (C) 2008 Jonathan CLARKE
Copyright (C) 2007 Olivier LI-KIANG-CHEONG
Copyright (C) 2007 Thomas CHEMINEAU
Copyright (C) 2005 Sébastien BAHLOUL
Copyright (C) 2005 Raphaël OUAZANA
Copyright (C) 2005 Clément OUDOT
Copyright (C) 2005 LINAGORA
GNU Public License (GPL)
|