#!/bin/sh

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

STATUS=$(/sbin/e-smith/db /home/e-smith/configuration getprop smb status)

case $1 in
    *start)
    	if [ "${STATUS}" != "enabled" ]
	then
	    exit 99
	fi
	;;
esac

smbd=/etc/rc.d/init.d/smbd
nmbd=/etc/rc.d/init.d/nmbd

if [ ! -e $smbd ]; then
    echo "ERROR: $smbd does not exist." 1>&2
    exit 1
fi

if [ ! -e $nmbd ]; then
    echo "ERROR: $nmbd does not exist." 1>&2
    exit 1
fi

case $1 in
    start)
    	:
	;;
    stop)
    	:
	;;
    restart)
    	:
	;;
    reload)
    	/usr/local/bin/svc -h /service/smbd
	exit 0
	;;
    status)
    	:
	;;
    *)
    	echo "Unsupported option: $1" 1>&2
	exit 1
	;;
esac

$nmbd $1 || exit 1
$smbd $1 || exit 1

exit 0
