restart

  ;;

 reload)

  reload

  ;;

 status)

  rhstatus

  ;;

 condrestart)

  [ -f /var/lock/subsys/smb ] && restart || :

  ;;

 *)

  echo $'Usage: $0 {start|stop|restart|status|condrestart}'

  exit 1

esac

Although the scripts can be used to customize the way that the system runs from power- on, absent the replacement of the kernel, this script approach also means that the system does not have to be halted in total to start, stop, upgrade, or install new services.

Note that not all scripts use this approach, and that other messages might be passed to the service script, such as restart, reload, or status. Also, not all scripts respond to the same set of messages (with the exception of start and stop, which they all have to accept by convention) because each service might require special commands.

TIP

You can write your own init scripts, using the existing scripts as examples. Sample scripts can also be found in /usr/share/doc/initscripts/sysvinitfiles, along with a brief tutorial written by Red Hat and a brief explanation of all the options available to use in init scripts.

After all the system scripts have been run, your system is configured and all the necessary system services have been started. If you are using a runlevel other than 5, the final act of the init process is to launch the user shell, which on Linux is nearly always bash. The shell launches and you see a login prompt on the screen.

Controlling Services at Boot with Administrative Tools

As the master control file for system startup, /etc/inittab and its corresponding system of symbolic links control system services. You can manage /etc/inittab and its symbolic links, using these graphical and nongraphical administrative tools:

chkconfig — A small script that helps you configure system services.

ntsysv — A graphical interface for the chkconfig configuration script.

system-config-services — A full graphical services configuration client. This application is found in the System Services/Sever settings menu as the Services menu item.

The following sections explain how to use all these administrative tools to configure and manage services in Fedora.

Using the chkconfig Text-Based Command-Line Tool

Traditionally, the command-line tool chkconfig has been used to effect administration of the services and their associations in the different runlevels. chkconfig was a major improvement over the process of configuring the symbolic links by hand. It is an effective, text-based command-line tool that you can use to display, diagnose, or change the starting or stopping of system services (as available under /etc/rc.d/init.d) in each runlevel.

For example, to list all services that are turned on in runlevel 5, you can pipe the output of chkconfig through the grep command like this:

# /sbin/chkconfig --list | grep '5:on' | sort

anacron 0:off 1:off 2:on  3:on  4:on 5:on 6:off

apmd    0:off 1:off 2:on  3:on  4:on 5:on 6:off

atd     0:off 1:off 2:off 3:on  4:on 5:on 6:off

autofs  0:off 1:off 2:off 3:on  4:on 5:on 6:off

canna   0:off 1:off 2:on  3:off 4:on 5:on 6:off

crond   0:off 1:off 2:on  3:on  4:on 5:on 6:off

Not all the output is shown here, but as you can see, chkconfig can display the value of off or on for each service and each runlevel. The sample output shows only those services that are started in runlevel 5. The chkconfig command can be used to reassign start or stop values for each runlevel and each service. As an example, to alter the scripts to start power management (controlled by the apmd script under /etc/rc.d/init.d) when using Fedora during runlevel 5, use chkconfig like this:

# chkconfig --level 5 apmd on

You can then verify this action by again using grep on chkconfig's output like this:

# chkconfig --list | grep apmd

apmd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

The chkconfig command does not start or stop a service; instead, it alters the scripts that start or stop a service, or it can report on the status of a service. It affects only the current runlevel by default; you can modify other runlevels by using the -levels option. You would use the ntsysv or service commands or run the daemons directly to actually start or stop services (as described later in this chapter). All these tools have useful man pages to refresh your memory of all the available options.

ntsysv is a graphical interface you can use to access chkconfig and use a graphical interface. ntsysv is an ncurses-based interface, meaning that it offers crude, block graphics and elements you can tab through and select by pressing the spacebar (see Figure 11.1).

FIGURE 11.1 The ntsysv utility manages only which services are started in the current runlevel. Use the --level option to modify other runlevels.

When you have the ntsysv application open, you can scroll through the list of services and toggle a service on or off by pressing the spacebar on the keyboard. When finished, use the Tab key to highlight the OK or Cancel button. Your changes are saved and used the next time Fedora is booted.

NOTE

ntsysv is simple to use and it's an excellent tool for a system without X, but it works for only the runlevel in which you are currently. Use the --level option to modify other runlevels.

The Fedora tool setup is an ncurses-based menu for all the available ncurses-based command-line configuration tools (see Figure 11.2). It can be used to access ntsysv and all the other command-line configuration tools.

FIGURE 11.2 Use the setup command's System Services item to access the

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату