summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pcr/i2p/PKGBUILD85
-rw-r--r--pcr/i2p/i2p.install21
-rw-r--r--pcr/i2p/i2prouter.service19
-rw-r--r--pcr/i2p/i2prouter.sh192
-rw-r--r--pcr/i2p/router.config11
-rw-r--r--pcr/i2p/wrapper.config162
6 files changed, 490 insertions, 0 deletions
diff --git a/pcr/i2p/PKGBUILD b/pcr/i2p/PKGBUILD
new file mode 100644
index 000000000..3205fe5f4
--- /dev/null
+++ b/pcr/i2p/PKGBUILD
@@ -0,0 +1,85 @@
+# Maintainer: skydrome <skydrome@i2pmail.org>
+# Contributor: skydrome <skydrome@i2pmail.org>
+
+########[ OPTIONS ]########################################
+# Comment out if you want to build all language translations
+export LG2=en
+
+# Download sources from within i2p
+#_i2p_fetch=1
+###########################################################
+
+pkgname=i2p
+pkgver=0.9.29
+pkgrel=1
+pkgdesc="A distributed anonymous network"
+url="https://geti2p.net"
+license=('GPL2')
+arch=('any')
+depends=('java-runtime' 'java-service-wrapper')
+makedepends=('apache-ant' 'java-environment')
+[[ "$LG2" != 'en' ]] && makedepends+=('gettext')
+#optdepends=('gtk2: for rrd graphs')
+conflicts=('i2p-bin' 'i2p-dev')
+backup=('opt/i2p/wrapper.config')
+install='i2p.install'
+
+_url="https://download.i2p2.de/releases/${pkgver}"
+
+source=("${_url}/i2psource_${pkgver}.tar.bz2"{,.sig}
+ 'i2prouter.service' 'i2prouter.sh' 'wrapper.config' 'router.config')
+
+[[ $_i2p_fetch ]] && {
+ export http_proxy=127.0.0.1:4444
+ source=("http://echelon.i2p/${pkgver}/i2psource_${pkgver}.tar.bz2"{,.sig}
+ #"http://whnxvjwjhzsske5yevyokhskllvtisv5ueokw6yvh6t7zqrpra2q.b32.i2p/releases/${pkgver}/i2psource_${pkgver}.tar.bz2"{,.sig}
+ 'i2prouter.service' 'i2prouter.sh' 'wrapper.config' 'router.config')
+}
+
+sha256sums=('67da4ce224fef2b190ffeed5dba102a3b7724f061b1c168255625c028a97c3a7'
+ 'SKIP'
+ '9bb899ece87099716da29bac8b7da02916fc325699b68989e73c1fe333a6342f'
+ 'ea8f97e66461d591b1819eab39bbc40056b89ae12f7729b3dd9fd2ce088e5e53'
+ '72c0944cd2b04c747673a534475f2ec42c64d52fdda76714f1165c4655113de2'
+ '1527afbadcf849ef551b3b7b68d1a29eec316ee620f5320f2933f73ee9924978')
+
+# https://geti2p.net/en/get-involved/develop/release-signing-key
+validpgpkeys=('2D3D2D03910C6504C1210C65EE60C0C8EE7256A8')
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ source /etc/profile.d/apache-ant.sh
+ source /etc/profile.d/jre.sh
+
+ export ANT_OPTS="-Dfile.encoding=UTF-8"
+ ant preppkg-linux-only
+}
+
+package() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ install -dm755 "$pkgdir/usr/lib/tmpfiles.d"
+ install -dm755 "$pkgdir/usr/bin"
+ install -dm750 "$pkgdir/opt/i2p"
+
+ cp -r pkg-temp/* "$pkgdir/opt/i2p"
+ cp "$srcdir/wrapper.config" "$pkgdir/opt/i2p"
+
+ install -Dm644 "$srcdir/router.config" "$pkgdir/opt/i2p/router.config"
+ install -Dm755 "$srcdir/i2prouter.sh" "$pkgdir/opt/i2p/i2prouter"
+ install -Dm644 "$srcdir/i2prouter.service" "$pkgdir/usr/lib/systemd/system/i2prouter.service"
+ install -Dm644 "$pkgdir/opt/i2p/man/eepget.1" "$pkgdir/usr/share/man/man1/eepget.1"
+ install -Dm644 "$pkgdir/opt/i2p/LICENSE.txt" "$pkgdir/usr/share/licenses/i2p/LICENSE"
+ mv "$pkgdir"/opt/i2p/licenses/* "$pkgdir/usr/share/licenses/i2p/"
+
+ ln -s /opt/i2p/{eepget,i2prouter} "$pkgdir/usr/bin/"
+ chmod +x "$pkgdir"/opt/i2p/{eepget,i2prouter}
+
+ echo 'd /run/i2p 0700 i2p i2p -' >"$pkgdir/usr/lib/tmpfiles.d/i2prouter.conf"
+
+ sed -i "$pkgdir"/opt/i2p/eepget \
+ -e 's:%INSTALL_PATH:/opt/i2p:g'
+ sed -i "$pkgdir"/opt/i2p/clients.config \
+ -e "s:clientApp.4.startOnLoad=.*:clientApp.4.startOnLoad=false:"
+ rm -r "$pkgdir"/opt/i2p/{osid,postinstall.sh,runplain.sh,INSTALL-headless.txt,LICENSE.txt,licenses,man,lib/wrapper*}
+}
diff --git a/pcr/i2p/i2p.install b/pcr/i2p/i2p.install
new file mode 100644
index 000000000..146cac383
--- /dev/null
+++ b/pcr/i2p/i2p.install
@@ -0,0 +1,21 @@
+post_install() {
+ getent passwd i2p &>/dev/null || {
+ echo -n ">>> Creating i2p user... "
+ useradd --system --user-group --home /opt/i2p i2p
+ echo "done"
+ }
+ post_upgrade
+}
+
+post_upgrade() {
+ systemd-tmpfiles --create i2prouter.conf
+ chown -R i2p:i2p /opt/i2p
+}
+
+pre_remove() {
+ getent passwd i2p &>/dev/null && {
+ echo -n ">>> Removing i2p user... "
+ userdel i2p
+ echo "done"
+ }
+}
diff --git a/pcr/i2p/i2prouter.service b/pcr/i2p/i2prouter.service
new file mode 100644
index 000000000..7c278c833
--- /dev/null
+++ b/pcr/i2p/i2prouter.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Invisible Internet Project
+After=network.target
+
+[Service]
+Type=forking
+User=i2p
+PIDFile=/run/i2p/i2p.pid
+Environment=WRAPPER_CONF=/opt/i2p/wrapper.config
+ExecStart=/usr/bin/java-service-wrapper ${WRAPPER_CONF} \
+ wrapper.name=i2prouter wrapper.syslog.ident=i2prouter \
+ wrapper.daemonize=TRUE
+SendSIGKILL=no
+ExecReload=/bin/kill -USR1 $MAINPID
+ExecStop=/bin/kill -TERM $MAINPID
+SuccessExitStatus=0 2 3
+
+[Install]
+WantedBy=multi-user.target
diff --git a/pcr/i2p/i2prouter.sh b/pcr/i2p/i2prouter.sh
new file mode 100644
index 000000000..1af0a35b4
--- /dev/null
+++ b/pcr/i2p/i2prouter.sh
@@ -0,0 +1,192 @@
+#!/bin/bash
+
+#-----------------------------------------------------------------------------
+I2P_USER="i2p"
+WRAPPER_CMD="/usr/bin/java-service-wrapper"
+WRAPPER_CONF="/opt/i2p/wrapper.config"
+PIDDIR="/run/i2p"
+PIDFILE="$PIDDIR/i2p.pid"
+TIMEOUT=30
+#-----------------------------------------------------------------------------
+
+fail() {
+ printf "\e[1;31m>>> ERROR:\033[0m %s\n" "$*"
+ exit 1
+}
+debug() {
+ printf "\e[1;33m>>> DEBUG:\033[0m %s\n" "$*"
+}
+
+check_user() {
+ if [[ "$(id -un)" != "$I2P_USER" ]]; then
+ #debug "current user: $(id -un) dropping to user: $I2P_USER"
+ if [[ ! -d "$PIDDIR" ]]; then
+ mkdir -p "$PIDDIR"
+ chown ${I2P_USER}:${I2P_USER} "$PIDDIR"
+ fi
+ SCRIPT_PATH="$(cd $(dirname $0) && pwd)/$(basename $0)"
+ su - "$I2P_USER" -c "${SCRIPT_PATH} $@"
+ exit $?
+ fi
+}
+
+init_vars() {
+ [[ ! -r "$WRAPPER_CONF" ]] &&
+ fail "Unable to read \$WRAPPER_CONF: ${WRAPPER_CONF}"
+ [[ ! -x "$WRAPPER_CMD" ]] &&
+ fail "Unable to find or execute \$WRAPPER_CMD: ${WRAPPER_CMD}"
+ [[ ! $(grep -E ^I2P_USER $0) && "$EUID" = "0" ]] &&
+ fail "Attempting to start as root! Please edit $(basename $0) and set the variable \$I2P_USER"
+ [[ "$(id -un "$I2P_USER")" != "$I2P_USER" ]] &&
+ fail "\$I2P_USER does not exist: $I2P_USER"
+ COMMAND_LINE="\"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"i2prouter\" wrapper.name=\"i2prouter\""
+}
+
+get_wrapper_pid() {
+ pgrep -u "$I2P_USER" -f 'wrapper.name=i2prouter'
+}
+get_pid() {
+ pgrep -u "$I2P_USER" -f 'jar'
+}
+
+check_if_running() {
+ unset pid
+ if [[ -f "$PIDFILE" ]]; then
+ if [[ -r "$PIDFILE" ]]; then
+ pid=$(cat "$PIDFILE")
+ #debug "pid:$pid get_pid:$(get_pid)"
+ if [[ ! "$pid" ]]; then
+ pid=$(get_pid)
+ if [[ ! "$pid" ]]; then
+ echo "Removing stale pid file: $PIDFILE"
+ rm -f "$PIDFILE"
+ fi
+ else
+ [[ "$pid" != "$(get_pid)" ]] &&
+ fail "\$PIDFILE $PIDFILE differs from what is actually running!"
+ fi
+ else
+ fail "Cannot read \$PIDFILE: $PIDFILE"
+ fi
+ fi
+}
+
+_console() {
+ if [[ ! "$pid" ]]; then
+ trap '' INT QUIT
+ eval $COMMAND_LINE
+ [[ $? != 0 ]] && fail "Failed to launch the wrapper!"
+ else
+ echo "I2P Service is already running"
+ fi
+}
+
+_start() {
+ if [[ ! "$pid" ]]; then
+ echo -n "Starting I2P Service"
+ COMMAND_LINE+=" wrapper.daemonize=TRUE"
+ eval $COMMAND_LINE
+ [[ $? != 0 ]] && fail "Failed to launch the wrapper!"
+ i=0
+ while [[ ! "$pid" || $i < $TIMEOUT ]]; do
+ echo -n "."
+ sleep 1
+ check_if_running
+ ((i++))
+ done
+ [[ $(get_pid) ]] &&
+ echo " done (pid $pid)" || fail "timeout: Failed to start wrapper!"
+ else
+ echo "I2P Service is already running"
+ fi
+}
+
+_restart() {
+ [[ "$pid" ]] &&
+ kill -USR1 $(get_wrapper_pid) || echo "I2P Service is not running"
+}
+
+_stop() {
+ if [[ "$pid" ]]; then
+ echo -n "Stopping I2P Service"
+ kill -TERM "$pid"
+ [[ $? != 0 ]] && fail "Unable to stop I2P Service: kill -TERM $pid"
+ i=0
+ while [[ "$pid" || $i > $TIMEOUT ]]; do
+ echo -n "."
+ sleep 1
+ [[ ! $(get_pid) ]] && unset pid
+ ((i++))
+ done
+ if [[ "$pid" ]]; then
+ fail "timeout: Failed to stop wrapper! (pid: $pid)"
+ else
+ echo " done"
+ [[ "$1" = 'start' ]] && _start
+ fi
+ else
+ echo "I2P Service is not running."
+ fi
+}
+
+_graceful() {
+ if [[ "$pid" ]]; then
+ echo "Stopping I2P Service gracefully..."
+ kill -HUP "$pid"
+ [[ $? != 0 ]] && fail "Unable to stop I2P Service."
+ else
+ echo "I2P Service is not running."
+ fi
+}
+
+_status() {
+ [[ "$pid" ]] &&
+ echo "I2P Service is running: PID:$pid" || echo "I2P Service is not running."
+}
+
+_dump() {
+ if [[ "$pid" ]]; then
+ echo "Dumping threads..."
+ kill -QUIT "$pid"
+ [[ $? != 0 ]] &&
+ fail "Failed to dump threads" || echo "Thread Dump is available in wrapper.log"
+ else
+ echo "I2P Service is not running."
+ fi
+}
+#-----------------------------------------------------------------------------
+
+check_user "$@"
+init_vars
+check_if_running
+
+case "$1" in
+ 'console') _console
+ ;;
+ 'start') _start
+ ;;
+ 'stop') _stop
+ ;;
+ 'graceful') _graceful
+ ;;
+ 'restart') _restart
+ ;;
+ 'status') _status
+ ;;
+ 'dump') _dump
+ ;;
+
+ *) echo "Usage: $(basename $0) [command]"
+ echo
+ echo "Commands:"
+ echo " console Launch in the current console"
+ echo " start Start in the background as a daemon process"
+ echo " stop Stop if running as a daemon or in another console"
+ echo " graceful Stop gracefully, may take up to 11 minutes for all tunnels to close"
+ echo " restart Restart the JVM"
+ echo " status Query the current status"
+ echo " dump Request a Java thread dump if running"
+ echo
+ ;;
+esac
+exit 0
diff --git a/pcr/i2p/router.config b/pcr/i2p/router.config
new file mode 100644
index 000000000..7148ff0df
--- /dev/null
+++ b/pcr/i2p/router.config
@@ -0,0 +1,11 @@
+# NOTE: This I2P config file must use UTF-8 encoding
+# * i2cp: allows java clients to communicate with I2P outside of the JVM. Disabled.
+# * IPv6: Disabled
+# * In-I2P Network Updates: Disabled
+i2cp.disableInterface=true
+i2np.ntcp.ipv6=false
+i2np.udp.ipv6=false
+i2np.udp.addressSources=hidden
+router.updateDisabled=true
+routerconsole.advanced=true
+i2np.upnp.enable=false
diff --git a/pcr/i2p/wrapper.config b/pcr/i2p/wrapper.config
new file mode 100644
index 000000000..284f7eb6a
--- /dev/null
+++ b/pcr/i2p/wrapper.config
@@ -0,0 +1,162 @@
+#encoding=UTF-8
+#********************************************************************
+# Wrapper Properties
+#
+# WARNING - for any changes to take effect, you must completely
+# stop the router and the wrapper. Clicking 'Restart' on your
+# router console will NOT reread this file! You must
+# click "Shutdown", wait 11 minutes, then start i2p.
+#
+#********************************************************************
+# Java Application
+wrapper.java.command=/usr/lib/jvm/default/bin/java
+
+# Java Main class. This class must implement the WrapperListener interface
+# or guarantee that the WrapperManager class is initialized. Helper
+# classes are provided to do this for you. See the Integration section
+# of the documentation for details.
+wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
+
+# Java Classpath (include wrapper.jar) Add class path elements as
+# needed starting from 1
+# Be sure there are no other duplicate classes.
+wrapper.java.classpath.1=/opt/i2p/lib/*.jar
+wrapper.java.classpath.2=/usr/share/java/wrapper.jar
+
+# Java Library Path (location of libwrapper.so)
+wrapper.java.library.path.1=/opt/i2p
+wrapper.java.library.path.2=/opt/i2p/lib
+wrapper.java.library.path.3=/usr/lib/java-service-wrapper
+
+# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
+wrapper.java.additional.auto_bits=TRUE
+
+# Java Additional Parameters
+wrapper.java.additional.1=-DloggerFilenameOverride=logs/log-router-@.txt
+wrapper.java.additional.2=-Dorg.mortbay.http.Version.paranoid=true
+wrapper.java.additional.3=-Dorg.mortbay.xml.XmlParser.NotValidating=true
+wrapper.java.additional.4=-Di2p.dir.base="/opt/i2p"
+wrapper.java.additional.4.stripquotes=TRUE
+
+# On some IPv6 enabled systems, I2P and other network-enabled java applications
+# may fail to start. For examples see
+# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560044.
+# Two things that may help if you experience this issue
+# 1) "echo 0 > /proc/sys/net/ipv6/bindv6only" as root; or
+# 2) uncomment the next two lines:
+wrapper.java.additional.5=-Djava.net.preferIPv4Stack=true
+wrapper.java.additional.6=-Djava.net.preferIPv6Addresses=false
+
+# Initial Java Heap Size (in MB)
+# If a non-zero value is specified for this property then an appropriate -Xms
+# parameter will be added. The initial memory must be less than or equal to
+# the value set for the maxmemory property
+#wrapper.java.initmemory=4
+
+# Maximum Java Heap Size (in MB)
+# The JVM's default is 64MB, and I2P can work fine in that, but to handle
+# lots of I2PSnark activity in the same JVM, increasing the default max heap
+# size should help. Feel free to reduce this if not using I2PSnark in the jvm
+# High-bandwidth routers may need to increase to 256 or more.
+wrapper.java.maxmemory=128
+
+# Application parameters. Add parameters as needed starting from 1
+wrapper.app.parameter.1=net.i2p.router.Router
+
+#********************************************************************
+# Wrapper Logging Properties
+#********************************************************************
+# Enables Debug output from the Wrapper.
+# wrapper.debug=TRUE
+# Format of output for the console. (See docs for formats)
+wrapper.console.format=PM
+
+# Log Level for console output. (See docs for log levels)
+wrapper.console.loglevel=INFO
+
+# Log file to use for wrapper output logging.
+# You may wish to change this.
+wrapper.logfile=/opt/i2p/wrapper.log
+
+# Format of output for the log file.
+# The format consists of the tokens 'L' for log level, 'P' for prefix, 'D' for thread,
+# 'T' for time, 'Z' for millisecond time, and 'M' for message
+# Unfortunately the log timezone cannot be changed, see
+# http://www.nabble.com/Log-message-timezone-td23651317.html
+wrapper.logfile.format=TM
+
+# Log Level for log file output. (See docs for log levels)
+wrapper.logfile.loglevel=INFO
+
+# Maximum size that the log file will be allowed to grow to before
+# the log is rolled. Size is specified in bytes. The default value
+# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
+# 'm' (mb) suffix. For example: 10m = 10 megabytes.
+wrapper.logfile.maxsize=1m
+
+# Maximum number of rolled log files which will be allowed before old
+# files are deleted. The default value of 0 implies no limit.
+wrapper.logfile.maxfiles=2
+
+# Log Level for sys/event log output. (See docs for log levels)
+wrapper.syslog.loglevel=NONE
+
+# these will shut down or crash the JVM
+wrapper.signal.mode.usr1=RESTART
+wrapper.signal.mode.usr2=IGNORE
+
+# choose what to do if the JVM kills itself based on the exit code
+wrapper.on_exit.default=SHUTDOWN
+wrapper.on_exit.0=SHUTDOWN
+wrapper.on_exit.1=SHUTDOWN
+# OOM
+wrapper.on_exit.10=RESTART
+# graceful shutdown
+wrapper.on_exit.2=SHUTDOWN
+# hard shutdown
+wrapper.on_exit.3=SHUTDOWN
+# hard restart
+wrapper.on_exit.4=RESTART
+# hard restart
+wrapper.on_exit.5=RESTART
+
+# the router may take a few seconds to save state, etc
+wrapper.jvm_exit.timeout=60
+
+# give the OS 60s to clear all the old sockets / etc before restarting
+# Let's change the default from 60 to 10 seconds and see if anyone moans..
+wrapper.restart.delay=5
+
+wrapper.ping.interval=300
+# The ping timeout must be at least 5 seconds longer than the value of wrapper.ping.interval.
+# Extend this if you are getting 'JVM appears hung' shutdowns.
+wrapper.ping.timeout=320
+
+# use the wrapper's internal timer thread. otherwise this would
+# force a restart of the router during daylight savings time as well
+# as any time that the OS clock changes
+wrapper.use_system_time=false
+
+# pid file for the JVM
+# If you plan to have multiple wrappers running on the same machine,
+# you should copy this file, change the location or file name,
+# and edit the i2prouter script to change the WRAPPER_CONF setting
+# to point to the new wrapper.config location.
+# Directory must exist or the wrapper will fail to start.
+wrapper.java.pidfile=/run/i2p/i2p.pid
+
+#********************************************************************
+# Wrapper General Properties
+#********************************************************************
+# Allow for the use of non-contiguous numbered properties
+wrapper.ignore_sequence_gaps=TRUE
+
+# Title to use when running as a console
+wrapper.console.title=I2P Service
+
+# Set permissions used when creating files
+# See http://wrapper.tanukisoftware.com/doc/english/prop-umask.html
+# for a detailed explanation of these settings.
+wrapper.umask=0022
+wrapper.java.umask=0022
+wrapper.logfile.umask=077