< Day Day Up > |
Startup and shutdown scripts for Linux are organized in three parts: sequencer script; execution scripts; and subdirectories and link files. These scripts work together to facilitate startup execution and are described shortly. Startup and shutdown are going to become increasingly more important to you as your system administration work to become more sophisticated. As you load and customize more applications, you will need to know more about startup and shutdown. In this section, you get an overview of startup and shutdown and the commands that you can use to control your system. The following descriptions are for the three components that are in the startup and shutdown model of Linux that is based on the UNIX System V model:
Figure 6-1 shows the directory structure for startup and shutdown scripts. Figure 6-1. Organization of Linux Startup and Shutdown FilesExecution scripts perform startup and shutdown tasks. /sbin/rc invokes the execution script with the appropriate start or stop arguments, and you can view the appropriate start or stop messages on the console. You'll see an [ OK ] that indicates that the execution script started successfully. Let's take a look at an example startup and shutdown file for Samba. This will help us later when we perform extensive Samba-related work in another chapter. As mentioned earlier, the script used as part of the startup and shutdown process is in /etc/init.d. The following example is from the IA-32 system used in the Samba chapter, but is the same for Integrity servers. For the Samba example, the name of the program is /etc/init.d/smb. Take a minute and use your favorite editor to open and view the script. If you're logged on as root, remember not to make any changes to the script without backing up the original. The startup and shutdown scripts in /etc/init.d generally perform both startup and shutdown functions. These startup and shutdown scripts recognize many arguments, including the following:
See if you can find these in /etc/init.d/smb. If you do, see if you can understand what they do. Now, test some of these arguments. We'll start smb, obtain its status, stop smb, and re-obtain its status. Remember, to do these things, you must be logged on as root: # ./smb start Starting SMB services: [ OK ] Starting NMB services: [ OK ] # ./smb status smbd (pid 11165) is running... nmbd (pid 11170) is running... # ./smb stop Shutting down SMB services: [ OK ] Shutting down NMB services: [ OK ] # ./smb status smbd is stopped nmbd is stopped # As you can see, the script obviously works great, but does not start automatically at system boot. Make sure that you're in /etc/rc.d, then search for all files in /etc/rc.d that contain smb. If you do, you get the following: # pwd /etc/rc.d # find . -name *smb* -print ./init.d/smb ./rc0.d/K35smb ./rc1.d/K35smb ./rc2.d/K35smb ./rc3.d/K35smb ./rc4.d/K35smb ./rc5.d/K35smb ./rc6.d/K35smb # All the files found begin with K, which indicates that these are kill files, and no start files beginning with S were found. We can start smb a variety of ways, including the following:
We'll use the third technique because the ksysv interface is easy to use and informative. Although this chapter discusses /etc/inittab soon, you need to know our default run level. You can obtain the current run level and the default run level because you haven't changed it in this case, by issuing the runlevel command: # runlevel N 5 # You now know that you're at run level 5. Figure 6-2 shows the top level ksysv interface. Figure 6-2. ksysv Interfacesmb appears at run level 5 under Stop but not under Start. All that we have to do to place it under Start is to select it in the Available Services window on the left and Copy and Paste it into Runlevel 5 to have it start when the system reaches run level 5. Figure 6-3 shows smb under Runlevel 5. Figure 6-3. ksysv with smb Under Runlevel 5After the system is rebooted, smb did come up as a running service as verified with the command in the following output: # /sbin/service smb status smbd (pid 933) is running... nmbd (pid 938) is running... # The /sbin/service command starts services. It calls the startup script, such as smb in this case, and performs the desired function, such as producing status in this case. There is no manual page for service, but you will see it issued in examples often. Now re-issue the search command and see if there is indeed an S file for smb to start it automatically: # pwd /etc/rc.d # find . -name *smb* -print ./init.d/smb ./rc0.d/K35smb ./rc1.d/K35smb ./rc2.d/K35smb ./rc3.d/K35smb ./rc4.d/K35smb ./rc5.d/S90smb ./rc5.d/K35smb ./rc6.d/K35smb # The startup script for out default run level 5 is /etc/rc.d/rc5.d/S90smb. This was added for us automatically by ksysv with our copy and paste operation. The following shows the anatomy of the file: /etc/rc.d/rc5.d/S90smb | | | | | | | v | | | script name - smb in example | | v | | sequence number - 90 in example | v | "S" for startup, "K" for kill or shutdown v run level number - 5 in example Now that you know the way in which startup and shutdown scripts work, it's time to investigate /etc/inittab. |
< Day Day Up > |