| < Day Day Up > |
|
You do not have to start your directory server by hand every time the system is rebooted. Commercial products provide you with tools and instructions on how to start the directory server upon system boot and how to stop it when the system is being shut down. On Microsoft servers, you configure this under "services." In the UNIX world, you have to copy start/stop scripts into the location of the "init" scripts. The exact location of these scripts depends on the UNIX dialect you are using. The architecture, however, is always the same:
The following is a script that starts and stops the server, depending on the parameter it gets:
slapd start : to start the server slapd stop: to stop the server
Exhibit 14 shows an example of a start/stop script for LDAP. Exhibit 15 shows the configuration file that controls whether the LDAP server is to be started or stopped during system startup or shutdown.
#! /usr/bin/sh # # @(#) $Revision: 1.2 $ # # Author: Reinhard E. Voglmaier # # Description: Start/Stop of LDAP server # # Set the environment: PATH=/sbin:/usr/sbin:/usr/bin export PATH LdapServerDir = /opt/ldap LdapConfigDir=$LdapServerDir/conf LdapCurrentJobs=$LdapServerDir/jobs rval=0 case $1 in start_msg) echo "Start LDAP servers" ;; stop_msg) echo "Stop LDAP servers" ;; 'start') if [ -f /etc/re.config.d/ldap ] then Servers = `. /etc/re.config.d/ldap` else echo "LDAP Configuration File not found" exit 1 fi for i in $Servers do Cmd=$LdapServerDir/$i/slapd ConfigFile=$LdapConfigDir/$i/slapd.conf $Cmd -f $ConfigFile if [ $? -eq 0 ] then echo "Ldap Server $i started" else echo "Could not start Ldap Server $i" fi done ;; 'stop') if [ -f /etc/rc.config.d/ldap ] then Servers = `. /etc/rc.config.d/ldap` else echo "LDAP Configuration File not found" exit 1 fi for i in $Servers do if [ -f $LdapCurrentJobs/$i/pid ] then PID=` cat $LdapCurrentJobs/$i/pid` kill -TERM ${PID} if [ retval -ne 0 ] then echo " Could not stop LDAP Server $i" else rm $LdapCurrentJobs/$i/pid echo "LDAP Server $i stopped" fi else echo "LDAP server $i not running" fi done ;; esac exit $rval
#!/usr/bin/sh # # @(#) $Revision: 1.2 $ # # Author: Reinhard E. Voglmaier # GlaxoSmithKline # Description: Configuration file for Start/Stop of LDAP server # # set to 1 if you want to start the server at system boot # set to 0 otherwise # Main LDAP Server main_ldap=1 # LDAP Administration Server admin_ldap=1 # LDAP Server TestApplication test01_ldap=0 # Print Server Names to be started for i in main_ldap admin_ldap test01_ldap do echo ${i} done
| < Day Day Up > |
|