Difference between revisions of "Rcstartup, SysV vs. BSD"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
(New page: <nowiki>SysV vs. BSD: Runlevels vs. No Runlevels</nowiki> <nowiki></nowiki> <nowiki>* OpenBSD does not have runlevels. OpenBSD uses an rc(8) style startup</nowiki> <nowiki></nowiki> ...)
 
m (Protected "Rcstartup, SysV vs. BSD" [edit=sysop:move=sysop])
 
(No difference)

Latest revision as of 18:28, 27 June 2007

SysV vs. BSD: Runlevels vs. No Runlevels

* OpenBSD does not have runlevels.  OpenBSD uses an rc(8) style startup

* A Unix administrator can achieve all of the functionality of runlevels 
without using runlevels.

* Whereas /etc/inittab sets the default runlevel on a Linux system, a BSD
* system
uses /etc/ttys to determine whether the system will boot into multiuser
command 
line or multiuser GUI.

* On a Linux system, each runlevel has an associated subdirectory: rc0.d for
runlevel 0, rc1.d for runlevel 1, and so on. The symlink names begin with
either
S (for start) or K (for kill).

* On OpenBSD the "system" startup scripts are found in /etc/rc.d and "user
added" startup scripts in /usr/local/etc/rc.d

* On OpenBSD, instead of using symbolic links beginning with S or K, a handful
of scripts in /etc whose names start with rc control which scripts run at
startup and shutdown.

* Most of the scripts found in Linux's /etc/init.d and BSD's /etc/rc.d share
similar behavior.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *

etc/rc.conf.local is an extension of /etc/rc.conf, which is used to set
variables for /etc/rc, which is run by init. Custom startup scripts belong in
/etc/rc.local, which is part of the default install.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *

NAME
     rc - command scripts for system startup

SYNOPSIS
     /etc/rc
     /etc/rc.local
     /etc/rc.securelevel

FILES
     /etc/rc                Command scripts for system startup.
     /etc/rc.local          Site specific command scripts for system startup.
     /etc/rc.conf           System daemon configuration database.
     /etc/rc.conf.local     Site specific daemon configuration database.
     /etc/rc.securelevel    Commands run before the security level changes.
     /etc/rc.shutdown       Commands run at system shutdown.
     /etc/login.conf        Login class capability database.
     /etc/netstart          Command script for network startup.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *

In rc.conf or rc.conf.local it is sufficient to have a service startup by
using the empty quotes:

  sshd_flags=""     <- this tells sshd to start with no arguments
  sshd_flags=NO     <- sshd will not start automatically

You can specify startup parameters that would otherwise appear behind the
binary on the command line.  Example:

  named_flags="-t /var/named -u named"

But sometimes an additional line is necessary, to get the service to start
automatically when the system loads.

  named_enable=YES 

So, for bind to start on system startup it apparently requires both of the
following:

  named_flags="-t /var/named -u named"
  named_enable=YES

However, it is not cleary as to when both are required, and when only the
first is required.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *

10.3 - How do I start daemons with the system? (Overview of rc(8))

OpenBSD uses an rc(8) style startup. This uses a few key files for startup.

    * /etc/rc - Main script. Should not be edited.
    * /etc/rc.conf - Configuration file used by /etc/rc to know what daemons
    * should start with the system.
    * /etc/rc.conf.local - Configuration file you can use to override settings
    * in /etc/rc.conf so you don't have to touch /etc/rc.conf itself, which is
    * convenient when upgrading your system.
    * /etc/netstart - Script used to initialize the network. Shouldn't be
    * edited.
    * /etc/rc.local - Script used for local administration. This is where new
    * daemons or host specific information should be stored.
    * /etc/rc.securelevel - Script which runs commands that must be run before
    * the security level changes. See init(8)
    * /etc/rc.shutdown - Script run on shutdown. Put anything you want done
    * before shutdown in this file. See rc.shutdown(8) 

How does rc(8) work?

The main files a system administrator should concentrate on are /etc/rc.conf
(or
/etc/rc.conf.local), /etc/rc.local and /etc/rc.shutdown. To get a look of how
the rc(8) procedure works, here is the flow:

After the kernel is booted, /etc/rc is started:

    * Filesystems are checked.
    * Configuration variables are read in from /etc/rc.conf and, afterwards,
    * /etc/rc.conf.local. Settings in rc.conf.local will override those in
    * rc.conf.
    * Filesystems are mounted
    * Clears out /tmp and preserves any editor files
    * Configures the network via /etc/netstart
          o Configures your interfaces up.
          o Sets your hostname, domainname, etc. 
    * Starts system daemons
    * Performs various other checks (quotas, savecore, etc)
    * Local daemons are run, via /etc/rc.local 

Starting Daemons and Services that come with OpenBSD

Most daemons and services that come with OpenBSD by default can be started on
boot by simply editing the /etc/rc.conf configuration file. To start out take
a
look at the default /etc/rc.conf file. You'll see lines similar to this:

    ftpd_flags=NO           # for non-inetd use: ftpd_flags="-D"

A line like this shows that ftpd is not to start up with the system (at least
not via rc(8), read the Anonymous FTP FAQ to read more about this). In any
case,
each line has a comment showing you the flags for NORMAL usage of that daemon
or
service. This doesn't mean that you must run that daemon or service with those
flags. Read the relevant manual page to see how you can have that daemon or
service start up in any way you like. For example, here is the default line
pertaining to httpd(8).

    httpd_flags=NO          # for normal use: "" (or "-DSSL" after reading
ssl(8))

Here you can obviously see that starting up httpd normally no flags are
necessary. So a line like: " httpd_flags=""" would be necessary. But to start
httpd with ssl enabled. (Refer to the SSL FAQ or ssl(8)) You should start with
a
line like: "httpd_flags="-DSSL"".

A good approach is to never touch /etc/rc.conf itself. Instead, create the
file
/etc/rc.conf.local, copy just the lines you are about to change from
/etc/rc.conf and adjust them as you like. This makes future upgrades easier --
all the changes are in the one file.
Starting up local daemons and configuration

For other daemons which you might install on the system via packages or other
ways, you should use the /etc/rc.local file. For example, I've installed a
daemon which lies at /usr/local/sbin/daemonx. I want it to start at boot time.
I
would put an entry into /etc/rc.local like this:

    if [ -x /usr/local/sbin/daemonx ]; then
                 echo -n ' daemonx';       /usr/local/sbin/daemonx
    fi

(If the daemon does not automatically detach on startup, remember to add a "&"
at the end of the command line.)

From now on, this daemon will be started at boot. You will be able to see any
errors on boot, a normal boot with no errors would show a line like this:

    Starting local daemons: daemonx.

rc.shutdown

/etc/rc.shutdown is a script that is run at shutdown. Anything you want done
before the system shuts down should be added to this file. If you have apm,
you
can also set "powerdown=YES", which will give you the equivalent of "shutdown
-p".