/[baselayout]/branches/baselayout-1_12/sbin/rc-daemon.sh
Gentoo

Diff of /branches/baselayout-1_12/sbin/rc-daemon.sh

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

Revision 2166 Revision 2167
353# Return the result of start_daemon or stop_daemon depending on 353# Return the result of start_daemon or stop_daemon depending on
354# how we are called 354# how we are called
355start-stop-daemon() { 355start-stop-daemon() {
356 local args="$( requote "$@" )" result i 356 local args="$( requote "$@" )" result i
357 local cmd pidfile pid stopping signal nothing=false 357 local cmd pidfile pid stopping signal nothing=false
358 local daemonfile="${svcdir}/daemons/${SVCNAME}" 358 local daemonfile=
359 local -a RC_DAEMONS=() RC_PIDFILES=() 359 local -a RC_DAEMONS=() RC_PIDFILES=()
360 360
361 if [[ -n ${SVCNAME} ]] ; then
362 daemonfile="${svcdir}/daemons/${SVCNAME}"
361 [[ -e ${daemonfile} ]] && source "${daemonfile}" 363 [[ -e ${daemonfile} ]] && source "${daemonfile}"
364 fi
362 365
363 rc_setup_daemon_vars 366 rc_setup_daemon_vars
364 367
365 # We pass --oknodo and --test directly to start-stop-daemon and return 368 # We pass --oknodo and --test directly to start-stop-daemon and return
366 if ${nothing}; then 369 if ${nothing}; then
369 fi 372 fi
370 373
371 if ${stopping}; then 374 if ${stopping}; then
372 rc_stop_daemon 375 rc_stop_daemon
373 result="$?" 376 result="$?"
374 if [[ ${result} == "0" ]]; then 377 if [[ ${result} == "0" && -n ${daemonfile} ]]; then
375 # We stopped the daemon successfully 378 # We stopped the daemon successfully
376 # so we remove it from our state 379 # so we remove it from our state
377 for (( i=0; i<${#RC_DAEMONS[@]}; i++ )); do 380 for (( i=0; i<${#RC_DAEMONS[@]}; i++ )); do
378 # We should really check for valid cmd AND pidfile 381 # We should really check for valid cmd AND pidfile
379 # But most called to --stop only set the pidfile 382 # But most called to --stop only set the pidfile
387 done 390 done
388 fi 391 fi
389 else 392 else
390 rc_start_daemon 393 rc_start_daemon
391 result="$?" 394 result="$?"
392 if [[ ${result} == "0" ]]; then 395 if [[ ${result} == "0" && -n ${daemonfile} ]]; then
393 # We started the daemon sucessfully 396 # We started the daemon sucessfully
394 # so we add it to our state 397 # so we add it to our state
395 local max="${#RC_DAEMONS[@]}" 398 local max="${#RC_DAEMONS[@]}"
396 for (( i=0; i<${max}; i++ )); do 399 for (( i=0; i<${max}; i++ )); do
397 if [[ ${RC_DAEMONS[i]} == "{cmd}" \ 400 if [[ ${RC_DAEMONS[i]} == "{cmd}" \
408 fi 411 fi
409 412
410 # Write the new list of daemon states for this service 413 # Write the new list of daemon states for this service
411 if [[ ${#RC_DAEMONS[@]} == "0" ]]; then 414 if [[ ${#RC_DAEMONS[@]} == "0" ]]; then
412 [[ -f ${daemonfile} ]] && rm -f "${daemonfile}" 415 [[ -f ${daemonfile} ]] && rm -f "${daemonfile}"
413 else 416 elif [[ -n ${daemonfile} ]] ; then
414 echo "RC_DAEMONS[0]=\"${RC_DAEMONS[0]}\"" > "${daemonfile}" 417 echo "RC_DAEMONS[0]=\"${RC_DAEMONS[0]}\"" > "${daemonfile}"
415 echo "RC_PIDFILES[0]=\"${RC_PIDFILES[0]}\"" >> "${daemonfile}" 418 echo "RC_PIDFILES[0]=\"${RC_PIDFILES[0]}\"" >> "${daemonfile}"
416 419
417 for (( i=1; i<${#RC_DAEMONS[@]}; i++ )); do 420 for (( i=1; i<${#RC_DAEMONS[@]}; i++ )); do
418 echo "RC_DAEMONS[${i}]=\"${RC_DAEMONS[i]}\"" >> "${daemonfile}" 421 echo "RC_DAEMONS[${i}]=\"${RC_DAEMONS[i]}\"" >> "${daemonfile}"

Legend:
Removed from v.2166  
changed lines
  Added in v.2167

  ViewVC Help
Powered by ViewVC 1.1.20