The OpenNET Project / Index page

[ новости /+++ | форум | wiki | теги | ]

Интерактивная система просмотра системных руководств (man-ов)

 [Cписок руководств | Печать]

rc (8)
  • rc (1) ( Русские man: Команды и прикладные программы пользовательского уровня )
  • rc (4) ( FreeBSD man: Специальные файлы /dev/* )
  • >> rc (8) ( FreeBSD man: Команды системного администрирования )

  • BSD mandoc


     - command scripts for auto-reboot and daemon startup




    The utility is the command script which controls the automatic boot process after being called by init(8). The rc.local script contains commands which are pertinent only to a specific site. Typically, the /usr/local/etc/rc.d/ mechanism is used instead of rc.local these days but if you want to use rc.local it is still supported. In this case, it should source /etc/rc.conf and contain additional custom startup code for your system. The best way to handle rc.local however, is to separate it out into rc.d/ style scripts and place them under /usr/local/etc/rc.d/ The rc.conf file contains the global system configuration information referenced by the startup scripts, while rc.conf.local contains the local system configuration. See rc.conf5 for more information.

    The rc.d/ directories contain scripts which will be automatically executed at boot time and shutdown time.  

    Operation of

    1. If autobooting, set autoboot = yes and enable a flag (rc_fast = yes ) which prevents the rc.d/ scripts from performing the check for already running processes (thus speeding up the boot process). This rc_fast = yes speedup will not occur when is started up after exiting the single-user shell.
    2. Determine whether the system is booting diskless, and if so run the /etc/rc.initdiskless script.
    3. Source /etc/rc.subr to load various rc.subr8 shell functions to use.
    4. Load the configuration files.
    5. Determine if booting in a jail, and add ``nojail '' to the list of KEYWORDS to skip in rcorder(8).
    6. Invoke rcorder(8) to order the files in /etc/rc.d/ that do not have a ``nostart '' KEYWORD (refer to rcorder(8)Ns's -s flag).
    7. Call each script in turn using run_rc_script ();
      (from rc.subr8), which sets $1 to ``start '' and sources the script in a subshell. If the script has a .sh suffix then it is sourced directly into the current shell. Stop processing when the script that is the value of the $early_late_divider has been run.
    8. Re-run rcorder(8), this time including the scripts in the $local_startup directories. Ignore everything up to the $early_late_divider then start executing the scripts as described above.


    Operation of rc.shutdown

    1. Source /etc/rc.subr to load various rc.subr8 shell functions to use.
    2. Load the configuration files.
    3. Invoke rcorder(8) to order the files in /etc/rc.d/ and the $local_startup directories that have a ``shutdown '' KEYWORD (refer to rcorder(8)Ns's -k flag), reverse that order, and assign the result to a variable.
    4. Call each script in turn using run_rc_script ();
      (from rc.subr8), which sets $1 to ``stop '' and sources the script in a subshell. If the script has a .sh suffix then it is sourced directly into the current shell.


    Contents of rc.d/

    rc.d/ is located in /etc/rc.d/ The following file naming conventions are currently used in rc.d/

    Scripts that are ``placeholders'' to ensure that certain operations are performed before others. In order of startup, these are:

    Ensure basic network services are running, including general network configuration.
    Ensure basic services exist for services that start early (such as named ) because they are required by DAEMON below.
    Check-point before all general purpose daemons such as lpd and ntpd
    Check-point before user login services ( inetd and sshd ) as well as services which might run commands as users ( cron and sendmail )
    Scripts that are to be sourced into the current shell rather than a subshell have a .sh suffix. Extreme care must be taken in using this, as the startup sequence will terminate if the script does.
    Scripts that are sourced in a subshell. The boot does not stop if such a script terminates with a non-zero status, but a script can stop the boot if necessary by invoking the stop_boot ();
    function (from rc.subr8).

    Each script should contain rcorder(8) keywords, especially an appropriate ``PROVIDE '' entry, and if necessary ``REQUIRE '' and ``BEFORE '' keywords.

    Each script is expected to support at least the following arguments, which are automatically supported if it uses the run_rc_command ();

    Start the service. This should check that the service is to be started as specified by rc.conf5. Also checks if the service is already running and refuses to start if it is. This latter check is not performed by standard Fx scripts if the system is starting directly to multi-user mode, to speed up the boot process. If forcestart is given, ignore the rc.conf5 check and start anyway.
    If the service is to be started as specified by rc.conf5, stop the service. This should check that the service is running and complain if it is not. If forcestop is given, ignore the rc.conf5 check and attempt to stop.
    Perform a stop then a start
    If the script starts a process (rather than performing a one-off operation), show the status of the process. Otherwise it is not necessary to support this argument. Defaults to displaying the process ID of the program (if running).
    If the script starts a process (rather than performing a one-off operation), wait for the command to exit. Otherwise it is not necessary to support this argument.
    Display which rc.conf5 variables are used to control the startup of the service (if any).

    If a script must implement additional commands it can list them in the extra_commands variable, and define their actions in a variable constructed from the command name (see the Sx EXAMPLES section).

    The following key points apply to old-style scripts in /usr/local/etc/rc.d/



    When an automatic reboot is in progress, is invoked with the argument autoboot One of the scripts run from /etc/rc.d/ is /etc/rc.d/fsck This script runs fsck(8) with option -p and -F to ``preen'' all the disks of minor inconsistencies resulting from the last system shutdown. If this fails, then checks/repairs of serious inconsistencies caused by hardware or software failure will be performed in the background at the end of the booting process. If autoboot is not set, when going from single-user to multi-user mode for example, the script does not do anything.

    The rc.early script is run very early in the startup process, immediately before the file system check. The rc.early script is deprecated. Any commands in this file should be separated out into rc.d/ style scripts and integrated into the system.

    The /etc/rc.d/local script can execute scripts from multiple rc.d/ directories. The default location includes /usr/local/etc/rc.d/ but these may be overridden with the local_startup rc.conf5 variable.

    The /etc/rc.d/serial script is used to set any special configurations for serial devices.

    The rc.firewall script is used to configure rules for the kernel based firewall service. It has several possible options:

    will allow anyone in
    will try to protect just this machine
    will try to protect a whole network
    totally disables IP services except via lo0 interface
    disables the loading of firewall rules
    will load the rules in the given filename (full path required).

    The /etc/rc.d/atm* scripts are used to configure ATM network interfaces. The interfaces are configured in three passes. The first pass performs the initial interface configuration. The second pass completes the interface configuration and defines PVCs and permanent ATMARP entries. The third pass starts any ATM daemons.

    Most daemons, including network related daemons, have their own script in /etc/rc.d/ which can be used to start, stop, and check the status of the service.

    Any architecture specific scripts, such as /etc/rc.d/apm for example, specifically check that they are on that architecture before starting the daemon.

    Following tradition, all startup files reside in /etc  


    dmesg(8) results soon after the process begins. Useful when dmesg(8) buffer in the kernel no longer has this information.



    The following is a minimal rc.d/ style script. Most scripts require little more than the following.
    # PROVIDE: foo
    # REQUIRE: bar_service_required_to_precede_foo
    . /etc/rc.subr
    load_rc_config $name
    run_rc_command "$1"

    Certain scripts may want to provide enhanced functionality. The user may access this functionality through additional commands. The script may list and define as many commands at it needs.

    # PROVIDE: foo
    # REQUIRE: bar_service_required_to_precede_foo
    # BEFORE:  baz_service_requiring_foo_to_precede_it
    . /etc/rc.subr
    extra_commands="nop hello"
    hello_cmd="echo Hello World."
            echo "I do nothing."
    load_rc_config $name
    run_rc_command "$1"

    As all processes are killed by init(8) at shutdown, the explicit kill(1) is unnecessary, but is often included.  


    kill(1), rc.conf5, init(8), rcorder(8), rc.subr8, reboot(8), savecore(8)  


    The utility appeared in BSD 4.0



    Operation of Nm
    Operation of Nm rc.shutdown
    Contents of Nm rc.d/

    Поиск по тексту MAN-ов: 

    Inferno Solutions
    Hosting by

    Закладки на сайте
    Проследить за страницей
    Created 1996-2023 by Maxim Chirkov
    Добавить, Поддержать, Вебмастеру