summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorskydrome2019-11-29 01:24:09 -0500
committerskydrome2019-11-29 01:24:09 -0500
commit368f064a356885cfc3e3710f0a8eefb55f6dee7a (patch)
tree18244bfd3820f5533627ad19447f44a98787fa90
parent6116d62aef9e7962536186e6c6e5b2bec8776b9c (diff)
downloadaur-368f064a356885cfc3e3710f0a8eefb55f6dee7a.tar.gz
merge with i2p package
-rw-r--r--.SRCINFO12
-rwxr-xr-xPKGBUILD39
-rwxr-xr-xi2p.install21
-rw-r--r--i2p.tmpfiles4
-rw-r--r--i2prouter.bash12
-rwxr-xr-xi2prouter.service28
-rwxr-xr-xi2prouter.sh84
-rwxr-xr-xrouter.config1
8 files changed, 114 insertions, 87 deletions
diff --git a/.SRCINFO b/.SRCINFO
index fbf8cf5c4fe2..07ebef2f1da8 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -22,14 +22,18 @@ pkgbase = i2p-dev
backup = opt/i2p/wrapper.config
source = git+https://github.com/i2p/i2p.i2p.git#commit=master
source = i2prouter.service
- source = i2prouter.sh
+ source = i2p.tmpfiles
source = wrapper.config
source = router.config
+ source = i2prouter.bash
+ source = i2prouter.sh
sha256sums = SKIP
- sha256sums = ff9942ca43715b5095b0118e306c8aec1af7c68c18e8959dba10d86eac8efbfd
- sha256sums = ea8f97e66461d591b1819eab39bbc40056b89ae12f7729b3dd9fd2ce088e5e53
+ sha256sums = 644b771ec7f5db3efab3206bf1f896566cdb00d410a54608fda85bdb4c2ad876
+ sha256sums = df26da04c8415ac24ec73b0dd08d3459a8964553bb77e5da5ab9833b0a31d865
sha256sums = 5c57456bf3f364175d036dfc6c6ceea5e57cdda970407829c04d09a4c821a9c0
- sha256sums = 41756375ef2e8323147cec31a8675b2bc11109451f9185c036ff32d26d6c9b99
+ sha256sums = 4ee28e022dccaf99043aa2735f05b7270b8eccf040c67f7ef48e114b5ca6e971
+ sha256sums = 7a19b9f90c8792460fd58e8b8aa435a065e34d29a942479850472510e9d3078a
+ sha256sums = b5f1a5bb354552acebe2857b9579410f7fd589f2f7d6b12fbbfe4127a2d33fd8
pkgname = i2p-dev
diff --git a/PKGBUILD b/PKGBUILD
index 15ef883acc4e..dc88805cdad4 100755
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -23,14 +23,18 @@ options=(!strip)
_gitname=i2p.i2p
_commit=master
+#mirror: https://gitlab.com/I2P/i2p.i2p.git
source=("git+https://github.com/i2p/${_gitname}.git#commit=${_commit}"
- 'i2prouter.service' 'i2prouter.sh' 'wrapper.config' 'router.config')
+ 'i2prouter.service' 'i2p.tmpfiles' 'wrapper.config' 'router.config'
+ 'i2prouter.bash' 'i2prouter.sh')
sha256sums=('SKIP'
- 'ff9942ca43715b5095b0118e306c8aec1af7c68c18e8959dba10d86eac8efbfd'
- 'ea8f97e66461d591b1819eab39bbc40056b89ae12f7729b3dd9fd2ce088e5e53'
+ '644b771ec7f5db3efab3206bf1f896566cdb00d410a54608fda85bdb4c2ad876'
+ 'df26da04c8415ac24ec73b0dd08d3459a8964553bb77e5da5ab9833b0a31d865'
'5c57456bf3f364175d036dfc6c6ceea5e57cdda970407829c04d09a4c821a9c0'
- '41756375ef2e8323147cec31a8675b2bc11109451f9185c036ff32d26d6c9b99')
+ '4ee28e022dccaf99043aa2735f05b7270b8eccf040c67f7ef48e114b5ca6e971'
+ '7a19b9f90c8792460fd58e8b8aa435a065e34d29a942479850472510e9d3078a'
+ 'b5f1a5bb354552acebe2857b9579410f7fd589f2f7d6b12fbbfe4127a2d33fd8')
pkgver() {
cd "$_gitname"
@@ -63,6 +67,7 @@ fi
build() {
export JAVA_HOME="${JAVA_HOME:-/usr/lib/jvm/default}"
+
build_jbigi
build_jcpuid
@@ -80,34 +85,38 @@ package() {
cd "$pkgdir"
install -dm755 "usr/bin"
- install -dm755 "opt/i2p/.tmp"
+ install -dm755 "opt/i2p"
cp -r "$srcdir/$_gitname"/pkg-temp/* "opt/i2p"
+ install -Dm644 "$srcdir/i2prouter.service" "usr/lib/systemd/system/i2prouter.service"
+ install -Dm644 "$srcdir/i2p.tmpfiles" "usr/lib/tmpfiles.d/i2p.conf"
+ echo 'u i2p - "I2P Router" /opt/i2p /bin/sh' |
+ install -Dm644 /dev/stdin "usr/lib/sysusers.d/i2p.conf"
+
install -Dm644 "$srcdir/router.config" "opt/i2p/router.config"
install -Dm644 "$srcdir/wrapper.config" "opt/i2p/wrapper.config"
install -Dm755 "$srcdir/i2prouter.sh" "opt/i2p/i2prouter"
- install -Dm644 "$srcdir/i2prouter.service" "usr/lib/systemd/system/i2prouter.service"
+
+ install -Dm644 "$srcdir/i2prouter.bash" "usr/share/bash-completion/completions/i2prouter"
+ install -Dm644 "$srcdir/$_gitname/installer/resources/bash-completion/eepget" \
+ "usr/share/bash-completion/completions/eepget"
+
install -Dm644 "opt/i2p/man/eepget.1" "usr/share/man/man1/eepget.1"
install -Dm644 "opt/i2p/LICENSE.txt" "usr/share/licenses/i2p/LICENSE"
mv opt/i2p/licenses/* "usr/share/licenses/i2p/"
ln -s /opt/i2p/{eepget,i2prouter} "usr/bin/"
chmod +x opt/i2p/{eepget,i2prouter}
-
- chmod -x opt/i2p/*.config
- chmod 755 opt/i2p
- chown -R 985:985 opt/i2p
-
- echo 'u i2p 985 "I2P Router" /opt/i2p /bin/sh' |
- install -Dm644 /dev/stdin "usr/lib/sysusers.d/i2p.conf"
- echo 'd /run/i2p 0700 i2p i2p' |
- install -Dm644 /dev/stdin "usr/lib/tmpfiles.d/i2p.conf"
+ chmod -x opt/i2p/*.config
sed -i opt/i2p/{eepget,wrapper.config} \
-e 's:%INSTALL_PATH:/opt/i2p:g'
+
+ # dont automatically start the webserver (3) or open a webbrowser (4)
sed -i opt/i2p/clients.config \
-e "s:clientApp.3.startOnLoad=.*:clientApp.3.startOnLoad=false:" \
-e "s:clientApp.4.startOnLoad=.*:clientApp.4.startOnLoad=false:"
+
rm -r opt/i2p/{osid,postinstall.sh,runplain.sh,INSTALL-headless.txt,LICENSE.txt,licenses,man,lib/wrapper}
}
diff --git a/i2p.install b/i2p.install
index 68c5726b257f..8bf945fbf96a 100755
--- a/i2p.install
+++ b/i2p.install
@@ -1,24 +1,9 @@
post_install() {
- echo "==> "
- echo "==> I2P Router settings can be adjusted at"
+ echo "==> I2P Router webui can be accessed at"
echo "==> http://127.0.0.1:7657/config.jsp"
- echo "==> "
-}
-
-## arg 1: the new package version
-## arg 2: the old package version
-post_upgrade() {
- if (( $(vercmp $2 0.9.39) < 0 )); then
- [[ $(id -g i2p) = '985' ]] || {
- echo -n ">>> Updating i2p user..."
- groupmod --gid 985 i2p
- usermod --uid 985 -s /bin/sh i2p
- chown -R 985:985 /opt/i2p
- echo " done"
- }
- fi
}
post_remove() {
- rm -f /opt/i2p/lib*.so*
+ rm -rf /opt/i2p/{lib*.so*,.tmp,.cache}
+ echo "==> Router configuration is saved in /opt/i2p/.i2p"
}
diff --git a/i2p.tmpfiles b/i2p.tmpfiles
new file mode 100644
index 000000000000..15085d2b2d37
--- /dev/null
+++ b/i2p.tmpfiles
@@ -0,0 +1,4 @@
+d /run/i2p 0700 i2p i2p
+d /opt/i2p 0755 i2p i2p
+d /opt/i2p/.i2p 0700 i2p i2p
+d /opt/i2p/.tmp 0700 i2p i2p
diff --git a/i2prouter.bash b/i2prouter.bash
new file mode 100644
index 000000000000..d95158603133
--- /dev/null
+++ b/i2prouter.bash
@@ -0,0 +1,12 @@
+_i2prouter()
+{
+ local cur prev opts
+ _init_completion || return
+
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ opts="console start stop graceful restart dump"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+}
+complete -F _i2prouter i2prouter
diff --git a/i2prouter.service b/i2prouter.service
index 724008b724be..5a80c870e9fc 100755
--- a/i2prouter.service
+++ b/i2prouter.service
@@ -1,18 +1,32 @@
+# It's not recommended to modify this file because it will be
+# overwritten during package upgrades. If you want to make changes, the
+# best way is to create a file "/etc/systemd/system/i2prouter.service.d/foo.conf"
+# and make your changes there. This file will be parsed after the file
+# i2p.service itself is parsed.
+
[Unit]
Description=Invisible Internet Project
-After=network.target
+After=network.target time-sync.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
+
+NoNewPrivileges=yes
+PrivateTmp=yes
+PrivateDevices=yes
+DeviceAllow=/dev/null rw
+DeviceAllow=/dev/urandom r
+LimitNOFILE=4096
+
+ExecStart=/usr/bin/java-service-wrapper /opt/i2p/wrapper.config \
+ wrapper.name=i2prouter \
+ wrapper.syslog.ident=i2prouter \
+ wrapper.daemonize=TRUE TZ=UTC
+ExecReload=/bin/kill -USR1 $MAINPID
+ExecStop=/bin/kill -TERM $MAINPID
SendSIGKILL=no
-ExecReload=/usr/bin/kill -USR1 $MAINPID
-ExecStop=/usr/bin/kill -TERM $MAINPID
SuccessExitStatus=0 2 3
[Install]
diff --git a/i2prouter.sh b/i2prouter.sh
index 1af0a35b4cbb..f4e7ac9a411d 100755
--- a/i2prouter.sh
+++ b/i2prouter.sh
@@ -1,12 +1,11 @@
-#!/bin/bash
+#!/usr/bin/env 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
+PIDFILE="/run/i2p/i2p.pid"
+TIMEOUT=30 #seconds
#-----------------------------------------------------------------------------
fail() {
@@ -20,10 +19,7 @@ debug() {
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
+ #chmod 700 /opt/i2p/.{i2p,tmp}
SCRIPT_PATH="$(cd $(dirname $0) && pwd)/$(basename $0)"
su - "$I2P_USER" -c "${SCRIPT_PATH} $@"
exit $?
@@ -39,7 +35,7 @@ init_vars() {
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\""
+ COMMAND_LINE="\"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"i2prouter\" wrapper.name=\"i2prouter\" TZ=UTC"
}
get_wrapper_pid() {
@@ -77,13 +73,13 @@ _console() {
eval $COMMAND_LINE
[[ $? != 0 ]] && fail "Failed to launch the wrapper!"
else
- echo "I2P Service is already running"
+ echo "I2P Router is already running! (pid: $pid)"
fi
}
_start() {
if [[ ! "$pid" ]]; then
- echo -n "Starting I2P Service"
+ echo -n "Starting I2P Router"
COMMAND_LINE+=" wrapper.daemonize=TRUE"
eval $COMMAND_LINE
[[ $? != 0 ]] && fail "Failed to launch the wrapper!"
@@ -97,20 +93,20 @@ _start() {
[[ $(get_pid) ]] &&
echo " done (pid $pid)" || fail "timeout: Failed to start wrapper!"
else
- echo "I2P Service is already running"
+ echo "I2P Router is already running! (pid: $pid)"
fi
}
_restart() {
[[ "$pid" ]] &&
- kill -USR1 $(get_wrapper_pid) || echo "I2P Service is not running"
+ kill -USR1 $(get_wrapper_pid) || echo "I2P Router is not running"
}
_stop() {
if [[ "$pid" ]]; then
- echo -n "Stopping I2P Service"
+ echo -n "Hard shutdown initiated"
kill -TERM "$pid"
- [[ $? != 0 ]] && fail "Unable to stop I2P Service: kill -TERM $pid"
+ [[ $? != 0 ]] && fail "Unable to stop I2P Router: kill -TERM $pid"
i=0
while [[ "$pid" || $i > $TIMEOUT ]]; do
echo -n "."
@@ -125,25 +121,32 @@ _stop() {
[[ "$1" = 'start' ]] && _start
fi
else
- echo "I2P Service is not running."
+ echo "I2P Router is not running."
fi
}
_graceful() {
if [[ "$pid" ]]; then
- echo "Stopping I2P Service gracefully..."
+ echo -n "Graceful shutdown initiated"
kill -HUP "$pid"
- [[ $? != 0 ]] && fail "Unable to stop I2P Service."
+ [[ $? != 0 ]] && fail "Unable to stop I2P Router."
+ i=0
+ while [[ "$pid" || $i > 660 ]]; do
+ echo -n "."
+ sleep 1
+ [[ ! $(get_pid) ]] && unset pid
+ ((i++))
+ done
+ if [[ "$pid" ]]; then
+ fail "timeout: Took longer than 10m to stop. (pid: $pid)"
+ else
+ echo " done"
+ fi
else
- echo "I2P Service is not running."
+ echo "I2P Router 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..."
@@ -151,14 +154,27 @@ _dump() {
[[ $? != 0 ]] &&
fail "Failed to dump threads" || echo "Thread Dump is available in wrapper.log"
else
- echo "I2P Service is not running."
+ echo "I2P Router is not running."
fi
}
#-----------------------------------------------------------------------------
+[[ "$1" != @(console|start|stop|graceful|restart|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 " dump Request a Java thread dump if running"
+ exit
+}
+
check_user "$@"
-init_vars
check_if_running
+init_vars
case "$1" in
'console') _console
@@ -171,22 +187,6 @@ case "$1" in
;;
'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
index 9eef9af13657..341c956668a7 100755
--- a/router.config
+++ b/router.config
@@ -1,6 +1,5 @@
# 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.udp.addressSources=hidden