r5265: ensure that the Fedora RPMS build with cups support
[ira/wip.git] / packaging / RedHat / smb.init
1 #!/bin/sh
2 #
3 # chkconfig: 345 81 35
4 # description: Starts and stops the Samba smbd and nmbd daemons \
5 #              used to provide SMB network services.
6
7 # Source function library.
8 . /etc/rc.d/init.d/functions
9
10 # Source networking configuration.
11 . /etc/sysconfig/network
12
13 # Check that networking is up.
14 [ ${NETWORKING} = "no" ] && exit 0
15
16 CONFIG=/etc/samba/smb.conf
17
18 # Check that smb.conf exists.
19 [ -f $CONFIG ] || exit 0
20
21 # See how we were called.
22 case "$1" in
23   start)
24         echo -n "Starting SMB services: "
25         daemon smbd -D  
26         daemon nmbd -D 
27         echo
28         touch /var/lock/subsys/smb
29         ;;
30   stop)
31         echo -n "Shutting down SMB services: "
32
33         ## we have to get all the smbd process here instead of just the
34         ## main parent (i.e. killproc) because it can take a long time
35         ## for an individual process to process a TERM signal
36         smbdpids=`ps guax | grep smbd | grep -v grep | awk '{print $2}'`
37         for pid in $smbdpids; do
38                 kill -TERM $pid
39         done
40         ## nmbd is ok to kill using killproc()
41         killproc nmbd -TERM
42         rm -f /var/lock/subsys/smb
43         echo ""
44         ;;
45   status)
46         status smbd
47         status nmbd
48         ;;
49   restart)
50         echo -n "Restarting SMB services: "
51         $0 stop
52         $0 start
53         echo "done."
54         ;;
55   *)
56         echo "Usage: smb {start|stop|restart|status}"
57         exit 1
58 esac
59