Operating System - HP-UX
1753441 Members
4743 Online
108794 Solutions
New Discussion юеВ

Re: rc.config.d files - All all files read into memory upon boot before starting apps

 
SOLVED
Go to solution
Jack C. Mahaffey
Super Advisor

rc.config.d files - All all files read into memory upon boot before starting apps

Inadvertantly posted this to wrong forum. Did not mean to post to Linux forum.

I recall a statement from an HP instructor that all variables in /etc/rc.config.d were loaded upon boot prior to running the rc.#d startup scripts. This would indicate that there could be major problems if multiple variable files, had the same variables.


Would someone please confirm this statement. I have seen previous variable files saved with extensions, as in netconf.old, netconf.new, etc.

jack...
5 REPLIES 5
Tracey
Trusted Contributor

Re: rc.config.d files - All all files read into memory upon boot before starting apps

I've had problems with naming a backup netconf.back. When booting I had major troubles and was told to rename it to back.netconf and everything came up normally after that.
Kenneth Platz
Esteemed Contributor

Re: rc.config.d files - All all files read into memory upon boot before starting apps

Jack,

Most of the scripts in /sbin/init.d call the /etc/rc.config script, which in turn does the following:

for CFG_FILE in /etc/rc.config.d/* /etc/TIMEZONE
do
fname=${CFG_FILE##*/} # get file basename
if [ -f $CFG_FILE -a "$fname" != "core" -a "${fname##*[.,~\#]}" = "$fnam
e" ]
then . $CFG_FILE # source a valid config file
fi
done

As a result, if any of the scripts in /etc/rc.config.d fail for any reason, then many of the vital subsystems (inetd, for instance) will not start up correctly.

Likewise, it is also very dangerous to keep 'backup' copies of your rc.config.d files in the same directory, else whichever file comes last in lexicographic order will be used. (I've seen this happen when people have both a netconf and netconf.orig file).

I hope this helps.
I think, therefore I am... I think!
Frederic Soriano
Honored Contributor
Solution

Re: rc.config.d files - All all files read into memory upon boot before starting apps

Hi Jack,

You should have a look at man page rc.config(4). Here is an excerpt:

--snip--
The file /etc/rc.config is a script that sources all of the /etc/rc.config.d/* scripts, and also sources /etc/TIMEZONE. To read the configuration definitions, only this file need be sourced. This file is sourced by /sbin/rc whenever it is run, such as when the init command is run to transition between run states. Each file that exists in /etc/rc.config.d is sourced, without regard to which startup scripts are to be executed.

[...]

Note that there must be no requirements on the order of the files sourced. This means configuration files must not refer to variables defined in other configuration files, since there is no guarantee that the variable being referenced is currently defined. There is no protection against environment variable namespace collision in these configuration files. Programmers must take care to avoid such problems.
--snip--

Besides, if you look at /etc/rc.config code, you'll see that minimum checks are performed, and that /etc/rc.config.d/scripts.with.a.dot.in.their.name will NOT be sourced (thanks to variable substitutions), thus allowing backup configuration scripts such as /etc/rc.config.d/netconf.OLD to remain in their original directory.

I hope this helps !

Best regards,

Fred.
James R. Ferguson
Acclaimed Contributor

Re: rc.config.d files - All all files read into memory upon boot before starting apps

Hi:

This question has come up before in similar forms. The script posted by Kenneth is the actual code from /etc/rc.config.

This script SKIPS files whose basename contains the characters between the square brackets, namely the period (.), the comma (,), the tilde (~) and the hash (#).

Thus, you CAN SAFELY have backup copies of a file called "myfile" where these backup copies are named : myfile.bak, myfile.old, myfile~lastone, etc. In cases like this, only "myfile" would be sourced by /etc/rc.config.

The man page noted by Frederic makes ample note of the sourcing order (lexographically) and of the warning for one script (source) NOT to assume another script (source) has provided an environmental variable for it.

Regards!

...JRF...
Jack C. Mahaffey
Super Advisor

Re: rc.config.d files - All all files read into memory upon boot before starting apps

Thanks to all...