Subject: Re: What about startup scripts??
To: Frederick Bruckman <fb@enteract.com>
From: Al B. Snell <alaric@alaric-snell.com>
List: tech-pkg
Date: 01/03/2001 18:15:00
On Wed, 3 Jan 2001, Frederick Bruckman wrote:

> > These scripts, we concurred earlier, should all source
> > /usr/pkg/etc/rc.conf rather than having seperate config files.
> 
> No. Please look at some existing rc.d scripts, and at /etc/rc. The
> rc.d scripts don't source config files. /etc/rc sources /etc/rc.conf,
> which in turn sources /etc/defaults/rc.conf, and then /etc/rc calls
> the shell function run_rc_script() over each script.

We're not talking about how to do the existing rc.d scripts; they only
cover parts of the base system. This discussion is of rc.d scripts for
packages. You are right in saying that there's no need for the existing
rc.d scripts to source stuff from /usr :-)

But that doesn't mean the rc.d scripts for packages can't source stuff
from /usr!

> > /usr/pkg/etc/rc.conf, being a shell script, can contain conditionals on
> > hostname, conditionals on a hypothetical 'hosttype' value stored in /etc
> > for people running large clusters that can be subdivided nito groups, or
> > it can just source /etc/rc.pkg.conf after setting up defaults, to allow
> > for per-machine overrides.
> 
> That's exactly backwards. If you have a monolithic / and /usr, you
> could source /usr/{pkg/,X11R6/,local/}etc/rc.conf in /etc/rc.conf, but
> otherwise, it can't work.

Why can't it work?

My example "xfstt" rc.d script might look like (not got access to a 1.5
system here so I'm guessing the rcorder keyword syntax and stuff):

/etc/rc.d/xfstt
-------------------B<---------------------------
#!/usr/bin/sh
# REQUIRE: everything-mounted ...
# KEYWORD: package
# PROVIDE: xfstt

. /etc/rc.conf
. /usr/pkg/etc/rc.conf

COMMAND="/usr/pkg/bin/xfstt"
...
do_rc_command()
-------------------B<---------------------------

/usr/pkg/etc/rc.conf - normal setup:
-------------------B<---------------------------
. /usr/pkg/etc/defaults/rc.conf

	xfstt="YES"	xfstt_flags="..."

-------------------B<---------------------------

/usr/pkg/etc/rc.conf - advanced setup:
-------------------B<---------------------------
. /usr/pkg/etc/defaults/rc.conf

. /etc/host-stuff.conf # sets HOST_TYPE_* vars

# Here we start xfstt on X-server boxes
if checkyesno HOST_TYPE_XSERVER; then
	xfstt="YES"	xfstt_flags="..."
else
	xfstt="NO"
fi
-------------------B<---------------------------

The above layout will work, since the rc.d script will not run until /usr
is mounted; packages don't need to install anything under /etc/rc.d - a
seperate script copies /usr/{pkg|local|X11R6}/etc/rc.d/* to /etc/rc.d
after a package installation (perhaps blanks it and also copies
/etc/defaults/rc.d/* there).

It will store package configuration under /usr, but as I have shown it's
easy to make that refer to per-machine options if /usr/pkg is shared.

ABS

-- 
                               Alaric B. Snell
 http://www.alaric-snell.com/  http://RFC.net/  http://www.warhead.org.uk/
   Any sufficiently advanced technology can be emulated in software