#!/bin/sh
SAMBADIR=/usr/local/samba
RCSCRIPT=/etc/rc2.d/S99samba
if [ ! -d /usr/bin ]
then exit
fi
killproc() { if [ -f $SAMBADIR/var/locks/$1.pid ]
then
kill `cat $SAMBADIR/var/locks/$1.pid`
else
pid=`/usr/bin/ps -e |
/usr/bin/grep $1 |
/usr/bin/sed -e 's/^ *//' -e 's/ .*//'`
[ "$pid" != "" ] && kill $pid
fi
}
start() {
$SAMBADIR/sbin/smbd -D -s $SAMBADIR/lib/smb.conf
$SAMBADIR/sbin/nmbd -D -s $SAMBADIR/lib/smb.conf
$SAMBADIR/sbin/winbindd
}
stop() {
killproc nmbd
killproc smbd
killproc winbindd
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
'enable')
if [ -h $RCSCRIPT ] ; then
echo "Samba is already enabled."
else
echo "Enabling Samba ... \c"
rm -f $RCSCRIPT
ln -s /etc/init.d/samba $RCSCRIPT
echo "Done"
fi
;;
'disable')
echo "Disabling Samba ... \c"
rm -f $RCSCRIPT
echo "Done"
;;
*)
echo "Usage: /etc/init.d/samba { start | stop | restart | enable | disable }"
;;
esac