#!/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
if [ "$1" == "start" ]; then
pre_run_var="`basename $rc_filename`_opnsense_bootup_run"
eval "pre_run=\$"$pre_run_var""
if [ ! -z "$pre_run" ]; then
eval "$pre_run"
fi
fi
$rc_filename $1
fi
done
-
Ad Schellevis authored
for example, if squid needs some directories to exists before initial run after boot, it could set this in /etc/rc.d.conf/squid squid_opnsense_bootup_run="/usr/local/opnsense/scripts/proxy/setup.sh" which effectively results in setup.sh being started followed by the normal service squid start disadvantage of this, both the service template and the rc system needed to be aware of the setup. advantage, all services which don't need special preperation are configured as they would be on normal FreeBSD
15d88980