Generated by GPT-5-mini| LSB init script | |
|---|---|
| Name | LSB init script |
| Genre | Software init script specification |
| Introduced | 1998 |
| Standard | Linux Standard Base |
| Purpose | Service management compatibility |
LSB init script
LSB init script is a specification-driven shell script format defined by the Linux Standard Base to standardize service startup and shutdown across distributions such as Debian, Red Hat Enterprise Linux, Ubuntu, SUSE Linux Enterprise Server, and Fedora. It provides a canonical header, action verbs, and exit codes intended to interoperate with init implementations including System V init, systemd, Upstart, OpenRC, and BusyBox init. The specification aims to improve portability among distributions maintained by organizations such as the Free Software Foundation, Linux Foundation, and vendors like Canonical, Red Hat, and SUSE.
LSB init script gives a common contract for init scripts so that installers, package managers like dpkg, RPM Package Manager, and init tools can query and manipulate services programmatically. Major distributions including Debian, Ubuntu, Red Hat Enterprise Linux, CentOS, SUSE Linux Enterprise Server, and community projects such as Arch Linux and Gentoo reference the LSB guidance for compatibility layers. The specification was developed within the Linux Standard Base project, which is associated with the Free Standards Group and later coordinated by the Linux Foundation.
An LSB-compliant script is typically a shell script placed in directories such as /etc/init.d on System V init-style systems or packaged inside archive formats like .deb and .rpm. The structure includes a prologue with LSB headers, a shell-compatible implementation section often using POSIX sh, and a command dispatch section implementing verbs like start, stop, restart, status, and reload. Distributions such as Debian and Red Hat Enterprise Linux supply helper utilities—examples include the update-rc.d tool from Debian and the chkconfig utility from Red Hat—which rely on these structured headers.
The header uses tags defined by the specification such as Provides, Required-Start, Required-Stop, Default-Start, Default-Stop, Short-Description, and Description. These tags are parsed by tools in distributions including Debian, Red Hat, SUSE, Mandriva, and Gentoo to determine runlevel behavior and dependencies. The Required-Start and Required-Stop fields commonly reference services like networking, cron, syslog, and hardware-related init scripts provided by vendors such as Intel or projects like udev. The Short-Description and Description fields are used in packaging and management tools such as dpkg-query and yum.
LSB defines a standard set of actions: start, stop, reload, force-reload, restart, status, and try-restart with expected semantics and exit codes aligned with tools like systemctl on systemd systems and classic init scripts on SysVinit. Exit codes include values indicating success, failure, and special conditions used by package installers and configuration management systems such as Ansible, Puppet, Chef, and SaltStack. These actions enable higher-level projects like Docker, Kubernetes, and OpenStack to rely on predictable service control behavior when interacting with legacy init scripts.
Though originally designed for System V init-style systems, LSB init scripts have been adapted as compatibility shims for modern init systems: systemd supplies compatibility units that execute traditional scripts, Upstart provided job wrappers, and OpenRC supports LSB headers for dependency resolution. Distribution maintainers at Canonical and Red Hat implemented transitional mechanisms to map LSB actions to native primitives in systemd or conversion tools in SUSE and Gentoo. Container-focused base images from projects such as Alpine Linux and BusyBox may include minimal implementations of LSB-compatible init wrappers.
Best practices recommend POSIX-compliant shell coding, minimal side effects during start and stop, idempotent operations, and clear dependency declarations per LSB tags. Test suites and validation tools from communities like Debian, Red Hat, and SUSE can parse headers and simulate actions; configuration management tests from Ansible Galaxy roles or Puppet Forge modules often include LSB script checks. Vendors running compliance programs such as Linux Professional Institute certification or internal QA labs use automated tools to assert behavior under packaging workflows for .deb and .rpm.
Portability concerns include shell dialect differences between dash on Debian and bash on other distributions, runlevel semantics across SysVinit and systemd, and dependency naming conventions used by distributions like Arch Linux and Gentoo. Packaging metadata in ecosystems such as Debian Policy, Red Hat Packaging Guidelines, and SUSE Packaging influences how LSB headers are generated and consumed. Projects migrating to systemd-native units often provide LSB-compatible init scripts as transitional artifacts while maintaining service files for native init systems supported by infrastructure vendors like Amazon Web Services and Google Cloud Platform.
Category:Software