init: set core file size to unlimited by default
[amitay/samba.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 # 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 # Check whether "netbios disabled" is true
41 #ISNETBIOSDISABLED=$(testparm -s 2>/dev/null | \
42 #       sed -n '/\[global\]/,/^$/p' | \
43 #       grep "disable netbios = Yes" | \
44 #       awk 'BEGIN{FS=" = "}{print $2}')
45
46 ISNETBIOSDISABLED=Yes
47
48 RETVAL=0
49
50
51 start() {
52         KIND="SMB"
53         echo -n $"Starting $KIND services: "
54         ulimit -c unlimited
55         daemon smbd $SMBDOPTIONS
56         RETVAL=$?
57         echo
58         KIND="NMB"
59         if [ x"$ISNETBIOSDISABLED" != x"Yes" ]; then
60                 echo -n $"Starting $KIND services: "
61                 daemon nmbd $NMBDOPTIONS
62                 RETVAL2=$?
63                 echo
64                 [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \
65                         RETVAL=1
66         else
67                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/smb || \
68                         RETVAL=1
69         fi
70         return $RETVAL
71 }       
72
73 stop() {
74         KIND="SMB"
75         echo -n $"Shutting down $KIND services: "
76         killproc smbd
77         RETVAL=$?
78         [ $RETVAL -eq 0 ] && rm -f /var/run/smbd.pid
79         echo
80         KIND="NMB"
81         if [ x"$ISNETBIOSDISABLED" != x"Yes" ]; then
82                 echo -n $"Shutting down $KIND services: "
83                 killproc nmbd 
84                 RETVAL2=$?
85                 [ $RETVAL2 -eq 0 ] && rm -f /var/run/nmbd.pid
86                 [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb 
87                 echo ""
88         else
89                 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/smb 
90                 echo ""
91         fi
92         return $RETVAL
93 }       
94
95 restart() {
96         stop
97         start
98 }       
99
100 reload() {
101         echo -n $"Reloading smb.conf file: "
102         killproc smbd -HUP
103         RETVAL=$?
104         echo
105         return $RETVAL
106 }       
107
108 rhstatus() {
109         status smbd
110         status nmbd
111 }       
112
113 case "$1" in
114   start)
115         start
116         ;;
117   stop)
118         stop
119         ;;
120   restart)
121         restart
122         ;;
123   reload)
124         reload
125         ;;
126   status)
127         rhstatus
128         ;;
129   condrestart)
130         [ -f /var/lock/subsys/smb ] && restart || :
131         ;;
132   *)
133         echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
134         exit 1
135 esac
136
137 exit $?