summaryrefslogtreecommitdiff
path: root/repo/i2pd
diff options
context:
space:
mode:
Diffstat (limited to 'repo/i2pd')
-rw-r--r--repo/i2pd/i2pd.confd13
-rw-r--r--repo/i2pd/i2pd.initd52
-rw-r--r--repo/i2pd/i2pd.xibuild46
3 files changed, 111 insertions, 0 deletions
diff --git a/repo/i2pd/i2pd.confd b/repo/i2pd/i2pd.confd
new file mode 100644
index 0000000..9b609c3
--- /dev/null
+++ b/repo/i2pd/i2pd.confd
@@ -0,0 +1,13 @@
+I2PD_USER=i2pd
+I2PD_GROUP=i2pd
+I2PD_LOG=/var/log/i2pd/i2pd.log
+I2PD_PID=/run/i2pd/i2pd.pid
+
+# max number of open files (for floodfill)
+rc_ulimit="-n 4096"
+
+# Options to i2pd
+I2PD_OPTIONS="--daemon --service --pidfile=${I2PD_PID} \
+--log=file --logfile=${I2PD_LOG} \
+--conf=/etc/i2pd/i2pd.conf --tunconf=/etc/i2pd/tunnels.conf"
+
diff --git a/repo/i2pd/i2pd.initd b/repo/i2pd/i2pd.initd
new file mode 100644
index 0000000..5f4346a
--- /dev/null
+++ b/repo/i2pd/i2pd.initd
@@ -0,0 +1,52 @@
+#!/sbin/openrc-run
+# Copyright 1999-2016 Gentoo Foundation
+# Copyright 2018 l-n-s <supervillain@riseup.net>
+# Distributed under the terms of the GNU General Public License v2
+
+description="C++ daemon for accessing the I2P network"
+description_graceful="Graceful shutdown, takes 10 minutes"
+
+command="/usr/sbin/i2pd"
+command_args="${I2PD_OPTIONS}"
+user="${I2PD_USER}:${I2PD_GROUP}"
+start_stop_daemon_args="
+ --user \"${user}\"
+ --pidfile \"${I2PD_PID}\"
+ --progress
+"
+retry="SIGTERM/20/SIGKILL/20"
+
+I2PD_PID_DIR=$(dirname "${I2PD_PID}")
+
+extra_started_commands="graceful"
+
+depend() {
+ need net
+ after firewall
+ use dns logger netmount
+}
+
+start_pre() {
+ if [ -z "${I2PD_USER}" ] || \
+ [ -z "${I2PD_GROUP}" ] || \
+ [ -z "${I2PD_PID}" ] || \
+ [ -z "${I2PD_OPTIONS}" ] ; then
+ eerror "Not all variables I2PD_USER, I2PD_GROUP, I2PD_PID, I2PD_OPTIONS are defined."
+ eerror "Check your /etc/conf.d/i2pd."
+ return 1
+ fi
+ if [ -n "${I2PD_LOG}" ]; then
+ checkpath -f -o "${user}" "${I2PD_LOG}"
+ fi
+ checkpath -d -m 0750 -o "${user}" "${I2PD_PID_DIR}"
+}
+
+graceful() {
+ # on SIGINT, i2pd stops accepting tunnels and shuts down in 600 seconds
+ ebegin "Gracefully stopping i2pd, this takes 10 minutes"
+ mark_service_stopping
+ eval start-stop-daemon --stop ${start_stop_daemon_args} \
+ --exec "${command}" --retry 'SIGINT/620/SIGTERM/20/SIGKILL/20'
+ eend $? && mark_service_stopped
+}
+
diff --git a/repo/i2pd/i2pd.xibuild b/repo/i2pd/i2pd.xibuild
new file mode 100644
index 0000000..78532c4
--- /dev/null
+++ b/repo/i2pd/i2pd.xibuild
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+NAME="i2pd"
+DESC="I2P Router written in C++"
+
+MAKEDEPS="make "
+DEPS="boost sbase openssl musl "
+
+PKG_VER=2.41.0
+SOURCE="https://github.com/PurpleI2P/i2pd/archive/$PKG_VER/i2pd-$PKG_VER.tar.gz"
+ADDITIONAL="i2pd.initd i2pd.confd "
+
+prepare () {
+ # Makefile.linux assumes some gnu/linux features (expr match)
+ # so we will use the bsd makefile instead
+ mv Makefile.bsd Makefile.linux
+}
+
+build () {
+ make PREFIX=/usr
+}
+
+package () {
+ install -D -m 755 i2pd "$PKG_DEST"/usr/sbin/i2pd
+
+ install -dm755 -o i2p \
+ "$PKG_DEST"/etc/i2pd \
+ "$PKG_DEST"/usr/share/i2pd \
+ "$PKG_DEST"/var/lib/i2pd \
+ "$PKG_DEST"/var/log/i2pd
+
+ install -D -m 644 contrib/tunnels.conf "$PKG_DEST"/etc/i2pd/tunnels.conf
+ install -D -m 644 contrib/i2pd.conf "$PKG_DEST"/etc/i2pd/i2pd.conf
+ cp -r contrib/certificates/ "$PKG_DEST"/usr/share/i2pd/certificates
+ ln -s /usr/share/i2pd/certificates "$PKG_DEST"/var/lib/i2pd/certificates
+
+ install -m755 -D i2pd.initd \
+ "$PKG_DEST"/etc/init.d/i2pd
+ install -m644 -D i2pd.confd \
+ "$PKG_DEST"/etc/conf.d/i2pd
+}
+
+postinstall () {
+ adduser -S -D -H -h /var/lib/i2p -s /sbin/nologin -g tor tor 2>/dev/null
+ return 0
+}