#!/bin/bash
#
# ldapbindfs	This shell script takes care of starting and stopping
#		the ldapbindfs filesystem.
#
# chkconfig: - 25 75
# description: ldapbindfs - fuse-based filesystem
# probe: false
# processname: ldapbindfs
# pidfile: /var/run/ldapbindfs.pid

# Comments to support LSB init script conventions

### BEGIN INIT INFO
# Provides: ldapbindfs
# Required-Start: slapd
# Required-Stop: slapd
# Default-Stop: 0 1 6
# Short-Description: start and stop ldapbindfs
# Description: ldapbindfs - fuse-based filesystem for mapping dns zones in ldap to text files
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

mountpoint="/var/named/ldap.mnt"

[ -f /usr/sbin/ldapbindfs ] || exit 0

RETVAL=0
start() {
	if [ -n "`/sbin/pidof ldapbindfs`" ]; then
	    echo -n $"ldapbindfs: already running"
	    RETVAL=$?
	    echo
	    return $RETVAL
	fi
        echo -n $"Starting ldapbindfs: "
    
	/usr/sbin/ldapbindfs -o allow_other,default_permissions $mountpoint
        RETVAL=$?
        [ $RETVAL = 0 ] && touch /var/lock/subsys/ldapbindfs && success
	echo
        return $RETVAL
}
stop() {
	echo -n $"Stopping ldapbindfs: "
	killproc ldapbindfs
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/ldapbindfs
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
	stop
	start
	;;
  condrestart)
	if [ -f /var/lock/subsys/ldapbindfs ] ; then
	    stop
	    start
	fi
	;;
  *)
	echo $"Usage: %s {start|stop|restart|condrestart}\n" "$0"
	exit 1
esac

exit $RETVAL
