4 # Do not "set -u", else importing gettext.sh dies
5 # with "ZSH_VERSION: parameter not set".
12 PROFILE
="${HOME}/.tor-browser/profile.default"
14 # Import exec_firefox() and configure_best_tor_browser_locale()
15 .
/usr
/local
/lib
/tails-shell-library
/tor-browser.sh
17 ask_for_confirmation
() {
18 local dialog_title
="`gettext \"Tor is not ready\"`"
19 local dialog_text
="`gettext \"Tor is not ready. Start Tor Browser anyway?\"`"
20 local dialog_start
="`gettext \"Start Tor Browser\"`"
21 local dialog_cancel
="`gettext \"Cancel\"`"
22 # zenity can't set the default button to cancel, so we switch the
23 # labels and interpret the return value as its negation.
25 --title "$dialog_title" --text="$dialog_text" \
26 --cancel-label "$dialog_start" --ok-label "$dialog_cancel"
29 tor_has_bootstrapped
() {
30 sudo
-n -u debian-tor
/usr
/local
/sbin
/tor-has-bootstrapped
33 # Workaround bug #8036 by copying any localized search plugins into
35 enable_localized_searchplugins
() {
37 locale
=$
(cat "${PROFILE}"/preferences
/0000locale.js | \
38 sed 's@^pref("general\.useragent\.locale", "\([^"]*\)");$@\1@')
39 if [ "${locale}" = en-US
] ||
[ -e "${PROFILE}"/searchplugins
]; then
42 # Fallback to a similar locale if there is no exact match
43 plugin
="$(ls -1 "${TBB_INSTALL}"/distribution/searchplugins/locale/ | grep -m1 "^
${locale}\
(-[A-Z
]\
+\
)\?$
" || true)"
44 if [ -n "${plugin}" ]; then
45 mkdir
-p "${PROFILE}"/searchplugins
46 # The plugins do not load if they are symlinks
47 cp --dereference "${TBB_INSTALL}"/distribution/searchplugins/locale/"${plugin}"/* "${PROFILE}"/searchplugins
52 if [ ! -d "${PROFILE}" ]; then
53 /usr
/local
/bin
/generate-tor-browser-profile
56 configure_best_tor_browser_locale
"${PROFILE}"
58 # Workaround bug #8036
59 enable_localized_searchplugins
61 if [ -z "$XAUTHORITY" ]; then
62 XAUTHORITY
=~
/.Xauthority
68 exec_firefox
-allow-remote --class "Tor Browser" -profile "${PROFILE}" "${@}"
72 if tor_has_bootstrapped || ask_for_confirmation
; then
73 # Torbutton 1.5.1+ uses those environment variables
74 export TOR_SOCKS_HOST
='127.0.0.1'
75 export TOR_SOCKS_PORT
='9150'