diff options
author | skydrome | 2015-06-01 10:28:25 -0400 |
---|---|---|
committer | skydrome | 2015-06-01 10:28:25 -0400 |
commit | 112037423cec6d4e1988a0fe0d0c70d5f1a6be84 (patch) | |
tree | d6be428cbffe9b33780ca8ed287cd6fa45af05c0 | |
download | aur-112037423cec6d4e1988a0fe0d0c70d5f1a6be84.tar.gz |
Initial commit
-rw-r--r-- | .SRCINFO | 35 | ||||
-rwxr-xr-x | PKGBUILD | 120 | ||||
-rwxr-xr-x | i2p.install | 22 | ||||
-rwxr-xr-x | i2prouter.service | 20 | ||||
-rwxr-xr-x | i2prouter.sh | 192 | ||||
-rwxr-xr-x | router.config | 9 | ||||
-rwxr-xr-x | wrapper.config | 162 |
7 files changed, 560 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..b50a580cc1f1 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,35 @@ +pkgbase = i2p-dev + pkgdesc = A distributed anonymous network (daily mtn->git sync) + pkgver = 0.9.19.33 + pkgrel = 1 + epoch = 1 + url = https://geti2p.net + install = i2p.install + arch = x86_64 + arch = i686 + arch = armv6h + arch = armv7h + license = GPL2 + makedepends = apache-ant + makedepends = git + makedepends = java-environment>=7 + depends = java-runtime>=7 + depends = gmp + depends = java-service-wrapper + provides = i2p + conflicts = i2p + conflicts = i2p-bin + backup = opt/i2p/wrapper.config + source = git://github.com/i2p/i2p.i2p.git#commit=master + source = i2prouter.service + source = i2prouter.sh + source = wrapper.config + source = router.config + sha256sums = SKIP + sha256sums = 842b529ae23bc82fd78e986dd7cc683bd7b671e93421de57f279dc3f4d5d0fd2 + sha256sums = ea8f97e66461d591b1819eab39bbc40056b89ae12f7729b3dd9fd2ce088e5e53 + sha256sums = a76e7b6ccd8f49b51d22012887e1f0101db3bfe6aeebe1bc416b48da4e206b27 + sha256sums = c001f045e52ab82154b21125384dbc4f1d2437376fc65c5d83987051e42b5409 + +pkgname = i2p-dev + diff --git a/PKGBUILD b/PKGBUILD new file mode 100755 index 000000000000..d092ab15c1ec --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,120 @@ +# Maintainer: skydrome <skydrome@i2pmail.org> +# Contributor: skydrome <skydrome@i2pmail.org> + +########[ OPTIONS ]######################################## +# Comment out if you want to build all language translations +export LG2=en + +## Clone i2p through i2p +# Add and Start a new Standard client tunnel with the following settings: +# Name: pull.git.repo.i2p +# Port: 9450 or some other unused port +# Tunnel Destination: 3so7htzxzz6h46qvjm3fbd735zl3lrblerlj2xxybhobublcv67q.b32.i2p +# git://127.0.0.1:9450/i2p.i2p.git +########################################################### + +pkgname=i2p-dev +pkgver=0.9.19.33 +pkgrel=1 +epoch=1 +pkgdesc="A distributed anonymous network (daily mtn->git sync)" +url="https://geti2p.net" +license=('GPL2') +arch=('x86_64' 'i686' 'armv6h' 'armv7h') +depends=('java-runtime>=7' 'gmp' 'java-service-wrapper') +makedepends=('apache-ant' 'git' 'java-environment>=7') +[[ "$LG2" != 'en' ]] && makedepends+=('gettext') +#optdepends=('gtk2: for rrd graphs') +conflicts=('i2p' 'i2p-bin') +provides=('i2p') +backup=('opt/i2p/wrapper.config') +install='i2p.install' + +_gitname=i2p.i2p +_commit=master + +source=("git://github.com/i2p/${_gitname}.git#commit=${_commit}" + 'i2prouter.service' 'i2prouter.sh' 'wrapper.config' 'router.config') + +sha256sums=('SKIP' + '842b529ae23bc82fd78e986dd7cc683bd7b671e93421de57f279dc3f4d5d0fd2' + 'ea8f97e66461d591b1819eab39bbc40056b89ae12f7729b3dd9fd2ce088e5e53' + 'a76e7b6ccd8f49b51d22012887e1f0101db3bfe6aeebe1bc416b48da4e206b27' + 'c001f045e52ab82154b21125384dbc4f1d2437376fc65c5d83987051e42b5409') + +pkgver() { + cd "$srcdir/$_gitname" + echo "$(grep 'VERSION =' core/java/src/net/i2p/CoreVersion.java \ + |sed 's/.*= "//;s/";//').$(grep 'BUILD =' router/java/src/net/i2p/router/RouterVersion.java \ + |sed 's/.*= //;s/;//')" +} + +prepare() { + cd "$srcdir/$_gitname" + sed -i build.properties \ + -e 's:javac.version=.*:javac.version=1.7:' + sed -i {router/java/build.xml,core/java/build.xml} \ + -e 's:target="1.5":target="1.7":' +} + +build_jbigi() { + msg "Building libjbigi..." + cd "$srcdir/$_gitname/core/c/jbigi" + CFLAGS+=" -fPIC -Wall" + INCLUDES="-I./jbigi/include -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux" + LDFLAGS="-shared -Wl,-O1,--sort-common,-z,relro,-soname,libjbigi.so" + gcc -c $CFLAGS $INCLUDES jbigi/src/jbigi.c + gcc $LDFLAGS $INCLUDES -o libjbigi.so jbigi.o -lgmp + install -Dm644 libjbigi.so "$srcdir/$_gitname/pkg-temp/lib/libjbigi.so" +} + +build_jcpuid() { +if [[ "$CARCH" != @(arm)* ]]; then + msg "Building libjcpuid..." + cd "$srcdir/$_gitname/core/c/jcpuid" + INCLUDES="-I./include -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux" + LDFLAGS="-shared -Wl,-O1,--sort-common,-z,relro,-soname,libjcpuid-${CARCH}-linux.so" + gcc $CFLAGS $LDFLAGS $INCLUDES src/jcpuid.c -o libjcpuid-${CARCH}-linux.so + install -Dm644 libjcpuid-${CARCH}-linux.so "$srcdir/$_gitname/pkg-temp/lib/libjcpuid.so" +fi +} + +build() { + source /etc/profile.d/apache-ant.sh + source /etc/profile.d/jre.sh + + build_jbigi + build_jcpuid + + cd "$srcdir/$_gitname" + ant -Dworkspace.version=$(git rev-parse $_commit) preppkg-linux +} + +package() { + cd "$srcdir/$_gitname" + + install -dm755 "$pkgdir/usr/lib/tmpfiles.d" + install -dm755 "$pkgdir/usr/bin" + install -dm755 "$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,wrapper.config} \ + -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/i2p.install b/i2p.install new file mode 100755 index 000000000000..e375465ba0bb --- /dev/null +++ b/i2p.install @@ -0,0 +1,22 @@ +post_install() { + getent passwd i2p &>/dev/null || { + echo -n ">>> Creating i2p user... " + useradd --system --user-group --home /opt/i2p i2p + echo "done" + } + systemd-tmpfiles --create i2prouter.conf + chown -R i2p:i2p /opt/i2p +} + +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/i2prouter.service b/i2prouter.service new file mode 100755 index 000000000000..ce1da03bc441 --- /dev/null +++ b/i2prouter.service @@ -0,0 +1,20 @@ +[Unit] +Description=Invisible Internet Project +After=network.target +RequiresOverridable=tlsdate.service ntpd.service + +[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/i2prouter.sh b/i2prouter.sh new file mode 100755 index 000000000000..1af0a35b4cbb --- /dev/null +++ b/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/router.config b/router.config new file mode 100755 index 000000000000..cbce544071a7 --- /dev/null +++ b/router.config @@ -0,0 +1,9 @@ +# 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 +router.updateDisabled=true +routerconsole.advanced=true diff --git a/wrapper.config b/wrapper.config new file mode 100755 index 000000000000..4d54e65a668a --- /dev/null +++ b/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=10 + +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 |