[nycbug-talk] rc.conf / rc'ng hacking
Matthew Story
matt at tablethotels.com
Thu Oct 13 12:02:41 EDT 2011
On Oct 13, 2011, at 11:32 AM, Mark Saad wrote:
> So I was tired,lazy yesterday and I was wondering how does rc'ng
> handle this , surely there has to be a rc'ng function to suck in from
> rc.subr that I can call to get my nic type etc . I cant find anything,
> can someone shed some light on how this handled ? Is there an easier
> way to this ?
you could use /etc/rc.conf.local, from man 5 rc.conf
The /etc/rc.conf file is included from the file /etc/defaults/rc.conf,
which specifies the default settings for all the available options.
Options need only be specified in /etc/rc.conf when the system adminis-
trator wishes to override these defaults. The file /etc/rc.conf.local is
used to override settings in /etc/rc.conf for historical reasons. See
the rc_conf_files variable below.
if you need more facility than that, you can alter the rc_conf_files variable in /etc/defaults/rc.conf:
rc_conf_files="/etc/rc.conf /etc/rc.conf.local"
for your inst script, you could start with the old rc_conf_files setting, and then ...
awk -F '=' 'BEGIN { OFS=FS; } $1 == "rc_conf_files" { sub(/\"$/, " my.rc.conf.local\"", $2); } { print; }' /etc/defaults/rc.conf > /etc/defaults/rc.conf.new && mv /etc/defaults/rc.conf.new /etc/defaults/rc.conf
will add 'my.rc.conf.local" to the rc_conf_files string. As rc conf files are just shell, you could cp the rc_conf_files functionallity from defaults to your /etc/rc.conf file and preserve the defaults file (as suggested in the defaults documentation), relevant code from rc.conf below:
##############################################################
### Define source_rc_confs, the mechanism used by /etc/rc.* ##
### scripts to source rc_conf_files overrides safely. ##
##############################################################
if [ -z "${source_rc_confs_defined}" ]; then
source_rc_confs_defined=yes
source_rc_confs () {
local i sourced_files
for i in ${rc_conf_files}; do
case ${sourced_files} in
*:$i:*) ;;
*)
sourced_files="${sourced_files}:$i:"
if [ -r $i ]; then
. $i
fi
;; esac
done
}
fi
if you care less for safety, you can just:
[ -r "rc.special.conf" ] && . "rc.special.conf"
or in your /etc/rc.conf, breakout your service daemon specific configs and then do the same pattern:
# for apache
[ -r "/etc/rc.conf.apache" ] && . "/etc/rc.conf.apache"
# for sendmail
[ -r "/etc/rc.conf.sendmail" ] && . "/etc/rc.conf.sendmail"
# etc ...
>
> ---
> Mark Saad | mark.saad at ymail.com
> _______________________________________________
> talk mailing list
> talk at lists.nycbug.org
> http://lists.nycbug.org/mailman/listinfo/talk
>
best of luck.
-matt
More information about the talk
mailing list