added Mandrake support from 2.2
[gd/samba-autobuild/.git] / packaging / Mandrake / smb.init
1 #!/bin/sh
2 #
3 # chkconfig: - 91 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 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
14 fi
15
16 # Source networking configuration.
17 . /etc/sysconfig/network
18
19 # Check that networking is up.
20 [ ${NETWORKING} = "no" ] && exit 0
21
22 # Check that smb.conf exists.
23 [ -f /etc/smb.conf ] || exit 0
24
25 RETVAL=0
26
27
28 start() {
29         echo -n "Starting SMB services: "
30         daemon smbd -D  
31         RETVAL=$?
32         echo
33         echo -n "Starting NMB services: "
34         daemon nmbd -D 
35         RETVAL2=$?
36         echo
37         [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \
38            RETVAL=1
39         return $RETVAL
40 }       
41 stop() {
42         echo -n "Shutting down SMB services: "
43         killproc smbd
44         RETVAL=$?
45         echo
46         echo -n "Shutting down NMB services: "
47         killproc nmbd
48         RETVAL2=$?
49         [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb
50         echo ""
51         return $RETVAL
52 }       
53 restart() {
54         stop
55         start
56 }       
57 reload() {
58         echo -n "Reloading smb.conf file: "
59         killproc smbd -HUP
60         RETVAL=$?
61         echo
62         return $RETVAL
63 }       
64 mdkstatus() {
65         status smbd
66         status nmbd
67 }       
68
69 case "$1" in
70   start)
71         start
72         ;;
73   stop)
74         stop
75         ;;
76   restart)
77         restart
78         ;;
79   reload)
80         reload
81         ;;
82   status)
83         mdkstatus
84         ;;
85   condrestart)
86         [ -f /var/lock/subsys/smb ] && restart || :
87         ;;
88   *)
89         echo "Usage: $0 {start|stop|restart|status|condrestart}"
90         exit 1
91 esac
92
93 exit $?