/etc/local.d

This article Article description::describes the setup of scripts in which get executed once during boot or shutdown.

A word of caution
It is a bad idea to abuse this infrastructure to start any other scripts or programs in the background because:


 * If the service script is restarted several times, then those scripts or programs will be executed in the background several times, possibly resulting in race conditions.
 * A script for terminating those processes would have to be also present and may easily fail when e.g. the  script has been executed several times.

For these reasons, it is much more convenient to write an OpenRC initscript file as described in the OpenRC Initscripts section of the Gentoo Handbook.

Configuration
All scripts in with the suffix  will be executed at boot time, all scripts with suffix  at shutdown time.

To e.g. output the text Hello world! at boot time, create the new file :

Afterwards mark the script as executable:

To start the scripts at boot time, add its init.d script to the default runlevel:

Now start the service by making OpenRC check for stopped services in the default runlevel:

Or start it explicitly:

By default, the local service will silence all output. Setting rc_verbose=yes will cause it to show which scripts were run and their output, if any.