1 |
slords |
1.1 |
#!/bin/sh |
2 |
|
|
# |
3 |
|
|
# chkconfig: - 91 35 |
4 |
|
|
# description: Starts and stops the Samba nmbd daemon \ |
5 |
|
|
# used to provide SMB network services. |
6 |
|
|
# |
7 |
|
|
# pidfile: /var/run/samba/nmbd.pid |
8 |
|
|
# config: /etc/samba/smb.conf |
9 |
|
|
|
10 |
|
|
|
11 |
|
|
# Source function library. |
12 |
|
|
if [ -f /etc/init.d/functions ] ; then |
13 |
|
|
. /etc/init.d/functions |
14 |
|
|
elif [ -f /etc/rc.d/init.d/functions ] ; then |
15 |
|
|
. /etc/rc.d/init.d/functions |
16 |
|
|
else |
17 |
|
|
exit 1 |
18 |
|
|
fi |
19 |
|
|
|
20 |
|
|
# Source auto-configure functions |
21 |
|
|
[ -e /etc/init.d/functions-automagic ] && source /etc/init.d/functions-automagic |
22 |
|
|
[ -e /etc/sysconfig/automagic ] && source /etc/sysconfig/automagic |
23 |
|
|
|
24 |
|
|
# Avoid using root's TMPDIR |
25 |
|
|
unset TMPDIR |
26 |
|
|
|
27 |
|
|
# Source networking configuration. |
28 |
|
|
. /etc/sysconfig/network |
29 |
|
|
|
30 |
|
|
if [ -f /etc/sysconfig/samba ]; then |
31 |
|
|
. /etc/sysconfig/samba |
32 |
|
|
fi |
33 |
|
|
|
34 |
|
|
# Check that networking is up. |
35 |
|
|
[ ${NETWORKING} = "no" ] && exit 1 |
36 |
|
|
|
37 |
|
|
# Check that smb.conf exists. |
38 |
|
|
[ -f /etc/samba/smb.conf ] || exit 6 |
39 |
|
|
|
40 |
|
|
RETVAL=0 |
41 |
|
|
|
42 |
|
|
automagic() { |
43 |
|
|
# Bail if no-automagic is not wanted |
44 |
|
|
if [ "$AUTOMAGIC" == "off" ]; then |
45 |
|
|
return |
46 |
|
|
fi |
47 |
|
|
|
48 |
|
|
sed -i -e "s/^interfaces.*/interfaces = lo $AUTOMAGIC_LANIFS/" /etc/samba/smb.conf |
49 |
|
|
sed -i -e "s/^bind interfaces only.*/bind interfaces only = yes/" /etc/samba/smb.conf |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
start() { |
53 |
|
|
automagic |
54 |
|
|
KIND="NMB" |
55 |
|
|
echo -n $"Starting $KIND services: " |
56 |
|
|
daemon nmbd $NMBDOPTIONS |
57 |
|
|
RETVAL=$? |
58 |
|
|
echo |
59 |
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/nmb || \ |
60 |
|
|
RETVAL=1 |
61 |
|
|
return $RETVAL |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
stop() { |
65 |
|
|
KIND="NMB" |
66 |
|
|
echo -n $"Shutting down $KIND services: " |
67 |
|
|
killproc nmbd |
68 |
|
|
RETVAL=$? |
69 |
|
|
echo |
70 |
|
|
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/nmb |
71 |
|
|
return $RETVAL |
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
restart() { |
75 |
|
|
stop |
76 |
|
|
start |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
reload() { |
80 |
|
|
echo -n $"Reloading smb.conf file: " |
81 |
|
|
killproc smbd -HUP |
82 |
|
|
RETVAL=$? |
83 |
|
|
echo |
84 |
|
|
return $RETVAL |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
rhstatus() { |
88 |
|
|
status nmbd |
89 |
|
|
return $? |
90 |
|
|
} |
91 |
|
|
|
92 |
|
|
|
93 |
|
|
# Allow status as non-root. |
94 |
|
|
if [ "$1" = status ]; then |
95 |
|
|
rhstatus |
96 |
|
|
exit $? |
97 |
|
|
fi |
98 |
|
|
|
99 |
|
|
# Check that we can write to it... so non-root users stop here |
100 |
|
|
[ -w /etc/samba/smb.conf ] || exit 4 |
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
case "$1" in |
105 |
|
|
start) |
106 |
|
|
start |
107 |
|
|
;; |
108 |
|
|
stop) |
109 |
|
|
stop |
110 |
|
|
;; |
111 |
|
|
restart) |
112 |
|
|
restart |
113 |
|
|
;; |
114 |
|
|
reload) |
115 |
|
|
reload |
116 |
|
|
;; |
117 |
|
|
status) |
118 |
|
|
rhstatus |
119 |
|
|
;; |
120 |
|
|
condrestart) |
121 |
|
|
[ -f /var/lock/subsys/nmb ] && restart || : |
122 |
|
|
;; |
123 |
|
|
*) |
124 |
|
|
echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}" |
125 |
|
|
exit 2 |
126 |
|
|
esac |
127 |
|
|
|
128 |
|
|
exit $? |