#!/bin/sh
#
. /opt/HAC/bin/rsf.sh

service=${RSF_SERVICE:-"service_name"}
script="`basename $0`"

case "${COMPANY_OS}" in
'freebsd')
    SMBCONTROL="/usr/local/bin/smbcontrol"
    SMBSTATUS="/usr/local/bin/smbstatus"
    ;;
*)
    SMBCONTROL="smbcontrol"
    SMBSTATUS="smbstatus"
	;;
esac


case "${1}" in
    'start')
        rc_exit ${service} ${RSF_OK}
        ;;

    'stop')
        if [ "${PROP_SAMBAPROFILE}" != "adsmemberserver" ] ; then
            if [ "${PROP_SMBENABLED}" = "true" ] ; then
                ${SMBCONTROL} smbd close-share '*'
                dated_echo "=========  ${SMBSTATUS} ========="
                ${SMBSTATUS}
                dated_echo "=========  ${SMBSTATUS} ========="
            else
                dated_echo "Samba share handling not enabled - nothing to do"
            fi
        fi
        rc_exit ${service} ${RSF_OK}
        ;;

    'check')
	exit ${RSF_CHECK_NORESRC}
	;;

    *)
	rc_exit ${service} ${RSF_WARN} "usage: $0 <start|stop|check>"
	;;
esac
