-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint-reseed.sh
executable file
·37 lines (30 loc) · 1.05 KB
/
entrypoint-reseed.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
#
# Author/Maintainer: konrad@diva.exchange
#
# -e Exit immediately if a simple command exits with a non-zero status
set -e
# start i2pd - in the context of the container this points to the top-level entrypoint, which belongs to i2pd
BANDWIDTH=${BANDWIDTH:-P}
BANDWIDTH=${BANDWIDTH} /entrypoint.sh >/dev/null 2>&1 &
IP_CONTAINER=`ip route get 1 | awk '{ print $NF; exit; }'`
# mandatory signer id, like something@somedomain.tld
SIGNER=${SIGNER:?Pass signer ID, like something@somedomain.tld}
# create the keys, if they don't exist
[ -f /home/i2preseed/${SIGNER}.lock ] || /home/i2preseed/bin/i2p-tools keygen --signer=${SIGNER}
touch /home/i2preseed/${SIGNER}.lock
# wait for some minutes to have the router integrated
sleep 600
while ( true )
do
/home/i2preseed/bin/i2p-tools reseed \
--signer=${SIGNER} \
--netdb=/home/i2pd/data/netDb \
--port=8443 \
--ip=${IP_CONTAINER} \
--trustProxy &
# sleep for 48 - 60 hours
sleep $(( (RANDOM*60*60*12/32768) + (60*60*48) ))
# terminate i2p-tools, to restart it again
pkill i2p-tools
done