[comp.unix.admin] Local rc scripts

seeger@thedon.cis.ufl.edu (F. L. Charles Seeger III) (09/27/90)

In article <KLM.90Sep26145601@goon.cme.nist.gov> klm@cme.nist.gov (Ken Manheimer) writes:
| We've actually implemented a refinement on the 'rc.site' scheme that
| walter mentioned in a prior article...
|
| ... The refinement to fix this
| consists of changing the hook to the global rc.site to the following
| sort of thing:

synopsis:	if available cp rc.site from nfs server to /etc/rc.site
		execute local copy (possibly old)

We rdist our SunOS 4.1 rc files (ours are modified from the distributed
ones), rather than using rc.site.  We do use a *host* specific rc, though.
Currently, it is run from rc.local rather than rc, though I considered
changing that so as to do host specific TFS% mounts (which must be done
after inetd is running, which is started late in rc).  Instead, I am
currently using a "mount -vat tfs" command at the end of the rc script
for this purpose and using the fstab for personality.  Nonetheless, rc
is probably the more general (and better) place to run either rc.site
or rc.`hostname`.

#
# Do anything else specific to this host...
#
if [ -f /etc/rc.`hostname` ]; then
	sh /etc/rc.`hostname`
fi

I esthetically abhor testing on explicit hostnames in rc scripts.

Regards,
Chuck
--
% Translucent File Service, new in SunOS 4.1.
--
  Charles Seeger    E301 CSE Building             Office: +1 904 392 1508
  CIS Department    University of Florida         Fax:    +1 904 392 1220
  seeger@ufl.edu    Gainesville, FL 32611-2024

peter@ficc.ferranti.com (Peter da Silva) (09/30/90)

The System V startup model might repay study.

	inittab ---> /etc/rc0
		     /etc/rc2 ---> /etc/rc2.d/S01MOUNTFSYS
				   /etc/rc2.d/S05RMTMPFILES
				   ...
		     /etc/rc3 ---> /etc/rc3.d/S08ina961
				   /etc/rc3.d/S20SV_onet
				   ...
		     ...

Run level 2 starts up all the multiuser stuff. Run level 3 is typically used
for the network level. An application program just needs to install a startup
file in /etc/rc?.d and it is automatically initialised. When shutting down,
then, it runs the rc files in reverse order and a different set of files is
run:

	inittab ---> /etc/rc2 ---> /etc/rc2.d/K20SV_onet
				   ...
		     /etc/rc0 ---> /etc/rc0.d/K98UMOUNTFSYS
				   ...

I'm really surprised that Sun and Berkeley haven't picked up on this yet. The
system for handling drivers is similarly clean...
-- 
Peter da Silva.   `-_-'
+1 713 274 5180.   'U`
peter@ferranti.com

prc@erbe.se (Robert Claeson) (09/30/90)

In a recent article peter@ficc.ferranti.com (Peter da Silva) writes:

>The System V startup model might repay study.
>
>	inittab ---> /etc/rc0
>		     /etc/rc2 ---> /etc/rc2.d/S01MOUNTFSYS
>				   /etc/rc2.d/S05RMTMPFILES
>				   ...

>Run level 2 starts up all the multiuser stuff. Run level 3 is typically used
>for the network level. An application program just needs to install a startup
>file in /etc/rc?.d and it is automatically initialised.

Actually, the /etc/init.d directory contains all the startup/shutdown
files, like MOUNTFSYS, ethernet, sendmail, acct, nfs and the like. Each
of these scripts are built around a switch, and accepts either "start"
or "stop" as arguments on the command line.

"Start" starts all the daemons and performs any other tasks needed to
start a service. Likewise, "stop" kills any started daemons and shuts
down the service.

Each of these scripts are then linked to /etc/rc0.d, /etc/rc1.d,
/etc/rc2.d etc with names in the form "[SK][0-9][0-9]<name>".
The scripts /etc/rc0, /etc/rc1 etc (one for each run level, 0-6)
first runs all K?? scripts in ascending order and then all S??
scripts, also in ascending order. Scripts starting with "K" gets
a "stop" passed on the command line while scripts starting with
"S" gets a "start" on the command line.

At this site, all we do to install a new service (say, Ingres,
Informix, the Annex terminal server software etc) is to create
a new script in /etc/init.d (all locally added scripts starts
with local-<name>. This is typically done by copying and modifying
an existing locally added script.

All scripts in /etc/init.d are then *linked* to the other startup
directories (ie, /etc/init.d/nfs gets linked to /etc/rc3.d/S85nfs
and to /etc/rc0.d/K05nfs):

# cd /etc
# ln init.d/local-ingres rc2.d/S98local-ingres
# ln init.d/local-ingres rc0.d/K01local-ingres

Note that all locally added scripts are assigned numbers so that
they will be run first in the shutdown sequence and last in the
startup sequence.

The System V method of performing start-up is one of the cleanest and
at the same time flexible ways I've seen among all UNIX systems.

-- 
Robert Claeson                  |Reasonable mailers: rclaeson@erbe.se
ERBE DATA AB                    |      Dumb mailers: rclaeson%erbe.se@sunet.se
                                |  Perverse mailers: rclaeson%erbe.se@encore.com
These opinions reflect my personal views and not those of my employer.