60-tor-ready.sh 1.24 KB
Newer Older
1 2 3
#! /bin/sh

# Run only when the interface is not "lo":
4
if [ -z "$1" ] || [ "$1" = "lo" ]; then
5 6 7 8
   exit 0
fi

# Run whenever an interface gets "up", not otherwise:
9
if [ "$2" != "up" ]; then
10 11 12
   exit 0
fi

segfault's avatar
segfault committed
13 14 15
# Import tor_has_bootstrapped()
. /usr/local/lib/tails-shell-library/systemd.sh

16 17 18 19
# Get LANG
. /etc/default/locale
export LANG

20 21 22 23 24
# Initialize gettext support
. gettext.sh
TEXTDOMAIN="tails"
export TEXTDOMAIN

segfault's avatar
segfault committed
25
while ! tor_has_bootstrapped; do
26
   sleep 1
27 28
done

29 30 31 32
# We now know that whatever Tor settings we are using works, so if Tor
# Launcher is still running, we can just kill it and make sure it
# won't start next network reconnect. A reason for this happening is
# if Tor was restarted by tordate, e.g. if the clock was to incorrect.
33 34 35
TOR_LAUNCHER_PROCESS_REGEX="firefox-unconfined -?-app.*tor-launcher-standalone"
if pgrep -f "${TOR_LAUNCHER_PROCESS_REGEX}"; then
   pkill -f "${TOR_LAUNCHER_PROCESS_REGEX}"
36
   pref=/home/tor-launcher/.tor-launcher/profile.default/prefs.js
Tails developers's avatar
Tails developers committed
37
   sed -i '/^user_pref("extensions\.torlauncher\.prompt_at_startup"/d' "${pref}"
38
   echo 'user_pref("extensions.torlauncher.prompt_at_startup", false);' >> "${pref}"
39 40
fi

41
/usr/local/sbin/tails-notify-user \
Tails developers's avatar
Tails developers committed
42 43
   "`gettext \"Tor is ready\"`" \
   "`gettext \"You can now access the Internet.\"`"