summaryrefslogtreecommitdiff
blob: 10a737d78fd17bec35b4a5c084614a250ce7507b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/sbin/runscript
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/net-fs/samba/files/samba-init,v 1.19 2010/08/11 19:52:00 scarabeus Exp $

opts="reload"

depend() {
	after slapd
	need net
	use cupsd
}

DAEMONNAME="${SVCNAME##samba.}"
[ "${DAEMONNAME}" != "samba" ] && daemon_list=${DAEMONNAME}

signal_do() {
	local signal="$1"
	[ -z "${signal}" ] && return 0

	local result=0 last_result=0 daemon= cmd_exec=
	for daemon in ${daemon_list} ; do
		eval cmd_exec=\$${daemon}_${signal}
		if [ -n "${cmd_exec}" ]; then
			ebegin "${my_service_name} -> ${signal}: ${daemon}"
			#echo ${cmd} '->' ${!cmd}
			${cmd_exec} > /dev/null
			last_result=$?
			eend ${last_result}
		fi
		result=$(( ${result} + ${last_result} ))
	done
	return ${result}
}
start() {
	# we can't assume that /var/run/ is persistent, so create dir if needed
	[ ! -e /var/run/samba ] && mkdir -p /var/run/samba
	${my_service_PRE}
	signal_do start && return 0
	
	eerror "Error: starting services (see system logs)"
	signal_do stop
	return 1
}
stop() {
	${my_service_PRE}
	if signal_do stop ; then
	    ${my_service_POST}
	    return 0
	fi
}
reload() {
	${my_service_PRE}
	signal_do reload
}