#!/bin/sh # check which services to enable if [ -f /etc/rc.conf ]; then . /etc/rc.conf fi for RC_CONF in $(ls /etc/rc.conf.d); do . /etc/rc.conf.d/${RC_CONF} done # probe all deamons in /usr/local/etc/rc.d/ ls /usr/local/etc/rc.d/* | while read rc_filename; do # read rc scripts and parse name and rcvar variables _file=`basename $rc_filename` eval `/usr/bin/grep "name[[:blank:]]*=" $rc_filename | /usr/bin/head -n 1` eval `grep "rcvar[[:blank:]]*=" $rc_filename | /usr/bin/sed '/^$/d'` # check if service is enabled eval "is_enabled=\$"$rcvar"" # start/stop service if [ "$is_enabled" == "YES" ]; then $rc_filename $1 fi done