/[baselayout]/trunk/sbin/rc-daemon.sh
Gentoo

Diff of /trunk/sbin/rc-daemon.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1783 Revision 1784
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2005 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3 3
4# RC functions to work with daemons 4# RC functions to work with daemons
5# Basically we're a fancy wrapper for start-stop-daemon 5# Basically we're a fancy wrapper for start-stop-daemon
6# and should be called as such. This means that our init scripts 6# and should be called as such. This means that our init scripts
33# void rc_shift_args(void) 33# void rc_shift_args(void)
34# 34#
35# Proccess vars - makes things easier by using the shift command 35# Proccess vars - makes things easier by using the shift command
36# and indirect variables 36# and indirect variables
37rc_shift_args() { 37rc_shift_args() {
38 local addvar
39
38 while [[ $# != "0" ]]; do 40 while [[ $# != "0" ]]; do
39 if [[ $1 != "-"* && -n ${addvar} ]]; then 41 if [[ $1 != "-"* && -n ${addvar} ]]; then
40 if [[ -z ${!addvar} ]]; then 42 if [[ -z ${!addvar} ]]; then
41 eval "${addvar}=\"$1\"" 43 eval "${addvar}=\"$1\""
42 else 44 else
93 local -a sargs=( "${args%% \'--\' *}" ) 95 local -a sargs=( "${args%% \'--\' *}" )
94 local -a eargs 96 local -a eargs
95 local x="${args// \'--\' /}" 97 local x="${args// \'--\' /}"
96 [[ ${x} != "${args}" ]] && eargs=( "${args##* \'--\' }" ) 98 [[ ${x} != "${args}" ]] && eargs=( "${args##* \'--\' }" )
97 99
98 rc_shift_args ${sargs[@]} 100 eval rc_shift_args "${sargs[@]}"
99 101
100 [[ -z ${cmd} ]] && cmd="${name}" 102 [[ -z ${cmd} ]] && cmd="${name}"
101 103
102 # We may want to launch the daemon with a custom command 104 # We may want to launch the daemon with a custom command
103 # This is mainly useful for debugging with apps like valgrind, strace 105 # This is mainly useful for debugging with apps like valgrind, strace
222 224
223 [[ -s ${pidfile} ]] || return 0 225 [[ -s ${pidfile} ]] || return 0
224 226
225 read pid < "${pidfile}" 227 read pid < "${pidfile}"
226 pids=" ${pids} " 228 pids=" ${pids} "
227 [[ ${pids// ${pid} } != "${pids}" ]] 229 [[ ${pids// ${pid} /} != "${pids}" ]]
228} 230}
229 231
230# int rc_start_daemon(void) 232# int rc_start_daemon(void)
231# 233#
232# We don't do anyting fancy - just pass the given options 234# We don't do anyting fancy - just pass the given options
274 if [[ -s ${pidfile} ]]; then 276 if [[ -s ${pidfile} ]]; then
275 read pid < "${pidfile}" 277 read pid < "${pidfile}"
276 # Check that the given program is actually running the pid 278 # Check that the given program is actually running the pid
277 if [[ -n ${pids} ]]; then 279 if [[ -n ${pids} ]]; then
278 pids=" ${pids} " 280 pids=" ${pids} "
279 [[ ${pids// ${pid} } == ${pids} ]] && return 1 281 [[ ${pids// ${pid} /} == "${pids}" ]] && return 1
280 fi 282 fi
281 pids=${pid} 283 pids="${pid}"
282 fi 284 fi
283 285
284 # If there's nothing to kill then return without error 286 # If there's nothing to kill then return without error
285 [[ -z ${pids} ]] && return 0 287 [[ -z ${pids} ]] && return 0
286 288

Legend:
Removed from v.1783  
changed lines
  Added in v.1784

  ViewVC Help
Powered by ViewVC 1.1.20