#!/bin/sh

###Daemontools run file to manage the winbindd daemon
###Work based off of smbd damontools run file.

. /etc/sysconfig/network
 
#if [ -f /etc/sysconfig/samba ]; then
#   . /etc/sysconfig/samba
#fi
# We currently don't care about /etc/sysconfig/samba, but that may change.

status=$(/sbin/e-smith/config getprop smb status)
if [ "$status" = "disabled" ]
then
    /sbin/e-smith/config setprop winbind status disabled
    sv d .
    exit
fi

winbindd=/usr/sbin/winbindd

[ -f $winbindd ] || exit 1
 
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1
 
# Check that smb.conf exists.
[ -f /etc/samba/smb.conf ] || exit 1
 
# Check that we can write to it... so non-root users stop here
[ -w /etc/samba/smb.conf ] || exit 1

exec 2>&1
exec $winbindd -F
