#! /bin/sh
### BEGIN INIT INFO
# Provides:          dhcp2ldap
# Required-Start:    slapd
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Dhcp Ldap syncronize
# Description:       Syncronize dhcp.leases with Bind9 Ldap
### END INIT INFO
# Author: http://projects.netfoo.org/2005/07/02/initial-release/

#test -x /usr/local/sbin/dhcp2ldapd || exit 0

case "$1" in
  start)
	echo -n "Starting dhcp2ldap Daemon: dhcp2ldap"
	start-stop-daemon --start --quiet --make-pidfile --pidfile /var/run/dhcp2ldapd.pid --exec /usr/local/sbin/dhcp2ldapd -- -d
        echo "."
	;;
  stop)
        echo -n "Stopping dhcp2ldap Daemon: dhcp2ldapd"
        killall dhcp2ldapd > /dev/null
	echo "."
	;;

  restart)
        echo -n "Restarting dhcp2ldap Daemon: dhcp2ldapd"
	killall dhcp2ldapd
	sleep 2
	start-stop-daemon --start --quiet --pidfile /var/run/dhcp2ldapd.pid --exec /usr/local/sbin/dhcp2ldapd -- -d
	echo "."
	;;

  *)
	echo "Usage: /etc/init.d/dhcp2ldap {start|stop|restart}"
	exit 1
esac

exit 0
