i2pd-rc-openbsd/README.md

117 行
4.3 KiB
Markdown

# I2Pd RC script for OpenBSD
Instructions on how to compile I2Pd on OpenBSD, together with a makefile and an
RC script to make it a system service, allowing it to be started at boot and so
on.
## Description
[I2Pd](https://i2pd.website/) is packaged in
[OpenBSD](https://www.openbsd.org/)'s official repositories, but the provided
versions are old, and older versions don't always run reliably when interacting
with newer versions on the I2P network.
Fortunately, compiling the latest version from source on OpenBSD is painless.
LibreSSL is supported, the official instructions work out of the box, and only a
small manual intervention is required to make the daemon start at system boot.
This repository contains instructions on how to compile I2Pd on OpenBSD together
with a makefile and an RC script to make it a system service, which allows it
to be started at boot, restarted if it crashes, managed by `rcctl`, and more.
## Compiling and installing
This part is taken from
[the official instructions](https://i2pd.readthedocs.io/en/latest/devs/building/unix/#building-on-unix-systems)
for compiling and installing I2Pd on a generic Unix system.
If the instructions listed here differ from the official instructions,
prioritize the official instructions, unless a detail specific to OpenBSD is
stated here.
First, install
[a few dependencies](https://i2pd.readthedocs.io/en/latest/devs/building/requirements/).
Git is not in their list, but is needed as it does not come with OpenBSD's base
system:
$ doas pkg_add boost cmake git lzlib
Next, clone their git repository:
$ cd /a/folder/of/your/choice/where/to/clone/the/repo
$ git clone https://github.com/PurpleI2P/i2pd.git
Then, generate the makefile and compile the source. You can
[pass options to cmake](https://i2pd.readthedocs.io/en/latest/devs/building/unix/#cmake-options)
to customize your makefile:
$ cd i2pd/build
$ cmake .
$ make
Next, install the binaries you just compiled:
$ doas make install
Finally, the base config files and certificates must be copied in the
appropriate folders. This step is not clearly listed in the official
installation instructions. It is only mentionned
[on this page](https://i2pd.readthedocs.io/en/latest/user-guide/run/#recommended-way-to-run-i2pd-built-from-source).
These base files are in the `contrib` folder at the root of the git repository.
$ cd ../contrib
$ doas mkdir -p /etc/i2pd /var/lib/i2pd
$ doas cp -R i2pd.conf tunnels.* /etc/i2pd
$ doas cp -R certificates /var/lib/i2pd
## Making I2Pd start at boot
At this point, you can start I2Pd manually, but it won't start automatically
when the system boots. This section describes how to achieve this.
The first thing to do is to create a new login class to increase the number of
files I2Pd will be able to open simultaneously. By default, OpenBSD restricts
this number to a value that is too low for I2Pd to work properly. Symptoms of a
number that is too small include difficulties connecting to eepsites and high
CPU usage.
If you are using OpenBSD 7.0 or older, simply add the following lines at the
end of `/etc/login.conf` to create the login class:
i2pd:\
:openfiles-cur=102400:\
:openfiles-max=102400:\
:tc=daemon:
If you are using OpenBSD 7.1 or newer, a login class can be created by adding a
file in `/etc/login.conf.d`. The makefile ran in the next steps detects the
version and creates the file automatically.
The new login class will be used by the user `_i2pd` created in the following
steps. Next, clone this git repository:
$ cd /a/folder/of/your/choice/where/to/clone/the/repo
$ git clone https://gitlab.com/alpou/i2pd-rc-openbsd.git
Then, simply run the makefile. This step creates a dedicated `_i2pd` user and a
group of the same name if they don't already exist, creates the login class
described above if you are using OpenBSD 7.1 or newer, makes the binaries
previously compiled belong to them, and copies the init script in `/etc/rc.d`.
$ cd i2pd-rc-openbsd
$ doas make install
The final step is to enable the service to make it start at boot time and to
manually start it:
$ doas rcctl enable i2pd
$ doas rcctl start i2pd
## Licensing
The content of this repository is provided under a 0BSD license. See the LICENSE
file for more information.