Runlevel System

From SoL 25 Wiki

Jump to: navigation, search

Starting with the first release back in 2002, SoL abandoned the old and slow SysV init script S/K-link massacre and introduced a simple and fast XML runlevel system. With SoL 25, the system has been simplified even more.

However, to provide (backwards) compatibility with some (commercial) applications, the legacy SysV init directories (/etc/init.d, /etc/rc.d/rc0.d, ...) exist so install scripts that expect them, won't yield errors.

Contents

[edit] Boot Basics

The first thing the Linux kernel runs is init, the mother of all processes. The SoL 25 /etc/inittab is configured so that each runlevel call is dispatched to /etc/rc.d/runsol, the heart of the SoL runlevel system. The runsol configuration file is /etc/rc.d/runlevel.xml. For each runlevel that is called by init, runsol starts the scripts that are defined in runlevel.xml for that runlevel.

For a detailed description of what happens in each runlevel by default, read Detailed SoL 25 Boot.

[edit] Runlevels

The runlevels in SoL 25 are defined as follows:

  • 0: Halt
  • 1: Single user mode
  • 2: Basic system without network
  • 3: Basic system with network
  • 4: Services layer
  • 6: Reboot
  • 9: System initialization

The default runlevel is runlevel 4.

[edit] runlevel.xml

The runlevel.xml syntax is quite simple, an example of a runlevel container may look like this:

  <services id="4">
    <run prog="sol-mysqld.sh" mode="on"/>
    <run prog="sol-httpd.sh" mode="on"/>
    <run prog="sol-proftpd.sh" mode="off"/>
  </services>

This example describes the runlevel 4, specified by the id attribute of the services element. Actually, you could name the element anything you want, its purpose is more a describing one. For each runlevel container, you can have multiple run elements, which have the prog and mode attributes. For prog, use the name of the runlevel script (located in /etc/rc.d/bin) that will start the desired service, "mode" is simply "on" or "off". In this example, the MySQL daemon and Apache would be started in runlevel 4, whereas ProFTPD wouldn't.

[edit] Start Scripts

The start scripts for certain services as well as the system init script are located in /etc/rc.d/bin. When started from the command line, they take one parameter that specifies what to do with the service:

  • up, start or u: Starts the service
  • down, stop or d: Stops the service in a clean way, if possible (unfortunately, not all services provide this feature)
  • cycle, restart, c or r: Restarts the service, this is equivalent to running stop and start
  • status or s: Tells if the service is still running by trying to find its processes
  • killall or k: Forces the services' processes to stop by issuing the "kill" command

Note that the old XML config files are no longer present. If you need to pass special parameters to a service, just edit the startscript itself. Since they are pretty simple, it is easy to create startscripts for your own needs.

Views
Personal tools