The BSD rc Scripts BSD Initialization Sequence

Or continue with multi−user startup by entering [Ctrl−D] 2. If [Ctrl−D] is entered, the system continues with the multi−user startup, as in the previous case.

4.2.6 Initialization Scripts

Once the init process is born, the system startup is determined by a series of rc initialization scripts which define a detailed procedure to bring the system into the multi−user mode. This is the most common case, although other system modes run−levels are also possible. These files control all custom−defined and site−dependent items there are multiple rc initialization scripts, and they are executed sequentially. Generally, rc initialization scripts represent Bourne shell script files, executable at any time and on any UNIX platform. The Bourne shell is the default shell, and it is available at the very early system stage on every UNIX platform. The rc initialization scripts do not differ from any other shell script, except at the time of their execution. This, by the way, is why the prefix rc is used in their description, as well as in the name. However, they can also be executed from the command line at any time, and administrators can make full use of this opportunity: on System V, individual function−specific initialization scripts are often used to stop and start specific UNIX functions during regular system production. On modern UNIX platforms, sometimes Korn shell rc initialization scripts are also included for example, on the HP−UX platform which indicated the early availability of the Korn shell. Understanding rc initialization scripts is a vital part of system administration — this is the place for system customization. A system administrator must be familiar with these files, their locations and, in many cases, their contents. Only then is full control over the system startup possible, and quick corrective action can follow any problem encountered during system boot time. Each modification in the initialization scripts must be done very carefully with respect for the basic administrative rule: save original script files before making any changes. If this rule is not followed, various problems can ensue. Despite the fact that rc initialization scripts on both UNIX platforms BSD and System V serve the same purpose, the mechanisms by which they are initiated and executed are quite different. These differences require great attention, knowledge, and skills from system administrators working in a heterogeneous environment, which is very common today. Today, the System V rc approach prevails — the System V organization of the rc initialization scripts offers more flexibility and other administrative advantages. We will discuss System V initialization in greater detail after a quick survey of the BSD−style initialization.

4.3 BSD Initialization

4.3.1 The BSD rc Scripts

Originally, the BSD initialization was controlled only by two rc initialization scripts: etcrc and etcrc.local. A general system initialization was supported by the etcrc script, while the etcrc.local script referred to a local site, i.e., to issues that should be customized probably a more appropriate script name would be rc.site to avoid any possible confusion toward the logical association with a network−local relationship. During system booting to the multi−user mode, init executed the rc script, which in turn executed the rc.local script. If a single−user boot was performed, scripts were only partially executed; the remaining parts were executed when the single−user shell was exited. 95 SunOS introduced additional script files: etcrc.boot and etcrc.single. The program init invokes first rc.boot script and from there rc.single regardless of whether the system is booting to single vs. multi−user mode; then the etcrc and etcrc.local files follow.

4.3.2 BSD Initialization Sequence

For a clearer picture, the block diagram of the SunOS execution sequence is presented in Figure 4.3 it is assumed the system is booting from the local disk. The SunOS organization made a clear distinction between single and multiple−user modes; it was immediately easier to follow any problems that developed in the system booting. Figure 4.3: The execution sequence of SunOS initialization scripts. To make system customization easier, SunOS provided a special interactive script named usretcinstallrun_configure that was invoked only once, the very first time the system was started upon the OS installation. Through the provided dialogue, the required parameters such as: system name, time zone, date, time, and network data were entered. The system administrator had 96 In the single−user mode, the only way to communicate with the system is via the console; other terminals are not initialized at all. SunOS assumes that anyone who has physical access to the console is an administrator, because from the console it is easy to gain full control over the system. There is no additional system protection. All rc files live in the etc directory; this is an example from SunOS 4.1.3: ls −l etc | grep rc −rw−r−−r−− 1 root 2993 Jan 20 1996 rc −rw−r−−r−− 1 root 5476 Jun 23 1996 rc.boot −rw−r−−r−− 1 root 352 Jan 20 1996 rc.ip −rw−r−−r−− 1 root 6169 Aug 3 1997 rc.local −rw−r−−r−− 1 root 5911 Jan 20 1996 rc.local.orig −rw−r−−r−− 1 root 2172 Jan 20 1996 rc.single We can easily recognize all of the listed files; the file rc.local was modified according to the local site requirements, and the original file was saved. An exception is the file rc.ip, which is used to start up diskless systems. All of the listed files are excellent examples of what shell scripts should look like; extremely skillful programmers write them, and it is a good idea to read them to learn the art of shell programming. However, this is out of the scope of this text. The description of the BSD system startup should be sufficient to explain how a UNIX system is brought into an operational stage. To conclude this discussion, an additional brief report related to this topic is presented. This report is taken directly from the manual pages for rc files on the SunOS platform; nevertheless, there are some discrepancies between the actual initialization scripts and this report, even though the described scripts and manual pages belong to the very same system. This is not so unusual, and a UNIX administrator must be prepared for such surprises. The supplied online documentation simply does not always fully support all system changes and upgrades. man rcfiles NAME rc, rc.boot, rc.local — command scripts for auto−reboot and daemons • SYNOPSIS etcrc • etcrc.boot • etcrc.local • DESCRIPTION rc and rc.boot are command scripts that are invoked by init8 to perform filesystem housekeeping and to start system daemons. rc.local is a script for commands that are pertinent only to a specific site or client machine. • rc.boot sets the machine name and, if on SunOS 4.1.1 Rev B or later, invokes ifconfig, which uses RARP to obtain the machines IP address from the NIS network. Then a whoami • 97 • Next, rc runs. If the system came up single−user, rc runs when the single−user shell terminates see init8. It mounts 4.2 filesystems and spawns a shell for etcrc.local, which mounts NFS filesystems, runs sysIDtool if on SunOS 4.1.1 Rev B or later to set the systems configuration information into local configuration files, and starts local daemons. After rc.local returns, rc starts standard daemons, preserves editor files, clearstmp, starts system accounting if applicable, starts the network where applicable, and if enabled, runs savecore8 to preserve the core image after a crash. •

4.4 System V Initialization