summaryrefslogtreecommitdiff
path: root/pcr/freenet
diff options
context:
space:
mode:
authorGaming4JC <g4jc@openmailbox.org>2017-03-04 13:46:11 -0500
committerGaming4JC <g4jc@openmailbox.org>2017-03-04 13:46:11 -0500
commit20afded69cddea04245721129dd825368d560892 (patch)
treec728bf4ef2857b076e3f0ed5c7fc37d1b3f725cd /pcr/freenet
parent0252d3f29a493d834121df40f2e16298e20f949e (diff)
downloadabslibre-20afded69cddea04245721129dd825368d560892.tar.gz
abslibre-20afded69cddea04245721129dd825368d560892.tar.bz2
abslibre-20afded69cddea04245721129dd825368d560892.zip
add freenet to pcr
Diffstat (limited to 'pcr/freenet')
-rw-r--r--pcr/freenet/PKGBUILD306
-rw-r--r--pcr/freenet/contrib.properties9
-rw-r--r--pcr/freenet/fred.properties12
-rw-r--r--pcr/freenet/freenet.ini31
-rw-r--r--pcr/freenet/freenet.install41
-rw-r--r--pcr/freenet/freenet.service13
-rw-r--r--pcr/freenet/run.sh179
-rw-r--r--pcr/freenet/wrapper.config138
8 files changed, 729 insertions, 0 deletions
diff --git a/pcr/freenet/PKGBUILD b/pcr/freenet/PKGBUILD
new file mode 100644
index 000000000..01cf02715
--- /dev/null
+++ b/pcr/freenet/PKGBUILD
@@ -0,0 +1,306 @@
+# Maintainer: skydrome <skydrome at@at i2pmail do.t org>
+# Contributors:
+
+_fred=#tag=build01476
+_contrib=#tag=v50
+
+_wot=#tag=build0019
+#_wot=#branch=next
+
+_keyutils=#tag=v5026
+_upnp=#tag=10007
+
+pkgname=freenet
+pkgver=0.7.5.1476
+pkgrel=1
+_pkgver=0.7.5
+pkgdesc="An encrypted network without censorship"
+url="https://freenetproject.org"
+license=('GPL2')
+arch=('i686' 'x86_64')
+install='freenet.install'
+
+depends=('java-runtime>=7' 'gmp' 'java-service-wrapper')
+makedepends=('java-environment>=7' 'apache-ant' 'git')
+checkdepends=('junit')
+# comment out to run unit tests
+BUILDENV+=('!check')
+
+backup=('opt/freenet/wrapper.config'
+ 'opt/freenet/conf/freenet.ini')
+
+_plugins=('WebOfTrust' 'UPnP' 'KeyUtils')
+
+# these are packages we need to download to prevent ant from
+# downloading them itself we are also going to build as much
+# as we can from source, including this array
+_deps=("http://downloads.sourceforge.net/project/sevenzip/LZMA%20SDK/4.65/lzma465.tar.bz2"
+ "league-lzmajio-0.95-0-gd38bf5c.tar.gz::https://codeload.github.com/league/lzmajio/legacy.tar.gz/0.95"
+ "http://downloads.sourceforge.net/project/bitcollider/jBitcollider%20%28Java%29/0.8/jBitcollider-0.8.zip"
+ "https://www.spaceroots.org/software/mantissa/mantissa-7.2-src.zip"
+ "https://downloads.freenetproject.org/contrib/db4o-7.4-java.zip")
+
+# ant will extract these
+noextract=('lzma465.tar.bz2'
+ 'league-lzmajio-0.95-0-gd38bf5c.tar.gz'
+ 'jBitcollider-0.8.zip'
+ 'mantissa-7.2-src.zip'
+ 'db4o-7.4-java.zip'
+ 'commons-compress.jar'
+ 'bcprov-jdk15on-156.jar')
+
+# here we have only java-commons-compress coming prebuilt by
+# the freenetproject, the rest we build ourselves
+source=("git+https://github.com/freenet/fred.git${_fred}"
+ "git+https://github.com/freenet/contrib.git${_contrib}"
+ "git+https://github.com/freenet/plugin-UPnP.git${_upnp}"
+ "git+https://github.com/freenet/plugin-KeyUtils.git${_keyutils}"
+ "git+https://github.com/freenet/plugin-WebOfTrust.git${_wot}"
+ "https://downloads.freenetproject.org/alpha/opennet/seednodes.fref"
+ "IpToCountry.dat::http://software77.net/geo-ip/?DL=4"
+ "https://downloads.freenetproject.org/contrib/jar/latest/commons-compress.jar"
+ "https://www.bouncycastle.org/download/bcprov-jdk15on-156.jar"
+ "http://downloads.sourceforge.net/project/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.tar.bz2"
+ "https://raw.githubusercontent.com/i2p/i2p.i2p/master/core/c/jcpuid/src/jcpuid.c"
+ "https://raw.githubusercontent.com/i2p/i2p.i2p/master/core/c/jcpuid/include/jcpuid.h"
+ 'fred.properties' 'contrib.properties' 'run.sh'
+ 'freenet.service' 'freenet.ini' 'wrapper.config'
+ "${_deps[@]}")
+
+sha256sums=('SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ '16924be3c8f1322b659f3ff08060a43f45f2e8de6f95af28d86fe9876e79008d'
+ '963e1ee14f808ffb99897d848ddcdb28fa91ddda867eb18d303e82728f878349'
+ '96effcca2581c1ab42a4828c770b48d54852edf9e71cefc9ed2ffd6590571ad1'
+ '1966a96a0733cb19b8172f03b3582141fea8f82abcc4b79800ba0a92a5c1122d'
+ '9ec758801a9864ae10caf851ee60ed22c3ef44428e77689c203d9b890921a6d2'
+ '236adfd42be0a7a74f2dec1356e517442b2ddcbb5d44cb0dab3671b6fddfca79'
+ '865c1f259d9c544861cc12b4ea64ad35ec6388c1392b3e5247eaed0f316e42b7'
+ '9912dcfc8f30143b68e6f9c51505ae921100eb6b24690a8680582bb23559d95a'
+ '434f67e2e86edb555b7dfb572a52d7ff719373989e1f1830f779bfccc678539f'
+ 'c0ce093a098d91dee6be294f8a2fc929aabad95612f994933194d0da5c4cdd25'
+ 'f7bceda39b36d1d79e70c8ba8e0e68d4cfe060b16e67d8341078af5fda13b405'
+ 'c935fd04dd8e0e8c688a3078f3675d699679a90be81c12686837e0880aa0fa1e'
+ '265f7ed2dd4fecb058884d3f8974674b06e0be46131c3b2bc6a310373937d2ef'
+ 'b36482ee9e919c669bb1797ff7e50f57edf505af67664e280fe1dff361861044'
+ 'e438135d69139ed4fa44400f416ea73935d16afe50dfe490b7bba0602ee89476'
+ '73f307a8cbd114fdc0af8daa067994a2cdc364c4053e6734d16b8dd1d5a0469f')
+
+
+if [[ "$CARCH" = 'i686' ]]; then
+ _arch=x86
+ __arch=i386
+else
+ _arch=x86_64
+ __arch=amd64
+fi
+
+pkgver() {
+ cd "$srcdir/fred"
+ echo "${_pkgver}.$(git describe |sed 's/build0//;s/-/./g')"
+}
+
+prepare() {
+ cd "$srcdir/fred"
+
+ rm -rf contrib
+ ln -sf ../contrib contrib
+ mkdir -p contrib/freenet-ext/{dist,lib}
+
+ # no need to fetch this file every time freenet starts as its only updated
+ # monthly, if it even changes at all
+ sed -i src/freenet/node/updater/NodeUpdateManager.java \
+ -e "s:updateIPToCountry =.*:updateIPToCountry = false;:"
+
+ # had a hard time building these sources, we'll use the prebuilt jars
+ cp "$srcdir/commons-compress.jar" contrib/freenet-ext/dist
+
+ # this is done to satisfy ant
+ ln -sf /usr/share/java/wrapper.jar contrib/freenet-ext/dist/
+ ln -sf /usr/share/java/{hamcrest-core,junit}.jar lib/
+ ln -sf "$srcdir"/ant-contrib/{ant-contrib-1.0b3,ant-contrib}.jar
+ cp "$srcdir"/bcprov-jdk15on-156.jar lib/bcprov.jar
+ cp "$srcdir"/{lzma465.tar.bz2,league-lzmajio-0.95-0-gd38bf5c.tar.gz,jBitcollider-0.8.zip,mantissa-7.2-src.zip,db4o-7.4-java.zip} contrib/freenet-ext/lib
+
+ # we're going to compile our own C libraries
+ cd "$srcdir/contrib"
+ rm -rf NativeBigInteger/lib/net/i2p/util/*
+ rm -rf NativeThread/lib/freenet/support/io/*.so
+ rm -rf onion-fec/bin/lib/{freebsd,linux,win32}-*
+
+ # these are from the I2P project
+ cd "$srcdir/contrib/jcpuid"
+ rm -rf lib/freenet/support/CPUInformation/* include/jcpuid.h
+ ln -sf "$srcdir"/jcpuid.h include/
+ ln -sf "$srcdir"/jcpuid.c src/
+}
+
+build() {
+ source /etc/profile.d/apache-ant.sh
+ source /etc/profile.d/jre.sh
+ export JAVA_HOME="${JAVA_HOME:-/usr/lib/jvm/default}"
+
+ build_jbigi
+ build_nativethread
+ build_jcpuid
+ build_fec
+
+ msg "Building Contrib Modules..."
+ cd "$srcdir/fred/contrib/freenet-ext"
+ ant -propertyfile "$srcdir/contrib.properties" \
+ -Djava.class.dirs.user="$srcdir/ant-contrib"
+
+ # ant doesnt seem to put all the required folders into the
+ # freenet-ext.jar correctly, make sure to do it here
+ cd dist
+ for dep in bitcollider-core commons-compress db4o lzmajio mantissa wrapper
+ do
+ jar xf "${dep}.jar"
+ done
+ jar uf freenet-ext.jar com net org SevenZip
+
+ msg "Building Freenet..."
+ cd "$srcdir/fred"
+ ant package-only -propertyfile "$srcdir/fred.properties" \
+ -f build-clean.xml -Ddoc.skip=true
+
+ build_plugins
+}
+
+build_jbigi() {
+ msg "Building NativeBigInt..."
+ cd "$srcdir/contrib/NativeBigInteger"
+
+ _objdir='lib/net/i2p/util'
+ 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 -lgmp"
+ rm -f *.o *.so
+
+ set -x
+ gcc -c $CFLAGS $INCLUDES jbigi/src/jbigi.c
+ gcc $LDFLAGS jbigi.o -o "$_objdir"/libjbigi-linux-none.so
+ set +x
+}
+
+build_nativethread() {
+ msg "Building NativeThread..."
+ cd "$srcdir/contrib/NativeThread"
+
+ _objdir='lib/freenet/support/io'
+ INCLUDES="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"
+ LDFLAGS="-shared -Wl,-O1,--sort-common,-z,relro,-soname,llibnative.so -lc"
+ rm -f *.o *.so NativeThread.h
+
+ set -x
+ javah -o NativeThread.h -classpath ../../fred/src freenet.support.io.NativeThread
+ gcc -c $CFLAGS $INCLUDES NativeThread.c
+ gcc $LDFLAGS NativeThread.o -o "$_objdir"/libNativeThread-${__arch}.so
+ set +x
+}
+
+build_jcpuid() {
+ msg "Building NativeCPUID..."
+ cd "$srcdir/contrib/jcpuid"
+
+ _objdir='lib/freenet/support/CPUInformation'
+ INCLUDES="-I./include -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"
+ LDFLAGS="-shared -Wl,-O1,--sort-common,-z,relro,-soname,libjcpuid-x86-linux.so"
+ rm -f *.o *.so
+
+ set -x
+ gcc -c $CFLAGS $INCLUDES src/jcpuid.c
+ gcc $LDFLAGS jcpuid.o -o "$_objdir"/libjcpuid-${_arch}-linux.so
+ set +x
+}
+
+build_fec() {
+ msg "Building onion-fec..."
+ cd "$srcdir/contrib/onion-fec/src/csrc"
+
+ _objdir='../../bin/lib/linux-${_arch}'
+ LDFLAGS="-shared -Wl,-O1,--sort-common,-z,relro"
+ INCLUDES="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"
+ _CLASSPATH="-classpath ../ com.onionnetworks.fec"
+
+ mkdir -p "$_objdir"
+ rm -f *.o *.so *.S com_*.h
+
+ set -x
+ javah -o com_onionnetworks_fec_Native8Code.h ${_CLASSPATH}.Native8Code
+ javah -o com_onionnetworks_fec_Native16Code.h ${_CLASSPATH}.Native16Code
+ gcc -S $CFLAGS fec.c -DGF_BITS=8 -o fec8.S
+ gcc -S $CFLAGS fec.c -DGF_BITS=16 -o fec16.S
+ gcc -c $CFLAGS $INCLUDES fec-jinterf.c -DGF_BITS=8 -o fec8-jinterf.o
+ gcc -c $CFLAGS $INCLUDES fec-jinterf.c -DGF_BITS=16 -o fec16-jinterf.o
+ gcc -c $CFLAGS fec8.S -DGF_BITS=8 -o fec8.o
+ gcc -c $CFLAGS fec16.S -DGF_BITS=16 -o fec16.o
+ gcc $LDFLAGS fec8.o fec8-jinterf.o -o "$_objdir"/libfec8.so
+ gcc $LDFLAGS fec16.o fec16-jinterf.o -o "$_objdir"/libfec16.so
+ set +x
+}
+
+build_plugins() {
+ for plugin in ${_plugins[@]}; do
+ msg "Building Plugin ${plugin}..."
+ cd "$srcdir/plugin-${plugin}"
+ ant dist \
+ -Dfreenet-cvs-snapshot.location=../fred/dist/freenet.jar \
+ -Dfreenet-ext.location=../contrib/freenet-ext/dist/freenet-ext.jar \
+ -Djunit.location=/usr/share/java/junit.jar \
+ -Dtest.skip=true
+ done
+}
+
+check() {
+ cd "$srcdir/fred"
+
+ # these tests use alot of memory and can cause OOM's
+ rm -f test/freenet/client/async/{*Storage,ClientRequestSelector}Test.java
+
+ ant unit -propertyfile "$srcdir/fred.properties" \
+ -f build-clean.xml
+}
+
+package() {
+ cd "$srcdir/fred"
+
+ # freenet
+ install -dm755 "$pkgdir"/usr/bin
+ install -dm700 "$pkgdir"/run/freenet
+ install -dm750 "$pkgdir"/opt/freenet/{downloads,lib,conf,noderef,persistent-temp,tmp,plugins/data,user/{data,certs}}
+
+ install -m640 "$srcdir"/{wrapper.config,run.sh,IpToCountry.dat} \
+ "$pkgdir"/opt/freenet
+ install -m640 "$srcdir"/freenet.ini "$pkgdir"/opt/freenet/conf
+ install -m640 contrib/freenet-ext/dist/freenet-ext.jar \
+ dist/freenet.jar \
+ lib/bcprov.jar "$pkgdir"/opt/freenet/lib
+ install -m640 "$srcdir"/seednodes.fref "$pkgdir"/opt/freenet/noderef
+
+ # plugins
+ for plugin in ${_plugins[@]}; do
+ install -m640 "$srcdir"/plugin-${plugin}/dist/${plugin}.jar "$pkgdir"/opt/freenet/plugins
+ done
+
+ echo "pluginmanager.loadplugin=$(echo ${_plugins[@]}|sed 's| |;|g')" \
+ >>"$pkgdir"/opt/freenet/conf/freenet.ini
+
+ # launcher
+ chmod +x "$pkgdir"/opt/freenet/run.sh
+ ln -s /opt/freenet/run.sh "$pkgdir"/usr/bin/freenet
+
+ # systemd
+ install -dm755 "$pkgdir"/usr/lib/tmpfiles.d
+ install -Dm644 "$srcdir"/freenet.service "$pkgdir"/usr/lib/systemd/system/freenet.service
+ echo 'd /run/freenet 0700 freenet freenet' >"$pkgdir"/usr/lib/tmpfiles.d/freenet.conf
+
+ # license
+ install -dm755 "$pkgdir"/usr/share/licenses/freenet
+ install -m644 LICENSE "$pkgdir"/usr/share/licenses/freenet/LICENSE
+}
diff --git a/pcr/freenet/contrib.properties b/pcr/freenet/contrib.properties
new file mode 100644
index 000000000..ad91486ae
--- /dev/null
+++ b/pcr/freenet/contrib.properties
@@ -0,0 +1,9 @@
+javac.target.version = 1.7
+extlib.use-mirrors = local
+
+extlib.commons-compress.suppress = true
+extlib.wrapper.suppress = true
+extlib.db4o.suppress = false
+extlib.lzma.suppress = false
+extlib.lzmajio.suppress = false
+extlib.mantissa.suppress = false
diff --git a/pcr/freenet/fred.properties b/pcr/freenet/fred.properties
new file mode 100644
index 000000000..635f6a7ff
--- /dev/null
+++ b/pcr/freenet/fred.properties
@@ -0,0 +1,12 @@
+javac.target.version = 1.7
+
+lib.dir = lib
+lib.contrib.dir = contrib/freenet-ext/dist
+
+libtest.jars = junit.jar hamcrest-core.jar
+bc.jar = bcprov.jar
+
+pmd.skip = true
+cpd.skip = true
+doc.skip = true
+findbugs.skip = true
diff --git a/pcr/freenet/freenet.ini b/pcr/freenet/freenet.ini
new file mode 100644
index 000000000..00a380d0e
--- /dev/null
+++ b/pcr/freenet/freenet.ini
@@ -0,0 +1,31 @@
+node.install.runDir=/opt/freenet
+node.install.cfgDir=/opt/freenet/conf
+node.install.nodeDir=/opt/freenet/noderef
+node.install.persistentTempDir=/opt/freenet/persistent-temp
+node.install.pluginDir=/opt/freenet/plugins
+node.install.pluginStoresDir=/opt/freenet/plugins/data
+node.install.userDir=/opt/freenet/user
+node.masterKeyFile=/opt/freenet/user/master.keys
+node.install.storeDir=/opt/freenet/user/data
+node.clientThrottleFile=/opt/freenet/user/data/client-throttle.dat
+node.load.nodeThrottleFile=/opt/freenet/user/data/node-throttle.dat
+ssl.sslKeyStore=/opt/freenet/user/certs
+node.downloadsDir=/opt/freenet/downloads
+node.install.tempDir=/opt/freenet/tmp
+node.uploadAllowedDirs=all
+node.downloadAllowedDirs=all
+node.updater.enabled=false
+node.updater.updateSeednodes=true
+node.updater.autoupdate=false
+node.updater.updateInstallers=false
+node.skipWrapperWarning=true
+node.l10n=English
+logger.dirname=/opt/freenet/logs
+logger.priority=ERROR
+fproxy.enabled=true
+fproxy.advancedModeEnabled=true
+fproxy.port=8888
+fcp.enabled=true
+fcp.port=9481
+security-levels.physicalThreatLevel=LOW
+security-levels.networkThreatLevel=NORMAL
diff --git a/pcr/freenet/freenet.install b/pcr/freenet/freenet.install
new file mode 100644
index 000000000..be2f4903d
--- /dev/null
+++ b/pcr/freenet/freenet.install
@@ -0,0 +1,41 @@
+post_install() {
+ getent passwd freenet &>/dev/null || {
+ echo -n ">>> Creating freenet system user... "
+ useradd --system \
+ --user-group \
+ --home /opt/freenet \
+ freenet &&
+ echo "ok" || echo "fail"
+ }
+ chown -R freenet:freenet /opt/freenet /run/freenet
+ echo
+ echo "Freenet will be slow at first startup while it discovers the network."
+ echo "You may see Data Not Found or Route Not Found errors, this is normal."
+ echo "For best performance Freenet should be run 24/7 as much as possible."
+ echo "Your node's configuration WebUI will be located at http://127.0.0.1:8888/ "
+ echo " https://freenetproject.org/faq.html"
+ echo
+}
+
+post_upgrade() {
+ chown -R freenet:freenet /opt/freenet /run/freenet
+
+ ## remove me at a later date
+ [[ -d /opt/freenet/conf/node ]] && {
+ sed -i /opt/freenet/conf/freenet.ini \
+ -e "s:node.install.nodeDir=/opt/freenet/conf/node:node.install.nodeDir=/opt/freenet/noderef:" \
+ -e "s:JSTUN;::"
+ mv /opt/freenet/conf/node /opt/freenet/noderef
+ }
+
+ echo
+}
+
+pre_remove() {
+ getent passwd freenet &>/dev/null && {
+ echo -n ">>> Removing freenet system user... "
+ userdel freenet
+ echo "ok"
+ echo
+ }
+}
diff --git a/pcr/freenet/freenet.service b/pcr/freenet/freenet.service
new file mode 100644
index 000000000..23db0fb1d
--- /dev/null
+++ b/pcr/freenet/freenet.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=An encrypted network without censorship and monitoring.
+After=network.target
+
+[Service]
+Type=forking
+User=freenet
+ExecStart=/opt/freenet/run.sh start --quiet
+ExecStop=/opt/freenet/run.sh stop --quiet
+WorkingDirectory=/opt/freenet
+
+[Install]
+WantedBy=multi-user.target
diff --git a/pcr/freenet/run.sh b/pcr/freenet/run.sh
new file mode 100644
index 000000000..2482222fa
--- /dev/null
+++ b/pcr/freenet/run.sh
@@ -0,0 +1,179 @@
+#!/usr/bin/env bash
+
+#-----------------------------------------------------------------------------
+_USER="freenet"
+WRAPPER_CMD="/usr/bin/java-service-wrapper"
+WRAPPER_CONF="/opt/freenet/wrapper.config"
+PIDDIR="/run/freenet"
+PIDFILE="$PIDDIR/freenet.pid"
+TIMEOUT=60
+#-----------------------------------------------------------------------------
+
+fail() {
+ printf "\e[1;31m>>> ERROR:\033[0m %s\n" "$*"
+ exit 1
+}
+
+check_user() {
+ if [[ "$(id -un)" != "$_USER" ]]; then
+ if [[ ! -d "$PIDDIR" ]]; then
+ install -dm700 "$PIDDIR"
+ chown ${_USER}:${_USER} "$PIDDIR"
+ fi
+ SCRIPT_PATH="$(cd $(dirname $0) && pwd)/$(basename $0)"
+ su - "$_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 ^_USER $0) && "$EUID" = "0" ]] &&
+ fail "Attempting to start as root! Please edit $(basename $0) and set the variable \$_USER"
+ [[ "$(id -un "$_USER")" != "$_USER" ]] &&
+ fail "\$_USER does not exist: $_USER"
+ COMMAND_LINE="\"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"freenet\" wrapper.name=\"freenet\""
+}
+
+get_wrapper_pid() {
+ pgrep -u "$_USER" -f 'wrapper.name=freenet'
+}
+get_pid() {
+ pgrep -u "$_USER" -f 'jar'
+}
+
+check_if_running() {
+ unset pid
+ if [[ -f "$PIDFILE" ]]; then
+ if [[ -r "$PIDFILE" ]]; then
+ pid=$(cat "$PIDFILE")
+ 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 "Freenet is already running"
+ fi
+}
+
+_start() {
+ if [[ ! "$pid" ]]; then
+ echo -n "Starting Freenet"
+ COMMAND_LINE+=" wrapper.daemonize=TRUE"
+ eval $COMMAND_LINE
+ [[ $? != 0 ]] && fail "Failed to launch the wrapper!"
+ i=0
+ if [[ ! $_quiet ]]; then
+ while [[ ! "$pid" || $i < $TIMEOUT ]]; do
+ echo -n "."
+ sleep 1
+ check_if_running
+ ((i++))
+ done
+ fi
+ [[ $(get_pid) ]] &&
+ echo " done" || fail "timeout: Failed to start wrapper!"
+ else
+ echo "Freenet is already running"
+ fi
+}
+
+_restart() {
+ [[ "$pid" ]] &&
+ kill -USR1 $(get_wrapper_pid) || echo "Freenet is not running"
+}
+
+_stop() {
+ if [[ "$pid" ]]; then
+ echo -n "Stopping Freenet"
+ kill -TERM $(get_wrapper_pid)
+ [[ $? != 0 ]] && fail "Unable to stop Freenet: kill -TERM $pid"
+ i=0
+ if [[ ! $_quiet ]]; then
+ while [[ "$pid" || $i > $TIMEOUT ]]; do
+ echo -n "."
+ sleep 1
+ [[ ! $(get_pid) ]] && unset pid
+ ((i++))
+ done
+ if [[ "$pid" ]]; then
+ fail "timeout: Failed to stop wrapper!"
+ fi
+ fi
+ echo " done"
+ else
+ echo "Freenet is not running."
+ fi
+}
+
+_status() {
+ [[ "$pid" ]] &&
+ echo "Freenet is running: PID:$pid" || echo "Freenet is not running."
+}
+
+_dump() {
+ if [[ "$pid" ]]; then
+ echo "Dumping threads..."
+ kill -QUIT $pid
+ [[ $? != 0 ]] &&
+ fail "Failed to dump Freenet Service" || echo "Dumped Freenet Service."
+ else
+ echo "Freenet is not running."
+ fi
+}
+#-----------------------------------------------------------------------------
+
+check_user "$*"
+init_vars
+check_if_running
+
+[[ "$2" = '--quiet' ]] &&
+ _quiet=true
+
+case "$1" in
+ 'console') _console
+ ;;
+ 'start') _start
+ ;;
+ 'stop') _stop
+ ;;
+ '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 " 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/freenet/wrapper.config b/pcr/freenet/wrapper.config
new file mode 100644
index 000000000..3960c613f
--- /dev/null
+++ b/pcr/freenet/wrapper.config
@@ -0,0 +1,138 @@
+#encoding=UTF-8
+
+# 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=freenet.node.NodeStarter
+
+# 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/freenet/lib/*.jar
+wrapper.java.classpath.2=/usr/share/java/*.jar
+
+# Java Library Path (location of libwrapper.so)
+wrapper.java.library.path.1=/opt/freenet/lib
+wrapper.java.library.path.2=/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
+
+wrapper.java.additional.1=-Dnetworkaddress.cache.ttl=0
+wrapper.java.additional.2=-Dnetworkaddress.cache.negative.ttl=0
+# Needed for some linux distros? Shouldn't prevent using IPv6, just make it prefer IPv4?
+wrapper.java.additional.3=-Djava.net.preferIPv4Stack=true
+# You could enable this for debugging, but Freenet will use more CPU if you do.
+#wrapper.java.additional.4=-enableassertions:freenet
+# You might want to set the following line if you have changed java.maxmemory
+# wrapper.java.additional.5=-XX:MaxPermSize=
+
+# 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=32
+
+# Maximum Java Heap Size (in MB)
+wrapper.java.maxmemory=256
+
+# Application parameters. Add parameters as needed starting from 1
+wrapper.app.parameter.1=/opt/freenet/conf/freenet.ini
+
+#********************************************************************
+# 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/freenet/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=LPTM
+
+# 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=2M
+
+# 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=3
+
+# 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=120
+
+wrapper.restart.reload_configuration=TRUE
+wrapper.filter.trigger.1=java.lang.OutOfMemoryError
+wrapper.filter.action.1=RESTART
+
+# 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
+
+# pid file for the JVM
+# Directory must exist or the wrapper will fail to start.
+wrapper.java.pidfile=/run/freenet/freenet.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=Freenet 0.7
+
+# 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