Writing Init Scripts

From Alpine Linux
Revision as of 05:22, 28 December 2010 by Ncopa (talk | contribs) (initial doc on how to write rc scripts)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This material is work-in-progress ...

Do not follow instructions here until this notice is removed.
(Last edited by Ncopa on 28 Dec 2010.)

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

Needs to start with #!/sbin/runscript

Using the start/stop templates and special predefined variables:

command="/usr/sbin/mydaemon"
command_args="--args-for-mydaemon"
procname="mydaemon"
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 $?
}