Merge from 3.0:
[gd/samba/.git] / packaging / Fedora / 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 # pidfile: /var/run/samba/smbd.pid
8 # pidfile: /var/run/samba/nmbd.pid
9 # config:  /etc/samba/smb.conf
10
11
12 # Source function library.
13 if [ -f /etc/init.d/functions ] ; then
14   . /etc/init.d/functions
15 elif [ -f /etc/rc.d/init.d/functions ] ; then
16   . /etc/rc.d/init.d/functions
17 else
18   exit 0
19 fi
20
21 # Avoid using root's TMPDIR
22 unset TMPDIR
23
24 # Source networking configuration.
25 . /etc/sysconfig/network
26
27 if [ -f /etc/sysconfig/samba ]; then
28    . /etc/sysconfig/samba
29 fi
30
31 # Check that networking is up.
32 [ ${NETWORKING} = "no" ] && exit 0
33
34 # Check that smb.conf exists.
35 [ -f /etc/samba/smb.conf ] || exit 0
36
37 # Check that we can write to it... so non-root users stop here
38 [ -w /etc/samba/smb.conf ] || exit 0
39
40
41 RETVAL=0
42
43
44 start() {
45         KIND="SMB"
46         echo -n $"Starting $KIND services: "
47         daemon smbd $SMBDOPTIONS
48         RETVAL=$?
49         echo
50         KIND="NMB"
51         echo -n $"Starting $KIND services: "
52         daemon nmbd $NMBDOPTIONS
53         RETVAL2=$?
54         echo
55         [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \
56            RETVAL=1
57         return $RETVAL
58 }       
59
60 stop() {
61         KIND="SMB"
62         echo -n $"Shutting down $KIND services: "
63         killproc smbd
64         RETVAL=$?
65         echo
66         KIND="NMB"
67         echo -n $"Shutting down $KIND services: "
68         killproc nmbd
69         RETVAL2=$?
70         [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb
71         echo ""
72         return $RETVAL
73 }       
74
75 restart() {
76         stop
77         start
78 }       
79
80 reload() {
81         echo -n $"Reloading smb.conf file: "
82         killproc smbd -HUP
83         RETVAL=$?
84         echo
85         return $RETVAL
86 }       
87
88 rhstatus() {
89         status smbd
90         status nmbd
91 }       
92
93 case "$1" in
94   start)
95         start
96         ;;
97   stop)
98         stop
99         ;;
100   restart)
101         restart
102         ;;
103   reload)
104         reload
105         ;;
106   status)
107         rhstatus
108         ;;
109   condrestart)
110         [ -f /var/lock/subsys/smb ] && restart || :
111         ;;
112   *)
113         echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
114         exit 1
115 esac
116
117 exit $?