#!/bin/sh
#
# samba        This shell script takes care of starting and stopping
#              samba4 daemons.
#
# chkconfig: - 58 74
# description: Samba 4.0 will be the next version of the Samba suite
# and incorporates all the technology found in both the Samba4 alpha
# series and the stable 3.x series. The primary additional features
# over Samba 3.6 are support for the Active Directory logon protocols
# used by Windows 2000 and above.

### BEGIN INIT INFO
# Provides: samba
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Should-Start: $syslog $named
# Should-Stop: $syslog $named
# Short-Description: start and stop samba4
# Description: Samba 4.0 will be the next version of the Samba suite
# and incorporates all the technology found in both the Samba4 alpha
# series and the stable 3.x series. The primary additional features
# over Samba 3.6 are support for the Active Directory logon protocols
# used by Windows 2000 and above.
### END INIT INFO

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

# Source networking configuration.
SourceIfNotEmpty /etc/sysconfig/network

# Read SAMBA parameters
SourceIfNotEmpty /etc/sysconfig/samba

prog=samba
prog_dir=/usr/local/samba/sbin/
lockfile=/var/lock/subsys/$prog
pidfile=/var/run/$prog.pid

start() {
        [ "$NETWORKING" = "no" ] && exit 1
#       [ -x /usr/sbin/ntpd ] || exit 5
        # Start daemons.
        echo -n $"Starting samba: "
        start_daemon --pidfile "$pidfile" --lockfile "$lockfile" $prog -D $SAMBAOPTIONS
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch $lockfile || \
           RETVAL=1
        return $RETVAL

}


stop() {
        [ "$EUID" != "0" ] && exit 4
        echo -n $"Shutting down samba: "
        stop_daemon --lockfile "$lockfile" $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f $lockfile
        return $RETVAL
}

restart() {
	stop
	start
}

# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
status)
        status $prog
        ;;
restart)
	restart
        ;;
reload)
        echo "Not implemented yet."
        exit 3
        ;;
condrestart)
        [ -f $lockfile ] && restart ||:
        ;;
condstop)
        [ -f $lockfile ] && stop ||:
        ;;
*)
        echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|condstop}"
        exit 2
esac
