thunderbird 2.18 KB
Newer Older
kytv's avatar
kytv committed
1 2 3
#!/bin/sh

set -e
4
set -u
anonym's avatar
anonym committed
5
set -x
6

7 8 9
# Import set_mozilla_pref()
. /usr/local/lib/tails-shell-library/tor-browser.sh

10 11
THUNDERBIRD_CONFIG_DIR="${HOME}/.thunderbird"
PROFILE="${THUNDERBIRD_CONFIG_DIR}/profile.default"
kytv's avatar
kytv committed
12

13 14 15 16 17 18 19 20 21 22 23
configure_locale() {
    # Thunderbird will set the locale based on the environment when
    # this pref is empty, but will then save the result to this pref
    # disabling this "guess" for the next time. We want Thunderbird to
    # always match the locale of the Tails session.
    set_mozilla_pref "${PROFILE}/prefs.js"   \
                     "intl.locale.requested" \
                     '""'                    \
                     user_pref
}

24 25 26 27 28 29 30 31
disable_autocrypt() {
    # Disable Autocrypt since it is not safe (#15923).
    set_mozilla_pref "${PROFILE}/prefs.js"                 \
                     "mail.server.default.enableAutocrypt" \
                     "false"                               \
                     user_pref
}

32 33 34
reconfigure_profile() {
    mkdir -p "${PROFILE}"
    configure_locale
35
    disable_autocrypt
36 37 38 39 40 41 42 43 44

    # Suppress Enigmail's configuration wizard by pretending that the current
    # version was already configured. Only do this on first run though:
    # once we've done this we let Enigmail manage this setting itself
    # so it can run any migration code it wants to on upgrades.
    if thunderbird_profile_is_new; then
	initialize_enigmail_configured_version
    fi
}
45

46
thunderbird_profile_is_new() {
47
   [ ! -f "${PROFILE}/extensions.json" ]
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
}

initialize_enigmail_configured_version() {
    mkdir -p "${PROFILE}/preferences"
    version="$(dpkg-query --show \
                          --showformat='${source:Upstream-Version}' \
                          enigmail | sed -E 's,\+.*$,,')"
    # Set the value in prefs.js so that Enigmail can manage it itself
    # once we've done this once.
    set_mozilla_pref "${PROFILE}/prefs.js" \
                     "extensions.enigmail.configuredVersion" \
                     "\"${version}\"" \
		     'user_pref'
}

63
start_thunderbird() {
64
    export GNOME_ACCESSIBILITY=1
kytv's avatar
kytv committed
65
    unset SESSION_MANAGER
66
    reconfigure_profile
67
    exec /usr/bin/thunderbird --class "Thunderbird" -profile "${PROFILE}" "${@}"
kytv's avatar
kytv committed
68 69
}

70
start_thunderbird "${@}"