#! /bin/sh
### BEGIN INIT INFO
# Provides:          likewise-open
# Required-Start:    $network $local_fs $remote_fs
# Required-Stop:     $network $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: Start likewise-open
# Description: Start and Stop the Likewise Identity Auth Daemon
### END INIT INFO

# Author: Rick Clark <rick.clark@ubuntu.com>


# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/sbin:/usr/bin:/sbin:/bin

DESC="Start and Stop the Likewise Identity Auth Daemon"
NAME=likewise-winbindd
DAEMON=/usr/sbin/$NAME
PIDFILE=/var/run/$NAME.pid


# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS

unset TMPDIR

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions


case "$1" in
        start)
                log_daemon_msg "Starting the Likewise-open auth daemon"
                start-stop-daemon --start --quiet --oknodo --exec $DAEMON
                log_end_msg $?
                ;;

        stop)
                log_daemon_msg "Stopping the Likewise-open auth daemon"
                start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
                log_end_msg $?
                ;;
       status)
               pidofproc -p $PIDFILE $DAEMON >/dev/null
               status=$?
               if [ $status -eq 0 ]; then
                       log_success_msg "$NAME is running"
               else
                       log_failure_msg "$NAME is not running"
               fi
               exit $status
               ;;

        restart|force-reload)
                $0 stop && sleep 2 && $0 start
                ;;

        *)
                echo "Usage: $0 {start|stop|status|restart|force-reload}"
                exit 1
                ;;
esac
