(app-crypt/gnupg, dev-libs/libgcrypt): Automake 1.14
[portage-overlay.git] / net-fs / samba / files / 3.6 / samba.initd
1 #!/sbin/runscript
2 # Copyright 1999-2014 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License, v2 or later
4 # $Header: /var/cvsroot/gentoo-x86/net-fs/samba/files/3.6/samba.initd,v 1.4 2014/03/14 09:30:41 polynomial-c Exp $
5
6 extra_started_commands="reload"
7 piddir="/var/run/samba"
8
9 depend() {
10         after slapd
11         need net
12         use cupsd
13 }
14
15 DAEMONNAME="${SVCNAME##samba.}"
16 [ "${DAEMONNAME}" != "samba" ] && daemon_list=${DAEMONNAME}
17
18 signal_do() {
19         local signal="$1"
20         [ -z "${signal}" ] && return 0
21
22         local result=0 last_result=0 daemon= cmd_exec=
23         for daemon in ${daemon_list} ; do
24                 eval cmd_exec=\$${daemon}_${signal}
25                 if [ -n "${cmd_exec}" ]; then
26                         ebegin "${my_service_name} -> ${signal}: ${daemon}"
27                         #echo ${cmd} '->' ${!cmd}
28                         ${cmd_exec} > /dev/null
29                         last_result=$?
30                         eend ${last_result}
31                 fi
32                 result=$(( ${result} + ${last_result} ))
33         done
34         return ${result}
35 }
36
37 mkdir_sambadirs() {
38         [ -d "${piddir}" ] || mkdir -p ${piddir}
39 }
40
41 start() {
42         ${my_service_PRE}
43         mkdir_sambadirs
44         signal_do start && return 0
45         
46         eerror "Error: starting services (see system logs)"
47         signal_do stop
48         return 1
49 }
50 stop() {
51         ${my_service_PRE}
52         if signal_do stop ; then
53             ${my_service_POST}
54             return 0
55         fi
56 }
57 reload() {
58         ${my_service_PRE}
59         signal_do reload
60 }