rc.subr revision 1.4
1[ -z "$local_rcconf" ] && . /etc/rc.conf 2 3rc_err() { 4 echo $1 5 exit 1 6} 7 8rc_start() { 9 type rc_pre >/dev/null && rc_pre 10 $daemon $daemon_flags >/dev/null 11} 12 13rc_check() { 14 pgrep -f "^$pexp" >/dev/null 15} 16 17rc_reload() { 18 pkill -HUP -f "^$pexp" 19} 20 21rc_stop() { 22 pkill -f "^$pexp" 23 type rc_post >/dev/null && rc_post || return 0 24} 25 26rc_cmd() { 27 [ `id -u` -eq 0 -o X"$1" = "Xcheck" ] || rc_err "$0: need root privileges" 28 [ -n "$daemon" ] || rc_err "$0: daemon is not set" 29 [ -n "$pexp" ] || pexp="$daemon${daemon_flags:+ $daemon_flags}" 30 31 case "$1" in 32 check) 33 rc_check 34 ;; 35 start) 36 rc_check || rc_start 37 ;; 38 stop) 39 rc_stop 40 ;; 41 reload) 42 rc_check && rc_reload 43 ;; 44 restart) 45 rc_stop 46 while rc_check; do 47 sleep 1 48 done 49 rc_start 50 ;; 51 *) 52 rc_err "usage: $0 {start|check|reload|restart|stop}" 53 esac 54} 55