summaryrefslogtreecommitdiffstats
path: root/config/chroot_local-includes/usr/local/bin/thunderbird
blob: a362001aa48fe43c6da5fe625d1e7f6e5d071be9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh

set -e
set -u
set -x

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

THUNDERBIRD_CONFIG_DIR="${HOME}/.thunderbird"
PROFILE="${THUNDERBIRD_CONFIG_DIR}/profile.default"

thunderbird_config_is_persistent() {
    [ "$(findmnt --noheadings --output SOURCE --target "${THUNDERBIRD_CONFIG_DIR}")" = "/dev/mapper/TailsData_unlocked[/thunderbird]" ]
}

configure_default_incoming_protocol() {
    # For extensions.torbirdy.defaultprotocol, POP = 0, IMAP = 1
    local default_protocol
    if thunderbird_config_is_persistent; then
        default_protocol=0
    else
        default_protocol=1
    fi
    set_mozilla_pref "${PROFILE}/preferences/0000tails.js" \
                     "extensions.torbirdy.defaultprotocol" \
                     "${default_protocol}"
}

start_thunderbird() {
   # Give Thunderbird its own temp directory, similar rationale to a1fd1f0f & #9558.
    TMPDIR="${PROFILE}/tmp"
    mkdir --mode=0700 -p "$TMPDIR"
    export TMPDIR

    unset SESSION_MANAGER

    configure_default_incoming_protocol

    # Apply only the relevant parts of Debian's Icedove → Thunderbird
    # migration procedure.
    TB_PROFILE_FOLDER="${THUNDERBIRD_CONFIG_DIR}"
    if [ ! -f "${TB_PROFILE_FOLDER}/.migrated" ]; then
        # Debian's migration helpers are not designed to have set -e
        # or -u enabled.
        set +e
        set +u
        . /usr/lib/thunderbird/thunderbird-wrapper-helper.sh
        do_fix_mimetypes_rdf
        do_create_migrated_mark_file
        set -e
        set -u
    fi

    exec /usr/bin/thunderbird --class "Thunderbird" -profile "${PROFILE}" "${@}"
}

start_thunderbird "${@}"