insserv
Manage System V init script dependencies
SYNOPSIS
insserv [OPTIONS] [SCRIPT...]
insserv -r [OPTIONS] SCRIPT...
PARAMETERS
SCRIPT...
The name(s) of the init.d script(s) to process. If no script is specified, insserv processes all scripts in the configured init.d directory.
-c, --config=runlevels
Specify the runlevels where the script should be configured. This overrides the Default-Start and Default-Stop LSB headers.
-d, --default
Use default runlevels for scripts lacking LSB headers, typically adding them to the startup sequence.
-D, --force-default
Force the use of default runlevels, even if LSB headers are present in the script. Useful for overriding existing configurations.
-e, --enable
Explicitly enable a specific script by creating the necessary links. This is the LSB-compliant way to enable a service.
-f, --force
Force installation or removal, ignoring some checks (e.g., missing LSB headers or dependency issues). Use with caution.
-F, --force-stop
Forces the stopping order for all scripts, ignoring LSB headers. Less commonly used.
-h, --help
Display a short help message and exit.
-k, --keep
Keep existing links for a script when reinstalling. New links are added, but old ones are not removed.
-p, --path=path
Specify an alternative path to the init.d scripts directory, overriding the default system path.
-r, --remove
Remove the specified script(s) from all runlevels, deleting the corresponding symbolic links.
-s, --show-script
Show the LSB headers for a given script, useful for debugging or verifying compliance.
-v, --version
Display version information and exit.
DESCRIPTION
The insserv command is a crucial utility within the SysVinit system, designed to manage and order initialization scripts. It automates the process of creating and maintaining the symbolic links found in the rcX.d directories (e.g., rc0.d, rcS.d, rc2.d). insserv parses the Required, Provides, Should-Start, Should-Stop, Default-Start, and Default-Stop LSB (Linux Standard Base) compliant headers within init.d scripts.
Based on these dependencies and runlevel information, it calculates the correct boot and shutdown order for services. This ensures that services start only after their prerequisites are available and stop gracefully before their dependencies are removed, maintaining system stability during boot-up and shutdown processes. It simplifies the administration of runlevel configurations by enforcing a consistent and dependency-aware service startup order.
CAVEATS
The effectiveness of insserv heavily relies on the correct and compliant implementation of LSB (Linux Standard Base) headers within the init.d scripts. Scripts lacking these headers, or having incorrect ones, may not be processed correctly, leading to unexpected service startup or shutdown behavior. It is primarily designed for systems using SysVinit and is not directly used on systems that have adopted more modern init systems like systemd or Upstart for service management.
LSB HEADERS IN INIT SCRIPTS
For insserv to function correctly, init.d scripts must contain specific LSB-compliant headers within a ### BEGIN INIT INFO
and ### END INIT INFO
block. These headers provide crucial metadata for dependency resolution and runlevel configuration. Key headers include:
Required: Specifies services that must be running before this script starts.
Provides: Declares the service name provided by this script.
Should-Start / Should-Stop: Lists services that ideally should be started/stopped in conjunction with this script.
Default-Start / Default-Stop: Defines the default runlevels where the service should automatically start/stop.
Short-Description / Description: Provides a brief and long description of the service.
HISTORY
insserv emerged as a response to the need for a more standardized and robust way to manage SysVinit scripts, particularly focusing on LSB (Linux Standard Base) compliance. While older tools like update-rc.d and chkconfig offered similar functionality, insserv specifically leverages the LSB headers within scripts (Required, Provides, etc.) to ensure proper dependency resolution and ordering. It gained significant traction in distributions that aimed for strict LSB adherence for their init systems. However, with the widespread adoption of systemd as the default init system in many modern Linux distributions, the direct usage and relevance of insserv have gradually decreased, though it remains a fundamental tool for systems still relying on SysVinit.
SEE ALSO
update-rc.d(8), chkconfig(8), init(8), runlevel(8), boot(7)