Added readme, license, makefile, and rc script

このコミットが含まれているのは:
Al Pou 2022-04-03 19:37:59 -04:00
コミット 881359761b
4個のファイルの変更150行の追加75行の削除

12
LICENSE ノーマルファイル
ファイルの表示

@ -0,0 +1,12 @@
This is a Zero-Clause BSD (0BSD) license.
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

39
Makefile ノーマルファイル
ファイルの表示

@ -0,0 +1,39 @@
.PHONY: install uninstall
install:
# This command verifies if the group _i2pd exists. If it doesn't, it
# creates it with gid 838.
groupinfo -e _i2pd || groupadd -g 838 _i2pd
# These commands verify if the user _i2pd exists. If it doesn't, it
# creates it with uid 838, default group 838 (which is _i2pd), login
# class "i2pd" (created manually before running this script), comment
# "i2pd account", home directory /var/lib/i2pd, and login shell
# /sbin/nologin (which forbids it from loging in).
# The mkdir and chown are used instead of the -m option of useradd in
# case /var/lib/i2pd already existed before the execution of this make
# target.
mkdir -p /var/lib/i2pd
userinfo -e _i2pd || useradd -u 838 -g 838 -L i2pd \
-c "i2pd account" -d /var/lib/i2pd -s /sbin/nologin _i2pd
chown -R _i2pd:_i2pd /var/lib/i2pd
# This command copies the RC script in the RC script folder to allow
# I2Pd to be managed by the service supervisor.
install -o root -g bin -m 555 i2pd /etc/rc.d/i2pd
uninstall:
# This command removes the RC script.
rcctl disable i2pd
rm /etc/rc.d/i2pd
# This command removes the _i2pd user and its home.
userdel -r _i2pd
# This command removes the _i2pd group.
groupdel _i2pd

163
README.md
ファイルの表示

@ -1,92 +1,105 @@
# 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.
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.
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.com/alpou/i2pd-rc-openbsd.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.com/alpou/i2pd-rc-openbsd/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
[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.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
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.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
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.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Compiling and installing
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
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.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
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:
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
$ doas pkg_add boost cmake git lzlib
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
Next, clone their git repository:
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
$ cd /a/folder/of/your/choice/where/to/clone/the/repo
$ git clone https://github.com/PurpleI2P/i2pd.git
## License
For open source projects, say how it is licensed.
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:
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
$ 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 reposotory.
$ 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.
To create a login class, simply add the following lines at the end of
`/etc/login.conf`:
i2pd:\
:openfiles-cur=102400:\
:openfiles-max=102400:\
:tc=daemon:
This 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 TODO
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, 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
manually start it:
$ doas rcctl enable i2pd
$ doas rcctl start i2pd

11
i2pd ノーマルファイル
ファイルの表示

@ -0,0 +1,11 @@
#!/bin/ksh
# Note: This script goes in /etc/rc.d
daemon="/usr/local/bin/i2pd --daemon"
daemon_flags="--service --conf=/etc/i2pd/i2pd.conf --tunconf=/etc/i2pd/tunnels.conf --tunnelsdir=/etc/i2pd/tunnels.d --datadir=/var/lib/i2pd"
daemon_user="_i2pd"
. /etc/rc.d/rc.subr
rc_cmd $1