From 5f016aee3902cbfe8ef0a633b36b495e4101fd1d Mon Sep 17 00:00:00 2001 From: Al Pou Date: Tue, 24 May 2022 15:52:51 -0400 Subject: [PATCH] Login class for i2pd is added in separate file in /etc/login.conf.d if OpenBSD 7.1 or newer --- Makefile | 14 ++++++++++++++ README.md | 15 ++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 495fc33..89fead3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ .PHONY: install uninstall +CLASS_FILE = /etc/login.conf.d/i2pd install: # This command verifies if the group _i2pd exists. If it doesn't, it @@ -18,6 +19,16 @@ install: -c "i2pd account" -d /var/lib/i2pd -s /sbin/nologin _i2pd chown -R _i2pd:_i2pd /var/lib/i2pd + # This command adds a new login class allowing _i2pd to open more files + # simultaneously if the version of OpenBSD is 7.1 or newer. For older + # versions, the modification should be done manually in /etc/login.conf. + if [ $$(echo "$$(uname -r) >= 7.1" | bc) = 1 ]; then \ + echo "i2pd:\\" > $(CLASS_FILE); \ + echo "\t:openfiles-cur=102400:\\" >> $(CLASS_FILE); \ + echo "\t:openfiles-max=102400:\\" >> $(CLASS_FILE); \ + echo "\t:tc=daemon:" >> $(CLASS_FILE); \ + fi + # 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 @@ -29,6 +40,9 @@ uninstall: rcctl disable i2pd rm /etc/rc.d/i2pd + # This command removes the i2pd login class. + rm $(CLASS_FILE) + # This command removes the _i2pd user and its home. userdel -r _i2pd diff --git a/README.md b/README.md index 0030667..1173038 100644 --- a/README.md +++ b/README.md @@ -77,28 +77,33 @@ 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`: +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: -This login class will be used by the user `_i2pd` created in the following +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, makes the binaries +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 +The final step is to enable the service to make it start at boot time and to manually start it: $ doas rcctl enable i2pd