Using Distribution Specific Tools

SysV startup scripts are very flexible, but they can be awkward to configure. Creating multiple symbolic links and determining the appropriate sequence numbers make the task of changing your servers' startup configurations difficult. For this reason, many distributions ship with tools to help simplify this task. These tools include chkconfig, ntsysv, ksysv, Red Hat's Service Configuration Tool, and YaST.

Using chkconfig

The chkconfig utility is a fairly straightforward command-line tool that ships with Mandrake, Red Hat, and SuSE. It supports changing both SysV startup script configurations and servers started from xinetd. It can be used to report on the SysV configuration, add or delete services, or modify the runlevels in which a service is active.

To view a configuration, pass the -list parameter to the program, optionally followed by a service name. For instance, to learn about the Postfix server configuration, you might type:

$ /sbin/chkconfig -list postfix postfix O:off 1 :off 2:on 3:on 4:off 5:off 6:off

Note Ordinary users can run chkconfig to examine server configurations, but not to change those configurations. Most ordinary users must specify the /sbin directory when launching chkconfig. To change startup scripts, you must run the tool as root.

This report reveals the runlevels in which SysV startup script links are set to start or stop the server. Servers that are launched by xinetd produce much shorter output lines; these servers are reported as being either on or off, with no runlevel information. In reality, they run only when xinetd is running, and hence only in the runlevels in which xinetd is active. If a link is missing, chkconfig reports its status as off.

To add or delete SysV startup script links for a script that exists in the main script directory, pass the -add or-del parameters, followed by the name of the service you want to modify. This command requires that a SysV startup script exist in the main directory, and it uses the chkconfig comment in that script to determine the appropriate sequence numbers and in which runlevels the service should run. For instance, to add Postfix to the system, type the following command:

# chkconfig -add postfix

To modify the runlevels in which a service is active in Red Hat or Mandrake, pass chkconfig the -levels parameter, followed by the runlevel numbers, the SysV startup script name, and the code on, off, or reset. The -levels parameter and runlevel numbers are, of course, unnecessary when dealing with servers started via xinetd. For instance, to deactivate Postfix in runlevels 4 and 5, type the following command:

# chkconfig -levels 45 postfix off

SuSE's version of chkconfig doesn't support the -levels option; instead it uses -set, which has a slightly different syntax. To use -set, you pass it the runlevels in which you want the service to run. If you want to disable the server in specific runlevels, you must pass chkconfig the runlevels in which you do want the service to run, omitting the runlevels you want to disable. For instance, if Postfix is currently active in runlevels 3, 4, and 5 and you want to disable it in runlevels 4 and 5, you might type:

# chkconfig -set postfix 3 Using ntsysv

The chkconfig utility fits nicely in the tradition of text-based Linux tools that require options passed to them on the command line. If you prefer something that's a bit more interactive, you might want to consider ntsysv, which is depicted in Figure 22.1, running within an xterm. This tool ships with Mandrake and Red Hat and uses a text-based interface to acquire information on which services should be started. If you type ntsysv and nothing else, the program enables you to select which servers should be started in the current runlevel. Use the arrow keys to position the cursor in a box to the left of the service name, and press the spacebar to toggle the service on or off. Services that are on have asterisks (*) in their boxes; those that are off don't have asterisks in their boxes. When you're done, press the Tab key to highlight the OK button and press the Enter key.

Figure 22.1: The text-based ntsysv program enables you to interactively edit which services are active.

By default, ntsysv enables you to modify only the current runlevel. To edit another runlevel or runlevels, you can pass the runlevel numbers using the -level option, as in ntsysv --level 4 to edit runlevel 4, or ntsysv --level 345 to edit runlevels 3, 4, and 5.

Using Red Hat's Service Configuration Tool

Red Hat's Service Configuration tool (redhat-config-services), as shown in Figure 22.2, is essentially a fully GUI version of ntsysv. Select a service, and the tool displays information about it, including whether or not it's active. Click the Start or Stop buttons to change the current running status, or click Restart to restart an already running server. To activate or deactivate the server, check or uncheck the box next to the server's name. This change affects only the current runlevel. You can change which runlevel is affected by selecting a new one from the Edit Runlevel menu. (The tool only supports editing runlevels 3 through 5.) After you've made changes, be sure to select File O Save Changes. The program doesn't ask for confirmation; it saves the changes immediately.

Figure 22.2: Red Hat's Service Configuration tool is essentially a GUI version of ntsysv.

Using YaST or YaST2

SuSE's text-based and GUI configuration tools, YaST and YaST2 (which I refer to collectively as YaST for simplicity) provide the means to edit SuSE's SysV startup sequences. From the main YaST menu, go to the System area and then select the Runlevel Editor option. The default is the Runlevel Editor tool, from which you can set the default runlevel. If you click the Runlevel Properties button, YaST opens a display of services started in various runlevels, as shown in Figure 22.3.

Figure 22.3: YaST2 enables you to change startup script runlevels.

To change a configuration, scroll to the name of the service you want to modify and select it. The check boxes below the main service display will change to reflect the current configuration. Check or uncheck boxes as you see fit. YaST keeps its own record of the proper sequence numbers for starting and stopping services, so you don't need to attend to this detail when using YaST. When you're done making changes, click Finish to activate them.

Using ksysv

Unfortunately, ntsysv, Red Hat's Service Configuration tool, and YaST don't work in all distributions. One option for cross-distribution GUI server control is ksysv, which is part of the K Desktop Environment (KDE). This tool can be used on any Linux distribution that uses a typical SysV startup script system, although it's missing from Red Hat's default installation. The first time you launch the program, it may ask you which distribution you're using so that it knows where to look for the scripts and links. Once you give it this information, it displays a window similar to the one shown in Figure 22.4. You can adjust which runlevels are displayed by clicking the boxes in the lower-right corner of the window (Figure 22.4 omits runlevels 0 and 6).

Figure 22.4: The ksysv runlevel configuration tool enables you to drag and drop services between runlevels.

The ksysv window displays a close analog to the structure of the SysV startup script directories. The Available Services area displays all of the available SysV startup scripts, and each Runlevel area displays scripts for both starting and stopping services in a given runlevel, along with the sequence numbers for these scripts. You can drag and drop services between these areas and to the trash can icon beneath the Available Services area. When you drag a service to a runlevel, ksysv tries to generate a sequence number in-between the two services above and below the position to which you drag the service. If these services have the same number or if the numbers differ only by one, ksysv can't generate a unique number and refuses to create an entry. You must then edit at least one of the surrounding services. You can do this, as well as change other features of a service, by clicking it. The program pops up a dialog box from which you can change the service number, start or stop the service, and so on.

When you're done making changes, select File O Save Configuration. The program displays a warning that making incorrect changes to SysV startup scripts can cause boot problems. Click Save if you're sure your changes are valid, or click Cancel otherwise.

Unfortunately, ksysv can't take advantage of the chkconfig information stored in Mandrake and Red Hat SysV startup scripts. This fact means that chkconfig and ntsysv do a better job of automatically assigning series numbers in these distributions. Nonetheless, ksysv can be a useful tool if you understand how to handle these features.

Team LIB

Team LIB

^ previous

0 0

Post a comment