# Author: Michael Stroeder
#
# /etc/init.d/web2ldap
#
### BEGIN INIT INFO
# Provides:			web2ldap
# Required-Start:		$local_fs $remote_fs $network 
# X-UnitedLinux-Should-Start:
# Required-Stop:		$local_fs $remote_fs $network
# X-UnitedLinux-Should-Stop:	
# Default-Start:		3 5
# Default-Stop:			0 1 2 6
# Short-Description:		web2ldap - web-based LDAPv3 client
# Description:			Starting web2ldap
### END INIT INFO

WEB2LDAP_SCRIPT=/opt/web2ldap/sbin/web2ldap.py
WEB2LDAP_PIDFILE=/opt/web2ldap/var/run/web2ldap-standalone.pid

. /etc/rc.status

# Reset status of this service
rc_reset

# The echo return value for success (defined in /etc/rc.config).
return=$rc_done

case "$1" in
    start)
        echo -n "Starting web2ldap"
        # web2ldap is started in demon mode
        $WEB2LDAP_SCRIPT -u wwwrun -t on -d on || return=$rc_failed
        echo -e "$return"
        ;;
    stop)
        echo -n "Shutting down web2ldap"
        kill `cat $WEB2LDAP_PIDFILE` || return=$rc_failed
	rc_status -v
	;;
    restart)
        ## If first returns OK call the second, if first or
        ## second command fails, set echo return value.
        $0 stop  &&  $0 start  ||  return=$rc_failed
        ;;
    reload)
        ## Exclusive possibility: Some services must be stopped
        ## and started to force a new load of the configuration.

        $0 stop  &&  $0 start  ||  return=$rc_failed
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart|reload}"
        exit 1
esac

# Inform the caller not only verbosely and set an exit status.
test "$return" = "$rc_done" || exit 1
exit 0

