Subversion Repositories configs

Rev

Rev 4 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 - 1
#!/bin/sh
2
#
3
# chkconfig: - 91 35
4
# description: Starts and stops the Samba smbd daemon \
5
#	       used to provide SMB network services.
6
#
7
# pidfile: /var/run/samba/smbd.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
# Avoid using root's TMPDIR
21
unset TMPDIR
22
 
23
# Source networking configuration.
24
. /etc/sysconfig/network
25
 
26
if [ -f /etc/sysconfig/samba ]; then
27
   . /etc/sysconfig/samba
28
fi
29
 
30
# Check that networking is up.
31
[ ${NETWORKING} = "no" ] && exit 1
32
 
33
# Check that smb.conf exists.
34
[ -f /etc/samba/smb.conf ] || exit 6
35
 
36
RETVAL=0
37
 
38
 
39
start() {
40
        KIND="SMB"
41
	echo -n $"Starting $KIND services: "
42
	daemon smbd $SMBDOPTIONS
43
	RETVAL=$?
44
	echo
45
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/smb || \
46
	   RETVAL=1
47
	return $RETVAL
48
}
49
 
50
stop() {
51
        KIND="SMB"
52
	echo -n $"Shutting down $KIND services: "
53
	killproc smbd
54
	RETVAL=$?
55
	echo
56
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/smb
57
	return $RETVAL
58
}
59
 
60
restart() {
61
	stop
62
	start
63
}
64
 
65
reload() {
66
        echo -n $"Reloading smb.conf file: "
67
	killproc smbd -HUP
68
	RETVAL=$?
69
	echo
70
	return $RETVAL
71
}
72
 
73
rhstatus() {
74
	status -l smb smbd
75
	return $?
76
}
77
 
78
configtest() {
79
	# First run testparm and check the exit status.
80
	# If it ain't 0, there was a problem, show them the testparm output.
81
	# Most of the time, though, testparm gives 0 - obvious problems
82
	# (like a missing config file) that testparm normally tells us about
83
	# have been checked for earlier in this script.
84
	/usr/bin/testparm -s &> /dev/null
85
	RETVAL=$?
86
	if [ $RETVAL -ne 0 ]; then
87
		/usr/bin/testparm -s
88
		exit $RETVAL
89
	fi
90
 
91
 
92
	# Note: testparm returns 0 even if it has unknown parameters.
93
	# Check for the word 'unknown', and print the relevant section
94
	# if it appears. Return '3' because testparm doesn't usually
95
	# use that.
96
	/usr/bin/testparm -s 2>&1 | grep -i unknown &> /dev/null
97
	if [ $? -eq 0 ]; then
98
		RETVAL=3
99
		/usr/bin/testparm -s 2>&1 | grep -i unknown
100
		exit $RETVAL
101
	fi
102
 
103
	# If testparm didn't fail and there weren't any unknowns, exit.
104
	echo Syntax OK
105
	return $RETVAL
106
}
107
 
108
 
109
# Allow status as non-root.
110
if [ "$1" = status ]; then
111
       rhstatus
112
       exit $?
113
fi
114
 
34 - 115
# Check that we are root ... so non-root users stop here
116
[  `id -u` -eq  "0" ] ||  exit 4
4 - 117
 
118
 
119
 
120
case "$1" in
121
  start)
122
  	start
123
	;;
124
  stop)
125
  	stop
126
	;;
127
  restart)
128
  	restart
129
	;;
130
  reload)
131
  	reload
132
	;;
133
  status)
134
  	rhstatus
135
	;;
136
  configtest)
137
  	configtest
138
	;;
139
  condrestart)
140
  	[ -f /var/lock/subsys/smb ] && restart || :
141
	;;
142
  *)
143
	echo $"Usage: $0 {start|stop|restart|reload|configtest|status|condrestart}"
144
	exit 2
145
esac
146
 
147
exit $?