sync with HEAD
[Samba.git] / packaging / Mandrake / smb.init
blobbdc151870950908970d01fecf8b85a05af100de9
1 #!/bin/sh
3 # chkconfig: 35 91 9
4 # description: Starts and stops the Samba smbd and nmbd daemons \
5 # used to provide SMB network services.
7 # Source function library.
8 if [ -f /etc/init.d/functions ] ; then
9 . /etc/init.d/functions
10 elif [ -f /etc/rc.d/init.d/functions ] ; then
11 . /etc/rc.d/init.d/functions
12 else
13 exit 0
16 # Source networking configuration.
17 . /etc/sysconfig/network
19 # Check that networking is up.
20 [ ${NETWORKING} = "no" ] && exit 0
22 # Check that smb.conf exists.
23 [ -f /etc/samba/smb.conf ] || exit 0
25 RETVAL=0
28 start() {
29 # If CUPS is used as printing system, reload smb after a 1 minute delay
30 # to allow the printers to appear properly as samba shares.
31 if killall -0 cupsd 2>/dev/null; then
32 ( sleep 60 && killproc smbd -HUP ) &
34 export TMPDIR="/var/tmp"
35 echo -n "Starting SMB services: "
36 daemon smbd -D
37 RETVAL=$?
38 echo
39 echo -n "Starting NMB services: "
40 daemon nmbd -D
41 RETVAL2=$?
42 echo
43 [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \
44 RETVAL=1
45 return $RETVAL
47 stop() {
48 echo -n "Shutting down SMB services: "
49 killproc smbd
50 RETVAL=$?
51 echo
52 echo -n "Shutting down NMB services: "
53 killproc nmbd
54 RETVAL2=$?
55 [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb
56 echo ""
57 return $RETVAL
59 restart() {
60 stop
61 start
63 reload() {
64 export TMPDIR="/var/tmp"
65 echo -n "Reloading smb.conf file: "
66 killproc smbd -HUP
67 RETVAL=$?
68 echo
69 return $RETVAL
71 mdkstatus() {
72 status smbd
73 status nmbd
76 case "$1" in
77 start)
78 start
80 stop)
81 stop
83 restart)
84 restart
86 reload)
87 reload
89 status)
90 mdkstatus
92 condrestart)
93 [ -f /var/lock/subsys/smb ] && restart || :
96 echo "Usage: $0 {start|stop|restart|status|condrestart}"
97 exit 1
98 esac
100 exit $?