Documentation Index
Fetch the complete documentation index at: https://mintlify.com/openwrt/openwrt/llms.txt
Use this file to discover all available pages before exploring further.
procd is OpenWrt’s PID 1 init system. It handles early boot, service supervision, hotplug events, and integrates with ubus to expose a service management API.
Components
| Component | Description |
|---|
init | Runs as PID 1 during early boot, sets up the system |
procd | Service supervisor: starts, monitors, and restarts services |
udevtrigger | Replays udev events on boot to trigger hotplug |
upgraded | Handles sysupgrade coordination |
askfirst | Spawns a getty/shell on the console at first boot |
Additional optional packages:
| Package | Description |
|---|
procd-ujail | Process jail helper using Linux namespaces |
procd-seccomp | Seccomp syscall filter support |
uxc | Container management using procd-ujail |
Service Script Structure
All init scripts live in /etc/init.d/ and use the /etc/rc.common framework:
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=95
STOP=05
start_service() {
procd_open_instance
procd_set_param command /usr/sbin/my-daemon --foreground
procd_set_param env MY_VAR=value
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
procd_set_param limits core="unlimited"
procd_set_param file /etc/config/my-service
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
procd_set_param Parameters
| Parameter | Description |
|---|
command | The command and arguments to execute |
env | Environment variable(s) to set |
respawn [threshold] [timeout] [retry] | Auto-restart settings. threshold: crash-free seconds before reset. timeout: seconds between restarts. retry: max restarts before giving up (0 = infinite). |
limits | Process resource limits (core, nofile, nproc, etc.) |
file | Config file(s) to watch; service restarts when these change |
netdev | Network interface to watch |
stdout | Redirect stdout to syslog (1=enable) |
stderr | Redirect stderr to syslog (1=enable) |
pidfile | Path to write the service PID |
user | Run the service as this user |
group | Run the service as this group |
START and STOP Values
START and STOP are integer ordering values (0–99). Services with lower START values start earlier. STOP is used for shutdown ordering.
Init Script Commands
# Enable a service (creates symlink in /etc/rc.d/)
/etc/init.d/my-service enable
# Disable a service
/etc/init.d/my-service disable
# Start / stop / restart
/etc/init.d/my-service start
/etc/init.d/my-service stop
/etc/init.d/my-service restart
# Reload configuration without restarting
/etc/init.d/my-service reload
# Show status
/etc/init.d/my-service status
Enabling a service creates a symlink:
/etc/rc.d/S95my-service -> /etc/init.d/my-service
procd via ubus
procd exposes a service object on ubus for runtime service management:
# List all services and their instances
ubus call service list
# Get details for a specific service
ubus call service list '{"name":"dnsmasq"}'
# Start a service instance programmatically
ubus call service set '{
"name": "my-app",
"instances": {
"instance1": {
"command": ["/usr/bin/my-app", "--arg1"]
}
}
}'
# Delete a service
ubus call service delete '{"name":"my-app"}'
# Send a signal to a service
ubus call service signal '{"name":"my-app","signal":15}'
Hotplug Subsystem
procd handles hotplug events (USB insertion, network link changes, etc.) by executing scripts from:
/etc/hotplug.d/<subsystem>/
The <subsystem> matches the kernel’s hotplug subsystem name:
| Subsystem | Triggered by |
|---|
block | Block devices (USB storage, SD cards) |
net | Network interface changes |
usb | USB device insertion/removal |
button | GPIO button events |
ieee80211 | Wi-Fi radio events |
Example hotplug script:
#!/bin/sh
# /etc/hotplug.d/block/10-mount
[ "$ACTION" = "add" ] || exit 0
[ -b "/dev/$DEVNAME" ] || exit 0
mkdir -p /mnt/$DEVNAME
mount /dev/$DEVNAME /mnt/$DEVNAME
Available Hotplug Variables
| Variable | Description |
|---|
$ACTION | add, remove, change, bind, unbind |
$DEVNAME | Device name (e.g., sda1, eth1) |
$SUBSYSTEM | Kernel subsystem |
$DEVTYPE | Device type (e.g., disk, partition) |
Minimal Service Example
#!/bin/sh /etc/rc.common
# /etc/init.d/hello
USE_PROCD=1
START=99
STOP=01
start_service() {
procd_open_instance
procd_set_param command /bin/sh -c 'while true; do echo hello; sleep 60; done'
procd_set_param respawn
procd_close_instance
}
After placing this file at /etc/init.d/hello:
chmod +x /etc/init.d/hello
/etc/init.d/hello enable
/etc/init.d/hello start