s3/smbd: sticky write time offset miscalculation causes broken timestamps
[kai/samba-autobuild/.git] / packaging / RHEL-CTDB / setup / 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 DAEMON_COREFILE_LIMIT='unlimited'
22
23 # Avoid using root's TMPDIR
24 unset TMPDIR
25
26 # Source networking configuration.
27 . /etc/sysconfig/network
28
29 if [ -f /etc/sysconfig/samba ]; then
30    . /etc/sysconfig/samba
31 fi
32
33 # Check that networking is up.
34 [ ${NETWORKING} = "no" ] && exit 0
35
36 # Check that smb.conf exists.
37 [ -f /etc/samba/smb.conf ] || exit 0
38
39 # Check that we can write to it... so non-root users stop here
40 [ -w /etc/samba/smb.conf ] || exit 0
41
42 # Check whether "netbios disabled" is true
43 #ISNETBIOSDISABLED=$(testparm -s 2>/dev/null | \
44 #       sed -n '/\[global\]/,/^$/p' | \
45 #       grep "disable netbios = Yes" | \
46 #       awk 'BEGIN{FS=" = "}{print $2}')
47
48 ISNETBIOSDISABLED=Yes
49
50 RETVAL=0
51
52
53 start() {
54         KIND="SMB"
55         echo -n $"Starting $KIND services: "
56         daemon smbd $SMBDOPTIONS
57         RETVAL=$?
58         echo
59         KIND="NMB"
60         if [ x"$ISNETBIOSDISABLED" != x"Yes" ]; then
61                 echo -n $"Starting $KIND services: "
62                 daemon nmbd $NMBDOPTIONS
63                 RETVAL2=$?
64                 echo
65                 [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \
66                         RETVAL=1
67         else
68                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/smb || \
69                         RETVAL=1
70         fi
71         return $RETVAL
72 }       
73
74 stop() {
75         KIND="SMB"
76         echo -n $"Shutting down $KIND services: "
77         killproc smbd
78         RETVAL=$?
79         [ $RETVAL -eq 0 ] && rm -f /var/run/smbd.pid
80         echo
81         KIND="NMB"
82         if [ x"$ISNETBIOSDISABLED" != x"Yes" ]; then
83                 echo -n $"Shutting down $KIND services: "
84                 killproc nmbd 
85                 RETVAL2=$?
86                 [ $RETVAL2 -eq 0 ] && rm -f /var/run/nmbd.pid
87                 [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb 
88                 echo ""
89         else
90                 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/smb 
91                 echo ""
92         fi
93         return $RETVAL
94 }       
95
96 restart() {
97         stop
98         start
99 }       
100
101 reload() {
102         echo -n $"Reloading smb.conf file: "
103         killproc smbd -HUP
104         RETVAL=$?
105         echo
106         return $RETVAL
107 }       
108
109 rhstatus() {
110         status smbd
111         status nmbd
112 }       
113
114 case "$1" in
115   start)
116         start
117         ;;
118   stop)
119         stop
120         ;;
121   restart)
122         restart
123         ;;
124   reload)
125         reload
126         ;;
127   status)
128         rhstatus
129         ;;
130   condrestart)
131         [ -f /var/lock/subsys/smb ] && restart || :
132         ;;
133   *)
134         echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
135         exit 1
136 esac
137
138 exit $?