1#!/bin/sh 2# 3# $FreeBSD: src/etc/rc.d/localdaemons,v 1.2 2003/05/05 15:38:41 mtm Exp $ 4# $DragonFly: src/etc/rc.d/localdaemons,v 1.2 2004/01/27 00:42:45 rob Exp $ 5# 6 7# PROVIDE: localdaemons 8# REQUIRE: abi 9# BEFORE: securelevel 10# KEYWORD: DragonFly shutdown 11 12. /etc/rc.subr 13 14name="localdaemons" 15start_cmd="locald_start" 16stop_cmd="locald_stop" 17 18locald_start() 19{ 20 # For each dir in $local_startup, search for init scripts matching *.sh 21 # 22 case ${local_startup} in 23 [Nn][Oo] | '') 24 ;; 25 *) 26 echo -n 'Local package initialization:' 27 slist="" 28 if [ -z "${script_name_sep}" ]; then 29 script_name_sep=" " 30 fi 31 for dir in ${local_startup}; do 32 if [ -d "${dir}" ]; then 33 for script in ${dir}/*.sh; do 34 slist="${slist}${script_name_sep}${script}" 35 done 36 fi 37 done 38 script_save_sep="$IFS" 39 IFS="${script_name_sep}" 40 for script in ${slist}; do 41 if [ -x "${script}" ]; then 42 (set -T 43 trap 'exit 1' 2 44 ${script} start) 45 elif [ -f "${script}" -o -L "${script}" ]; then 46 echo -n " (skipping ${script##*/}, not executable)" 47 fi 48 done 49 IFS="${script_save_sep}" 50 echo '.' 51 ;; 52 esac 53} 54 55locald_stop() 56{ 57 echo -n 'Shutting down daemon processes:' 58 59 # For each dir in $local_startup, search for init scripts matching *.sh 60 case ${local_startup} in 61 [Nn][Oo] | '') 62 ;; 63 *) 64 slist="" 65 if [ -z "${script_name_sep}" ]; then 66 script_name_sep=" " 67 fi 68 for dir in ${local_startup}; do 69 if [ -d "${dir}" ]; then 70 for script in ${dir}/*.sh; do 71 slist="${slist}${script_name_sep}${script}" 72 done 73 fi 74 done 75 script_save_sep="$IFS" 76 IFS="${script_name_sep}" 77 for script in `reverse_list ${slist}`; do 78 if [ -x "${script}" ]; then 79 (set -T 80 trap 'exit 1' 2 81 ${script} stop) 82 fi 83 done 84 IFS="${script_save_sep}" 85 echo '.' 86 ;; 87 esac 88} 89 90load_rc_config $name 91run_rc_command "$1" 92