Merge remote-tracking branch 'flapflap/de-network_configuration'
[tails-test.git] / config / chroot_local-includes / usr / local / sbin / tails-i2p
bloba70739c18a3b151cc4570e54530344562fe69965
1 #!/bin/sh
3 set -e
5 # Get LANG
6 . /etc/default/locale
7 export LANG
9 # Initialize gettext support
10 . gettext.sh
11 TEXTDOMAIN="tails"
12 export TEXTDOMAIN
14 # Must be set after gettext initialization
15 set -u
17 # Import wait_until()
18 . /usr/local/lib/tails-shell-library/common.sh
19 # Import i2p_has_bootstrapped() and i2p_router_console_is_ready()
20 . /usr/local/lib/tails-shell-library/i2p.sh
22 I2P_STARTUP_TIMEOUT=60
23 # We'll give up once 6 minutes have passed. Even with ridiculously
24 # subpar network conditions I've not seen bootstrapping take longer
25 # than this.
26 I2P_BOOTSTRAP_TIMEOUT=360
28 startup_failure() {
29 /usr/local/sbin/tails-notify-user \
30 "`gettext \"I2P failed to start\"`" \
31 "`gettext \"Something went wrong when I2P was starting. Check the logs in /var/log/i2p for more information.\"`"
32 service i2p stop # clean up, just in case
33 exit 1
36 wait_until_i2p_router_console_is_ready() {
37 wait_until ${I2P_STARTUP_TIMEOUT} i2p_router_console_is_ready
40 notify_router_console_success() {
41 /usr/local/sbin/tails-notify-user \
42 "`gettext \"I2P's router console is ready\"`" \
43 "`gettext \"You can now access I2P's router console on http://127.0.0.1:7657.\"`"
46 bootstrap_failure() {
47 /usr/local/sbin/tails-notify-user \
48 "`gettext \"I2P is not ready\"`" \
49 "`gettext \"Eepsite tunnel not built within six minutes. Check the router console at http://127.0.0.1:7657/logs or the logs in /var/log/i2p for more information. Reconnect to the network to try again.\"`"
50 exit 1
53 wait_until_i2p_has_bootstrapped() {
54 wait_until ${I2P_BOOTSTRAP_TIMEOUT} i2p_has_bootstrapped
57 notify_bootstrap_success() {
58 /usr/local/sbin/tails-notify-user \
59 "`gettext \"I2P is ready\"`" \
60 "`gettext \"You can now access services on I2P.\"`"
63 case "${1}" in
64 start|restart)
65 service i2p restart
66 wait_until_i2p_router_console_is_ready || startup_failure
67 notify_router_console_success
68 wait_until_i2p_has_bootstrapped || bootstrap_failure
69 notify_bootstrap_success
71 stop)
72 exec service i2p stop
75 echo "invalid argument '${1}'" >&2
76 exit 1
78 esac