| | @@ -0,0 +1,60 @@ |
| 1 | +<title>Serving via rc on OpenBSD</title>
|
| 2 | +
|
| 3 | +OpenBSD provides [https://man.openbsd.org/rc.subr.8|rc.subr(8)],
|
| 4 | +a framework for writing [https://man.openbsd.org/rc.8|rc(8)] scripts.
|
| 5 | +
|
| 6 | +<h2>Creating the daemon</h2>
|
| 7 | +Create the file /etc/rc.d/fossil with contents like the following.
|
| 8 | +
|
| 9 | +<blockquote><pre>
|
| 10 | +#!/bin/ksh
|
| 11 | +daemon="/usr/local/bin/fossil" # fossil executable
|
| 12 | +daemon_user="_fossil" # user to run fossil as
|
| 13 | +daemon_flags="server /home/_fossil/example --repolist --port 8888" # fossil command
|
| 14 | +
|
| 15 | +. /etc/rc.d/rc.subr
|
| 16 | +# pexp="$daemon sil' kills the process.
|
| 17 | +rc_bg=YES # Run in the background, since fossil serve does not daemon</blockquote>
|
| 18 | +
|
| 19 | +<h3>pexp</h3>
|
| 20 | +You may need to uncomment the "pexp=". rc.subr typically
|
| 21 | +finds the daemon process based by matching the process name and argument list.
|
| 22 | +Without the "pexp=" line, rc.subr would look for this exact command:
|
| 23 | +
|
| 24 | +<blockquote><pre>
|
| 25 | +/usr/local/bin/fossil se--repolist --port 8888
|
| 26 | +</pre></blockquot--repolist --port 8888
|
| 27 | +</pre>
|
| 28 | +
|
| 29 | +Depending on the arguments and their order, fossil may rewrite the arguments
|
| 30 | +for display in the process listing ([https://man.openbsd.org/ps.1|ps(1)]),
|
| 31 | +so rc.subr may fail to find the process through the default match. The example
|
| 32 | +above does not get rewritten, but the same commands in a different order can
|
| 33 | +be rewritten.
|
| 34 | +For example, when I switch the order of the argublockquote><pre>
|
| 35 | +/usr/local/bin/fossil server --repolist --port 8888 /home/_fossil/example
|
| 36 | +</pre></blockquote>
|
| 37 | +
|
| 38 | +the process comblockquote><pre>
|
| 39 | +/usr/local/bin/fossil server /home/_fossil/example /home/_fossil/example 8888 /</blockquot /home/_fossil/example
|
| 40 | +</pre>
|
| 41 | +
|
| 42 | +The commented "pexp=" line instructs rc.subr to choose the processblockquote><pre>
|
| 43 | +/usr/local/bin/fossil server
|
| 44 | +</pre></blockquote>
|
| 45 | +
|
| 46 | +<h2>Enabling the daemon</h2>
|
| 47 | +>Enabling the daemon</h2>
|
| 48 | +
|
| 49 | +Once youblockquote>ssil, run these commands.
|
| 50 | +
|
| 51 | +<pre>
|
| 52 | +rcctl enable fossil # add fossil to pkg_scripts in /etc/rc.conf.</blockquot# start the daemon now
|
| 53 | +</pre>
|
| 54 | +
|
| 55 | +The daemon should now be running and set to start at boot.
|
| 56 | +You may want to serve multiple fossil instances with different options.
|
| 57 | +For example,
|
| 58 | +
|
| 59 | + * If different users own different repositories, you may want different users
|
| 60 | + to serve different repositori |