Writing Init Scripts: Difference between revisions

From Alpine Linux
(update link)
(Change runscript to openrc-run, add start_stop_daemon_args to example)
Line 3: Line 3:
This document explains how to write openrc scripts, aka init.d scripts.
This document explains how to write openrc scripts, aka init.d scripts.


Needs to start with #!/sbin/runscript
Needs to start with <tt>#!/sbin/openrc-run</tt>


Using the start/stop templates and special predefined variables:
Using the start/stop templates and special predefined variables:
Line 11: Line 11:
command="/usr/sbin/mydaemon"
command="/usr/sbin/mydaemon"
command_args="--args-for-mydaemon"
command_args="--args-for-mydaemon"
procname="mydaemon"
start_stop_daemon_args="--args-for-start-stop-daemon"
pidfile="/var/run/mydaemon.pid"
pidfile="/var/run/mydaemon.pid"
stopsig="SIGTERM"
stopsig="SIGTERM"

Revision as of 18:22, 31 August 2016

This material is work-in-progress ...

Do not follow instructions here until this notice is removed.
(Last edited by Jirutka on 31 Aug 2016.)

This document explains how to write openrc scripts, aka init.d scripts.

Needs to start with #!/sbin/openrc-run

Using the start/stop templates and special predefined variables:

description="My Example Daemon"
command="/usr/sbin/mydaemon"
command_args="--args-for-mydaemon"
start_stop_daemon_args="--args-for-start-stop-daemon"
pidfile="/var/run/mydaemon.pid"
stopsig="SIGTERM"

Using start-stop-daemon

To be written

start() {
    ebegin "Starting mydaemon"
    start-stop-daemon --start \
        --exec /usr/sbin/mydaemon \
        --pidfile /var/run/mydaemon.pid \
        -- \
        --args-for-mydaemon
    eend $?
}

More info here: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4#doc_chap4