<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lchristolo</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lchristolo"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Lchristolo"/>
	<updated>2026-04-29T16:09:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15522</id>
		<title>Writing Init Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15522"/>
		<updated>2018-12-03T15:54:02Z</updated>

		<summary type="html">&lt;p&gt;Lchristolo: /* restart */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux uses the [https://github.com/OpenRC/openrc OpenRC] init system to start services. Don&#039;t confuse OpenRC init with our system init (the first process that is executed aka pid 1). Many of the current init.d script found in Alpine Linux are taken from Gentoo. If you want to save time you could search [https://packages.gentoo.org/categories Gentoo&#039;s repository] for an existing initscript for your service. You can also check [https://wiki.gentoo.org/wiki/Handbook:X86/Working/Initscripts#Writing_initscripts Gentoo&#039;s wiki] for some additional OpenRC information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;NOTE&amp;lt;/strong&amp;gt;: OpenRC recently added [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md documentation] on how to write proper Init scripts. Make sure you read it!&lt;br /&gt;
&lt;br /&gt;
If you cannot find an init.d script from Gentoo, or you just want to start to write your own init.d scripts, we provide you with some basic information on how to write simple OpenRC init scripts.&lt;br /&gt;
&lt;br /&gt;
Primary information about the OpenRC format can be found in the [http://manpages.org/openrc-run/8 OpenRC man page openrc-run].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;apk add openrc-doc man&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;man openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Minimal Templates ==&lt;br /&gt;
&lt;br /&gt;
Every init.d script you write needs to start with a [https://en.wikipedia.org/wiki/Shebang_(Unix) shebang] like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/sbin/openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services relying on OpenRC exclusively ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/path/to/command&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services supervised by [http://www.skarnet.org/software/s6/ s6] ===&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* Install and configure the &amp;lt;code&amp;gt;s6-scan&amp;lt;/code&amp;gt; service to start on system boot&lt;br /&gt;
* Exclude &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;status()&amp;lt;/code&amp;gt; functions in order for s6 supervision to work reliably. OpenRC has built-in equivalent functions which invoke the necessary s6 commands.&lt;br /&gt;
* Include a &amp;lt;code&amp;gt;depend()&amp;lt;/code&amp;gt; stanza to ensure that the &amp;lt;code&amp;gt;s6-svscan&amp;lt;/code&amp;gt; service is already running.&lt;br /&gt;
* Add a &amp;lt;code&amp;gt;start_pre()&amp;lt;/code&amp;gt; stanza to symlink the service directory into the scan directory, because the &amp;lt;code&amp;gt;/etc/init.d/bootmisc&amp;lt;/code&amp;gt; scripts cleans out the &amp;lt;code&amp;gt;/run&amp;lt;/code&amp;gt; directory on system boot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;foo&amp;quot;&lt;br /&gt;
supervisor=&amp;quot;s6&amp;quot;&lt;br /&gt;
s6_service_path=&amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
    need s6-svscan&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
    if [ ! -L &amp;quot;${RC_SVC_DIR}/s6-scan/${name}&amp;quot; ]; then&lt;br /&gt;
        ln -s &amp;quot;/path/to/${name}/service/dir&amp;quot; &amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest of the below basic example could be omitted, but that would most probably leave you with an non working initd script.&lt;br /&gt;
&lt;br /&gt;
== Basic example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
  &lt;br /&gt;
name=$RC_SVCNAME&lt;br /&gt;
cfgfile=&amp;quot;/etc/$RC_SVCNAME/$RC_SVCNAME.conf&amp;quot;&lt;br /&gt;
command=&amp;quot;/usr/bin/my_daemon&amp;quot;&lt;br /&gt;
command_args=&amp;quot;--my-daemon-args&amp;quot;&lt;br /&gt;
command_user=&amp;quot;my_system_user&amp;quot;&lt;br /&gt;
pidfile=&amp;quot;/run/$RC_SVCNAME/$RC_SVCNAME.pid&amp;quot;&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--args-for-start-stop-daemon&amp;quot;&lt;br /&gt;
command_background=&amp;quot;yes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
        need net&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
        checkpath --directory --owner $command_user:$command_user --mode 0775 \&lt;br /&gt;
                /run/$RC_SVCNAME /var/log/$RC_SVCNAME&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== start, stop, restart functions ==&lt;br /&gt;
&lt;br /&gt;
OpenRC defined a few basic functions ie: start, stop, restart. These functions are defined by default but can be overwritten by defining your own set of functions.&lt;br /&gt;
This is generally only necessary if you want to do something special which is not provided by the default start/stop/restart implementations.&lt;br /&gt;
&lt;br /&gt;
=== start ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
start() {&lt;br /&gt;
    ebegin &amp;quot;Starting mydaemon&amp;quot;&lt;br /&gt;
    start-stop-daemon --start \&lt;br /&gt;
        --exec /usr/sbin/mydaemon \&lt;br /&gt;
        --pidfile /var/run/mydaemon.pid \&lt;br /&gt;
        -- \&lt;br /&gt;
        --args-for-mydaemon&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stop() {&lt;br /&gt;
    ebegin &amp;quot;Stopping mydaemon&amp;quot;&lt;br /&gt;
    start-stop-daemon --stop --exec /home/user/mydaemon\&lt;br /&gt;
    --pidfile /home/user/mydaemon.pid&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== restart ===&lt;br /&gt;
&lt;br /&gt;
== Daemon, Forking, Logging ==&lt;br /&gt;
&lt;br /&gt;
TODO...&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]]&lt;/div&gt;</summary>
		<author><name>Lchristolo</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15521</id>
		<title>Writing Init Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15521"/>
		<updated>2018-12-03T11:25:22Z</updated>

		<summary type="html">&lt;p&gt;Lchristolo: /* start, stop, restart functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux uses the [https://github.com/OpenRC/openrc OpenRC] init system to start services. Don&#039;t confuse OpenRC init with our system init (the first process that is executed aka pid 1). Many of the current init.d script found in Alpine Linux are taken from Gentoo. If you want to save time you could search [https://packages.gentoo.org/categories Gentoo&#039;s repository] for an existing initscript for your service. You can also check [https://wiki.gentoo.org/wiki/Handbook:X86/Working/Initscripts#Writing_initscripts Gentoo&#039;s wiki] for some additional OpenRC information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;NOTE&amp;lt;/strong&amp;gt;: OpenRC recently added [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md documentation] on how to write proper Init scripts. Make sure you read it!&lt;br /&gt;
&lt;br /&gt;
If you cannot find an init.d script from Gentoo, or you just want to start to write your own init.d scripts, we provide you with some basic information on how to write simple OpenRC init scripts.&lt;br /&gt;
&lt;br /&gt;
Primary information about the OpenRC format can be found in the [http://manpages.org/openrc-run/8 OpenRC man page openrc-run].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;apk add openrc-doc man&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;man openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Minimal Templates ==&lt;br /&gt;
&lt;br /&gt;
Every init.d script you write needs to start with a [https://en.wikipedia.org/wiki/Shebang_(Unix) shebang] like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/sbin/openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services relying on OpenRC exclusively ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/path/to/command&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services supervised by [http://www.skarnet.org/software/s6/ s6] ===&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* Install and configure the &amp;lt;code&amp;gt;s6-scan&amp;lt;/code&amp;gt; service to start on system boot&lt;br /&gt;
* Exclude &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;status()&amp;lt;/code&amp;gt; functions in order for s6 supervision to work reliably. OpenRC has built-in equivalent functions which invoke the necessary s6 commands.&lt;br /&gt;
* Include a &amp;lt;code&amp;gt;depend()&amp;lt;/code&amp;gt; stanza to ensure that the &amp;lt;code&amp;gt;s6-svscan&amp;lt;/code&amp;gt; service is already running.&lt;br /&gt;
* Add a &amp;lt;code&amp;gt;start_pre()&amp;lt;/code&amp;gt; stanza to symlink the service directory into the scan directory, because the &amp;lt;code&amp;gt;/etc/init.d/bootmisc&amp;lt;/code&amp;gt; scripts cleans out the &amp;lt;code&amp;gt;/run&amp;lt;/code&amp;gt; directory on system boot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;foo&amp;quot;&lt;br /&gt;
supervisor=&amp;quot;s6&amp;quot;&lt;br /&gt;
s6_service_path=&amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
    need s6-svscan&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
    if [ ! -L &amp;quot;${RC_SVC_DIR}/s6-scan/${name}&amp;quot; ]; then&lt;br /&gt;
        ln -s &amp;quot;/path/to/${name}/service/dir&amp;quot; &amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest of the below basic example could be omitted, but that would most probably leave you with an non working initd script.&lt;br /&gt;
&lt;br /&gt;
== Basic example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
  &lt;br /&gt;
name=$RC_SVCNAME&lt;br /&gt;
cfgfile=&amp;quot;/etc/$RC_SVCNAME/$RC_SVCNAME.conf&amp;quot;&lt;br /&gt;
command=&amp;quot;/usr/bin/my_daemon&amp;quot;&lt;br /&gt;
command_args=&amp;quot;--my-daemon-args&amp;quot;&lt;br /&gt;
command_user=&amp;quot;my_system_user&amp;quot;&lt;br /&gt;
pidfile=&amp;quot;/run/$RC_SVCNAME/$RC_SVCNAME.pid&amp;quot;&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--args-for-start-stop-daemon&amp;quot;&lt;br /&gt;
command_background=&amp;quot;yes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
        need net&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
        checkpath --directory --owner $command_user:$command_user --mode 0775 \&lt;br /&gt;
                /run/$RC_SVCNAME /var/log/$RC_SVCNAME&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== start, stop, restart functions ==&lt;br /&gt;
&lt;br /&gt;
OpenRC defined a few basic functions ie: start, stop, restart. These functions are defined by default but can be overwritten by defining your own set of functions.&lt;br /&gt;
This is generally only necessary if you want to do something special which is not provided by the default start/stop/restart implementations.&lt;br /&gt;
&lt;br /&gt;
=== start ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
start() {&lt;br /&gt;
    ebegin &amp;quot;Starting mydaemon&amp;quot;&lt;br /&gt;
    start-stop-daemon --start \&lt;br /&gt;
        --exec /usr/sbin/mydaemon \&lt;br /&gt;
        --pidfile /var/run/mydaemon.pid \&lt;br /&gt;
        -- \&lt;br /&gt;
        --args-for-mydaemon&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stop() {&lt;br /&gt;
    ebegin &amp;quot;Stopping mydaemon&amp;quot;&lt;br /&gt;
    start-stop-daemon --stop --exec /home/user/mydaemon\&lt;br /&gt;
    --pidfile /home/user/mydaemon.pid&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== restart ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
restart() {&lt;br /&gt;
    stop&lt;br /&gt;
    start&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Daemon, Forking, Logging ==&lt;br /&gt;
&lt;br /&gt;
TODO...&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]]&lt;/div&gt;</summary>
		<author><name>Lchristolo</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15520</id>
		<title>Writing Init Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15520"/>
		<updated>2018-12-03T11:19:26Z</updated>

		<summary type="html">&lt;p&gt;Lchristolo: /* start, stop, restart functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux uses the [https://github.com/OpenRC/openrc OpenRC] init system to start services. Don&#039;t confuse OpenRC init with our system init (the first process that is executed aka pid 1). Many of the current init.d script found in Alpine Linux are taken from Gentoo. If you want to save time you could search [https://packages.gentoo.org/categories Gentoo&#039;s repository] for an existing initscript for your service. You can also check [https://wiki.gentoo.org/wiki/Handbook:X86/Working/Initscripts#Writing_initscripts Gentoo&#039;s wiki] for some additional OpenRC information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;NOTE&amp;lt;/strong&amp;gt;: OpenRC recently added [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md documentation] on how to write proper Init scripts. Make sure you read it!&lt;br /&gt;
&lt;br /&gt;
If you cannot find an init.d script from Gentoo, or you just want to start to write your own init.d scripts, we provide you with some basic information on how to write simple OpenRC init scripts.&lt;br /&gt;
&lt;br /&gt;
Primary information about the OpenRC format can be found in the [http://manpages.org/openrc-run/8 OpenRC man page openrc-run].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;apk add openrc-doc man&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;man openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Minimal Templates ==&lt;br /&gt;
&lt;br /&gt;
Every init.d script you write needs to start with a [https://en.wikipedia.org/wiki/Shebang_(Unix) shebang] like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/sbin/openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services relying on OpenRC exclusively ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/path/to/command&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services supervised by [http://www.skarnet.org/software/s6/ s6] ===&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* Install and configure the &amp;lt;code&amp;gt;s6-scan&amp;lt;/code&amp;gt; service to start on system boot&lt;br /&gt;
* Exclude &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;status()&amp;lt;/code&amp;gt; functions in order for s6 supervision to work reliably. OpenRC has built-in equivalent functions which invoke the necessary s6 commands.&lt;br /&gt;
* Include a &amp;lt;code&amp;gt;depend()&amp;lt;/code&amp;gt; stanza to ensure that the &amp;lt;code&amp;gt;s6-svscan&amp;lt;/code&amp;gt; service is already running.&lt;br /&gt;
* Add a &amp;lt;code&amp;gt;start_pre()&amp;lt;/code&amp;gt; stanza to symlink the service directory into the scan directory, because the &amp;lt;code&amp;gt;/etc/init.d/bootmisc&amp;lt;/code&amp;gt; scripts cleans out the &amp;lt;code&amp;gt;/run&amp;lt;/code&amp;gt; directory on system boot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;foo&amp;quot;&lt;br /&gt;
supervisor=&amp;quot;s6&amp;quot;&lt;br /&gt;
s6_service_path=&amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
    need s6-svscan&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
    if [ ! -L &amp;quot;${RC_SVC_DIR}/s6-scan/${name}&amp;quot; ]; then&lt;br /&gt;
        ln -s &amp;quot;/path/to/${name}/service/dir&amp;quot; &amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest of the below basic example could be omitted, but that would most probably leave you with an non working initd script.&lt;br /&gt;
&lt;br /&gt;
== Basic example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
  &lt;br /&gt;
name=$RC_SVCNAME&lt;br /&gt;
cfgfile=&amp;quot;/etc/$RC_SVCNAME/$RC_SVCNAME.conf&amp;quot;&lt;br /&gt;
command=&amp;quot;/usr/bin/my_daemon&amp;quot;&lt;br /&gt;
command_args=&amp;quot;--my-daemon-args&amp;quot;&lt;br /&gt;
command_user=&amp;quot;my_system_user&amp;quot;&lt;br /&gt;
pidfile=&amp;quot;/run/$RC_SVCNAME/$RC_SVCNAME.pid&amp;quot;&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--args-for-start-stop-daemon&amp;quot;&lt;br /&gt;
command_background=&amp;quot;yes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
        need net&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
        checkpath --directory --owner $command_user:$command_user --mode 0775 \&lt;br /&gt;
                /run/$RC_SVCNAME /var/log/$RC_SVCNAME&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== start, stop, restart functions ==&lt;br /&gt;
&lt;br /&gt;
OpenRC defined a few basic functions ie: start, stop, restart. These functions are defined by default but can be overwritten by defining your own set of functions.&lt;br /&gt;
This is generally only necessary if you want to do something special which is not provided by the default start/stop/restart implementations.&lt;br /&gt;
&lt;br /&gt;
=== start ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
start() {&lt;br /&gt;
    ebegin &amp;quot;Starting mydaemon&amp;quot;&lt;br /&gt;
    start-stop-daemon --start \&lt;br /&gt;
        --exec /usr/sbin/mydaemon \&lt;br /&gt;
        --pidfile /var/run/mydaemon.pid \&lt;br /&gt;
        -- \&lt;br /&gt;
        --args-for-mydaemon&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stop() {&lt;br /&gt;
    ebegin &amp;quot;Stopping mydaemon&amp;quot;&lt;br /&gt;
    start-stop-daemon --stop --exec /home/user/mydaemon\&lt;br /&gt;
    --pidfile /home/user/mydaemon.pid&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== restart ===&lt;br /&gt;
&lt;br /&gt;
== Daemon, Forking, Logging ==&lt;br /&gt;
&lt;br /&gt;
TODO...&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]]&lt;/div&gt;</summary>
		<author><name>Lchristolo</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15519</id>
		<title>Writing Init Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15519"/>
		<updated>2018-12-03T11:14:45Z</updated>

		<summary type="html">&lt;p&gt;Lchristolo: /* start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux uses the [https://github.com/OpenRC/openrc OpenRC] init system to start services. Don&#039;t confuse OpenRC init with our system init (the first process that is executed aka pid 1). Many of the current init.d script found in Alpine Linux are taken from Gentoo. If you want to save time you could search [https://packages.gentoo.org/categories Gentoo&#039;s repository] for an existing initscript for your service. You can also check [https://wiki.gentoo.org/wiki/Handbook:X86/Working/Initscripts#Writing_initscripts Gentoo&#039;s wiki] for some additional OpenRC information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;NOTE&amp;lt;/strong&amp;gt;: OpenRC recently added [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md documentation] on how to write proper Init scripts. Make sure you read it!&lt;br /&gt;
&lt;br /&gt;
If you cannot find an init.d script from Gentoo, or you just want to start to write your own init.d scripts, we provide you with some basic information on how to write simple OpenRC init scripts.&lt;br /&gt;
&lt;br /&gt;
Primary information about the OpenRC format can be found in the [http://manpages.org/openrc-run/8 OpenRC man page openrc-run].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;apk add openrc-doc man&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;man openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Minimal Templates ==&lt;br /&gt;
&lt;br /&gt;
Every init.d script you write needs to start with a [https://en.wikipedia.org/wiki/Shebang_(Unix) shebang] like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/sbin/openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services relying on OpenRC exclusively ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/path/to/command&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services supervised by [http://www.skarnet.org/software/s6/ s6] ===&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* Install and configure the &amp;lt;code&amp;gt;s6-scan&amp;lt;/code&amp;gt; service to start on system boot&lt;br /&gt;
* Exclude &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;status()&amp;lt;/code&amp;gt; functions in order for s6 supervision to work reliably. OpenRC has built-in equivalent functions which invoke the necessary s6 commands.&lt;br /&gt;
* Include a &amp;lt;code&amp;gt;depend()&amp;lt;/code&amp;gt; stanza to ensure that the &amp;lt;code&amp;gt;s6-svscan&amp;lt;/code&amp;gt; service is already running.&lt;br /&gt;
* Add a &amp;lt;code&amp;gt;start_pre()&amp;lt;/code&amp;gt; stanza to symlink the service directory into the scan directory, because the &amp;lt;code&amp;gt;/etc/init.d/bootmisc&amp;lt;/code&amp;gt; scripts cleans out the &amp;lt;code&amp;gt;/run&amp;lt;/code&amp;gt; directory on system boot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;foo&amp;quot;&lt;br /&gt;
supervisor=&amp;quot;s6&amp;quot;&lt;br /&gt;
s6_service_path=&amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
    need s6-svscan&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
    if [ ! -L &amp;quot;${RC_SVC_DIR}/s6-scan/${name}&amp;quot; ]; then&lt;br /&gt;
        ln -s &amp;quot;/path/to/${name}/service/dir&amp;quot; &amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest of the below basic example could be omitted, but that would most probably leave you with an non working initd script.&lt;br /&gt;
&lt;br /&gt;
== Basic example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
  &lt;br /&gt;
name=$RC_SVCNAME&lt;br /&gt;
cfgfile=&amp;quot;/etc/$RC_SVCNAME/$RC_SVCNAME.conf&amp;quot;&lt;br /&gt;
command=&amp;quot;/usr/bin/my_daemon&amp;quot;&lt;br /&gt;
command_args=&amp;quot;--my-daemon-args&amp;quot;&lt;br /&gt;
command_user=&amp;quot;my_system_user&amp;quot;&lt;br /&gt;
pidfile=&amp;quot;/run/$RC_SVCNAME/$RC_SVCNAME.pid&amp;quot;&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--args-for-start-stop-daemon&amp;quot;&lt;br /&gt;
command_background=&amp;quot;yes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
        need net&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
        checkpath --directory --owner $command_user:$command_user --mode 0775 \&lt;br /&gt;
                /run/$RC_SVCNAME /var/log/$RC_SVCNAME&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== start, stop, restart functions ==&lt;br /&gt;
&lt;br /&gt;
OpenRC defined a few basic functions ie: start, stop, restart. These functions are defined by default but can be overwritten by defining your own set of functions.&lt;br /&gt;
This is generally only necessary if you want to do something special which is not provided by the default start/stop/restart implementations.&lt;br /&gt;
&lt;br /&gt;
=== start ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
start() {&lt;br /&gt;
    ebegin &amp;quot;Starting mydaemon&amp;quot;&lt;br /&gt;
    start-stop-daemon --start \&lt;br /&gt;
        --exec /usr/sbin/mydaemon \&lt;br /&gt;
        --pidfile /var/run/mydaemon.pid \&lt;br /&gt;
        -- \&lt;br /&gt;
        --args-for-mydaemon&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== restart ===&lt;br /&gt;
&lt;br /&gt;
== Daemon, Forking, Logging ==&lt;br /&gt;
&lt;br /&gt;
TODO...&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]]&lt;/div&gt;</summary>
		<author><name>Lchristolo</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15518</id>
		<title>Writing Init Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15518"/>
		<updated>2018-12-03T11:14:06Z</updated>

		<summary type="html">&lt;p&gt;Lchristolo: /* stop */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux uses the [https://github.com/OpenRC/openrc OpenRC] init system to start services. Don&#039;t confuse OpenRC init with our system init (the first process that is executed aka pid 1). Many of the current init.d script found in Alpine Linux are taken from Gentoo. If you want to save time you could search [https://packages.gentoo.org/categories Gentoo&#039;s repository] for an existing initscript for your service. You can also check [https://wiki.gentoo.org/wiki/Handbook:X86/Working/Initscripts#Writing_initscripts Gentoo&#039;s wiki] for some additional OpenRC information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;NOTE&amp;lt;/strong&amp;gt;: OpenRC recently added [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md documentation] on how to write proper Init scripts. Make sure you read it!&lt;br /&gt;
&lt;br /&gt;
If you cannot find an init.d script from Gentoo, or you just want to start to write your own init.d scripts, we provide you with some basic information on how to write simple OpenRC init scripts.&lt;br /&gt;
&lt;br /&gt;
Primary information about the OpenRC format can be found in the [http://manpages.org/openrc-run/8 OpenRC man page openrc-run].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;apk add openrc-doc man&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;man openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Minimal Templates ==&lt;br /&gt;
&lt;br /&gt;
Every init.d script you write needs to start with a [https://en.wikipedia.org/wiki/Shebang_(Unix) shebang] like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/sbin/openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services relying on OpenRC exclusively ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/path/to/command&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services supervised by [http://www.skarnet.org/software/s6/ s6] ===&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* Install and configure the &amp;lt;code&amp;gt;s6-scan&amp;lt;/code&amp;gt; service to start on system boot&lt;br /&gt;
* Exclude &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;status()&amp;lt;/code&amp;gt; functions in order for s6 supervision to work reliably. OpenRC has built-in equivalent functions which invoke the necessary s6 commands.&lt;br /&gt;
* Include a &amp;lt;code&amp;gt;depend()&amp;lt;/code&amp;gt; stanza to ensure that the &amp;lt;code&amp;gt;s6-svscan&amp;lt;/code&amp;gt; service is already running.&lt;br /&gt;
* Add a &amp;lt;code&amp;gt;start_pre()&amp;lt;/code&amp;gt; stanza to symlink the service directory into the scan directory, because the &amp;lt;code&amp;gt;/etc/init.d/bootmisc&amp;lt;/code&amp;gt; scripts cleans out the &amp;lt;code&amp;gt;/run&amp;lt;/code&amp;gt; directory on system boot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;foo&amp;quot;&lt;br /&gt;
supervisor=&amp;quot;s6&amp;quot;&lt;br /&gt;
s6_service_path=&amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
    need s6-svscan&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
    if [ ! -L &amp;quot;${RC_SVC_DIR}/s6-scan/${name}&amp;quot; ]; then&lt;br /&gt;
        ln -s &amp;quot;/path/to/${name}/service/dir&amp;quot; &amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest of the below basic example could be omitted, but that would most probably leave you with an non working initd script.&lt;br /&gt;
&lt;br /&gt;
== Basic example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
  &lt;br /&gt;
name=$RC_SVCNAME&lt;br /&gt;
cfgfile=&amp;quot;/etc/$RC_SVCNAME/$RC_SVCNAME.conf&amp;quot;&lt;br /&gt;
command=&amp;quot;/usr/bin/my_daemon&amp;quot;&lt;br /&gt;
command_args=&amp;quot;--my-daemon-args&amp;quot;&lt;br /&gt;
command_user=&amp;quot;my_system_user&amp;quot;&lt;br /&gt;
pidfile=&amp;quot;/run/$RC_SVCNAME/$RC_SVCNAME.pid&amp;quot;&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--args-for-start-stop-daemon&amp;quot;&lt;br /&gt;
command_background=&amp;quot;yes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
        need net&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
        checkpath --directory --owner $command_user:$command_user --mode 0775 \&lt;br /&gt;
                /run/$RC_SVCNAME /var/log/$RC_SVCNAME&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== start, stop, restart functions ==&lt;br /&gt;
&lt;br /&gt;
OpenRC defined a few basic functions ie: start, stop, restart. These functions are defined by default but can be overwritten by defining your own set of functions.&lt;br /&gt;
This is generally only necessary if you want to do something special which is not provided by the default start/stop/restart implementations.&lt;br /&gt;
&lt;br /&gt;
=== start ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
start() {&lt;br /&gt;
    ebegin &amp;quot;Starting mydaemon&amp;quot;&lt;br /&gt;
    start-stop-daemon --start \&lt;br /&gt;
        --exec /usr/sbin/mydaemon \&lt;br /&gt;
        --pidfile /var/run/mydaemon.pid \&lt;br /&gt;
        -- \&lt;br /&gt;
        --args-for-mydaemon&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
stop() {&lt;br /&gt;
    ebegin &amp;quot;Stopping mydeamon&amp;quot;&lt;br /&gt;
    start-stop-daemon --stop --exec /home/user/mydeamon\&lt;br /&gt;
    --pidfile /home/user/mydeamon.pid&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
stop() {&lt;br /&gt;
    ebegin &amp;quot;Stopping mydeamon&amp;quot;&lt;br /&gt;
    start-stop-daemon --stop --exec /home/user/mydeamon\&lt;br /&gt;
    --pidfile /home/user/mydeamon.pid&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
=== restart ===&lt;br /&gt;
&lt;br /&gt;
== Daemon, Forking, Logging ==&lt;br /&gt;
&lt;br /&gt;
TODO...&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]]&lt;/div&gt;</summary>
		<author><name>Lchristolo</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15517</id>
		<title>Writing Init Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Writing_Init_Scripts&amp;diff=15517"/>
		<updated>2018-12-03T11:13:24Z</updated>

		<summary type="html">&lt;p&gt;Lchristolo: /* stop */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux uses the [https://github.com/OpenRC/openrc OpenRC] init system to start services. Don&#039;t confuse OpenRC init with our system init (the first process that is executed aka pid 1). Many of the current init.d script found in Alpine Linux are taken from Gentoo. If you want to save time you could search [https://packages.gentoo.org/categories Gentoo&#039;s repository] for an existing initscript for your service. You can also check [https://wiki.gentoo.org/wiki/Handbook:X86/Working/Initscripts#Writing_initscripts Gentoo&#039;s wiki] for some additional OpenRC information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;NOTE&amp;lt;/strong&amp;gt;: OpenRC recently added [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md documentation] on how to write proper Init scripts. Make sure you read it!&lt;br /&gt;
&lt;br /&gt;
If you cannot find an init.d script from Gentoo, or you just want to start to write your own init.d scripts, we provide you with some basic information on how to write simple OpenRC init scripts.&lt;br /&gt;
&lt;br /&gt;
Primary information about the OpenRC format can be found in the [http://manpages.org/openrc-run/8 OpenRC man page openrc-run].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;apk add openrc-doc man&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;man openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Minimal Templates ==&lt;br /&gt;
&lt;br /&gt;
Every init.d script you write needs to start with a [https://en.wikipedia.org/wiki/Shebang_(Unix) shebang] like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/sbin/openrc-run&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services relying on OpenRC exclusively ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/path/to/command&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Services supervised by [http://www.skarnet.org/software/s6/ s6] ===&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* Install and configure the &amp;lt;code&amp;gt;s6-scan&amp;lt;/code&amp;gt; service to start on system boot&lt;br /&gt;
* Exclude &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;status()&amp;lt;/code&amp;gt; functions in order for s6 supervision to work reliably. OpenRC has built-in equivalent functions which invoke the necessary s6 commands.&lt;br /&gt;
* Include a &amp;lt;code&amp;gt;depend()&amp;lt;/code&amp;gt; stanza to ensure that the &amp;lt;code&amp;gt;s6-svscan&amp;lt;/code&amp;gt; service is already running.&lt;br /&gt;
* Add a &amp;lt;code&amp;gt;start_pre()&amp;lt;/code&amp;gt; stanza to symlink the service directory into the scan directory, because the &amp;lt;code&amp;gt;/etc/init.d/bootmisc&amp;lt;/code&amp;gt; scripts cleans out the &amp;lt;code&amp;gt;/run&amp;lt;/code&amp;gt; directory on system boot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;foo&amp;quot;&lt;br /&gt;
supervisor=&amp;quot;s6&amp;quot;&lt;br /&gt;
s6_service_path=&amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
    need s6-svscan&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
    if [ ! -L &amp;quot;${RC_SVC_DIR}/s6-scan/${name}&amp;quot; ]; then&lt;br /&gt;
        ln -s &amp;quot;/path/to/${name}/service/dir&amp;quot; &amp;quot;${RC_SVCDIR}/s6-scan/${name}&amp;quot;&lt;br /&gt;
    fi&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest of the below basic example could be omitted, but that would most probably leave you with an non working initd script.&lt;br /&gt;
&lt;br /&gt;
== Basic example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
  &lt;br /&gt;
name=$RC_SVCNAME&lt;br /&gt;
cfgfile=&amp;quot;/etc/$RC_SVCNAME/$RC_SVCNAME.conf&amp;quot;&lt;br /&gt;
command=&amp;quot;/usr/bin/my_daemon&amp;quot;&lt;br /&gt;
command_args=&amp;quot;--my-daemon-args&amp;quot;&lt;br /&gt;
command_user=&amp;quot;my_system_user&amp;quot;&lt;br /&gt;
pidfile=&amp;quot;/run/$RC_SVCNAME/$RC_SVCNAME.pid&amp;quot;&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--args-for-start-stop-daemon&amp;quot;&lt;br /&gt;
command_background=&amp;quot;yes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
        need net&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start_pre() {&lt;br /&gt;
        checkpath --directory --owner $command_user:$command_user --mode 0775 \&lt;br /&gt;
                /run/$RC_SVCNAME /var/log/$RC_SVCNAME&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== start, stop, restart functions ==&lt;br /&gt;
&lt;br /&gt;
OpenRC defined a few basic functions ie: start, stop, restart. These functions are defined by default but can be overwritten by defining your own set of functions.&lt;br /&gt;
This is generally only necessary if you want to do something special which is not provided by the default start/stop/restart implementations.&lt;br /&gt;
&lt;br /&gt;
=== start ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
start() {&lt;br /&gt;
    ebegin &amp;quot;Starting mydaemon&amp;quot;&lt;br /&gt;
    start-stop-daemon --start \&lt;br /&gt;
        --exec /usr/sbin/mydaemon \&lt;br /&gt;
        --pidfile /var/run/mydaemon.pid \&lt;br /&gt;
        -- \&lt;br /&gt;
        --args-for-mydaemon&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
stop() {&lt;br /&gt;
    ebegin &amp;quot;Stopping mydeamon&amp;quot;&lt;br /&gt;
    start-stop-daemon --stop --exec /home/user/mydeamon\&lt;br /&gt;
    --pidfile /home/user/mydeamon.pid&lt;br /&gt;
    eend $?&lt;br /&gt;
}&lt;br /&gt;
=== stop ===&lt;br /&gt;
&lt;br /&gt;
=== restart ===&lt;br /&gt;
&lt;br /&gt;
== Daemon, Forking, Logging ==&lt;br /&gt;
&lt;br /&gt;
TODO...&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]]&lt;/div&gt;</summary>
		<author><name>Lchristolo</name></author>
	</entry>
</feed>