1#! /bin/sh
2
3#
4# Samba server control
5#
6
7IS_ON=/etc/chkconfig
8KILLALL=/sbin/killall
9
10SAMBAD=/usr/samba/bin/smbd
11PROFILE_SAMBAD=/usr/samba/bin/smbd.profile
12#SAMBA_OPTS=-d2
13NMBD=/usr/samba/bin/nmbd
14PROFILE_NMBD=/usr/samba/bin/nmbd.profile
15#NMBD_OPTS=-d1
16
17SMBCONTROL=/usr/samba/bin/smbcontrol
18
19if test ! -x $IS_ON ; then
20    IS_ON=true
21fi
22
23if $IS_ON verbose ; then
24    ECHO=echo
25else		# For a quiet startup and shutdown
26    ECHO=:
27fi
28
29if $IS_ON sambaprofiling ; then
30        enable_profiling=yes
31fi
32
33if test "$enable_profiling" -o "$1" = "profile" ; then
34        SAMBAD=$PROFILE_SAMBAD
35        NMBD=$PROFILE_NMBD
36        enable_profiling="yes"
37fi
38
39case $1 in
40start|profile)
41	if $IS_ON samba && test -x $SAMBAD; then
42            /etc/init.d/samba stop
43	    $ECHO "Samba:\c"
44	    $SAMBAD $SAMBA_OPTS -D; $ECHO " smbd\c"
45	    $NMBD $NMBD_OPTS -D; $ECHO " nmbd\c"
46	    $ECHO "."
47	fi
48        if $IS_ON samba && test "$enable_profiling" ; then
49                if test -x $SMBCONTROL; then
50                    $ECHO "Enabling Samba profiling."
51                    $SMBCONTROL smbd profile on > /dev/null 2>&1
52                    $SMBCONTROL nmbd profile on > /dev/null 2>&1
53                fi
54                $KILLALL -HUP pmcd
55        fi
56	;;
57stop)
58	$ECHO "Stopping Samba Servers."
59	$KILLALL -15 smbd nmbd
60	$KILLALL -15 smbd.profile nmbd.profile
61	$KILLALL -15 pmdasamba
62	exit 0
63	;;
64*)
65	echo "usage: /etc/init.d/samba {start|stop|profile}"
66	;;
67esac
68