Commit 097785df authored by Tails developers's avatar Tails developers

Refactor code checking if I2P is enabled.

parent 8c45b567
......@@ -3,8 +3,11 @@
# I2P isn't started automatically at system boot.
# Instead, it is started with this hook script.
# Import i2p_is_enabled().
. /usr/local/lib/tails-shell-library/i2p.sh
# Don't even try to run this script if I2P is not enabled.
grep -qw "i2p" /proc/cmdline || exit 0
i2p_is_enabled || exit 0
# don't run if interface is 'lo'
[ $1 = "lo" ] && exit 0
......
......@@ -3,6 +3,9 @@
# This script reverses everything done by config/chroot_local-hooks/97_remove_i2p
# when the string "i2p" is added to the boot prompt.
# Import i2p_is_enabled().
. /usr/local/lib/tails-shell-library/i2p.sh
SRC="/usr/share/tails/i2p-disabled"
Install_I2P(){
......@@ -18,7 +21,7 @@ Add_Sudo_Config(){
chmod 0440 /etc/sudoers.d/zzz_i2pbrowser
}
if grep -qw "i2p" /proc/cmdline && [ -d "$SRC" ]; then
if i2p_is_enabled && [ -d "$SRC" ]; then
Install_I2P
Add_Sudo_Config
fi
......@@ -3,6 +3,10 @@
I2P_CONFIG="/var/lib/i2p/i2p-config"
I2P_TUNNEL_CONFIG="${I2P_CONFIG}/i2ptunnel.config"
i2p_is_enabled() {
grep -qw "i2p" /proc/cmdline
}
i2p_eep_proxy_address() {
# We retrieve the host and port number from the I2P profile This
# shouldn't be anywhere other than 127.0.0.1:4444 but in case
......
......@@ -15,7 +15,7 @@ set -e
# and run_chroot_browser().
. /usr/local/lib/tails-shell-library/chroot-browser.sh
# Import i2p_router_console_is_ready().
# Import i2p_router_console_is_ready() and i2p_is_enabled().
. /usr/local/lib/tails-shell-library/i2p.sh
error () {
......@@ -74,7 +74,7 @@ show_shutdown_notification () {
# Main script:
# This isn't very useful without I2P...
grep -qw "i2p" /proc/cmdline || exit 0
i2p_is_enabled || exit 0
CMD=$(basename "${0}")
LOCK="/var/lock/${CMD}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment