e75128
#!/bin/bash
e75128
#
e75128
# Startup script for the fedora.us Thunderbird RPM
e75128
# (based on the Mozilla RPM launch script)
e75128
#
e75128
e75128
##
e75128
## Variables
e75128
##
e75128
MOZ_ARCH=$(uname -m)
e75128
case $MOZ_ARCH in
e75128
        x86_64 | s390x | sparc64 )
e75128
                MOZ_LIB_DIR="/usr/lib64"
e75128
                SECONDARY_LIB_DIR="/usr/lib"
e75128
                ;;
e75128
        * )
e75128
                MOZ_LIB_DIR="/usr/lib"
e75128
                SECONDARY_LIB_DIR="/usr/lib64"
e75128
                ;;
e75128
esac
e75128
e75128
if [ ! -x $MOZ_LIB_DIR/thunderbird/thunderbird ]; then
e75128
    if [ ! -x $SECONDARY_LIB_DIR/thunderbird/thunderbird ]; then
e75128
        echo "Error: $MOZ_LIB_DIR/thunderbird/thunderbird not found"
e75128
        if [ -d $SECONDARY_LIB_DIR ]; then
e75128
            echo "       $SECONDARY_LIB_DIR/thunderbird/thunderbird not found"
e75128
        fi
e75128
        exit 1
e75128
    fi
e75128
    MOZ_LIB_DIR="$SECONDARY_LIB_DIR"
e75128
fi
e75128
e75128
MOZ_DIST_BIN="$MOZ_LIB_DIR/thunderbird"
e75128
MOZ_PROGRAM="$MOZ_DIST_BIN/thunderbird"
e75128
MOZ_LANGPACKS_DIR="$MOZ_DIST_BIN/langpacks"
e75128
MOZ_EXTENSIONS_PROFILE_DIR="$HOME/.mozilla/extensions/{3550f703-e582-4d05-9a08-453d09bdfdc6}"
e75128
e75128
##
e75128
## Set MOZ_ENABLE_PANGO is no longer used because Pango is enabled by default
e75128
## you may use MOZ_DISABLE_PANGO=1 to force disabling of pango
e75128
##
e75128
#MOZ_DISABLE_PANGO=1
e75128
#export MOZ_DISABLE_PANGO
e75128
e75128
##
e75128
## Set MOZ_APP_LAUNCHER for gnome-session
e75128
##
e75128
export MOZ_APP_LAUNCHER="/usr/bin/thunderbird"
e75128
e75128
##
e75128
## Disable the GNOME crash dialog, Moz has it's own
e75128
## 
e75128
GNOME_DISABLE_CRASH_DIALOG=1
e75128
export GNOME_DISABLE_CRASH_DIALOG
e75128
e75128
##
e02199
## Disable the SLICE allocator (rhbz#1014858)
e02199
##
e02199
export G_SLICE=always-malloc
e02199
e02199
##
e75128
## To disable the use of Firefox localization, set MOZ_DISABLE_LANGPACKS=1
e75128
## in your environment before launching Firefox.
e75128
##
e75128
#
e75128
# MOZ_DISABLE_LANGPACKS=1
e75128
# export MOZ_DISABLE_LANGPACKS
e75128
#
e75128
e75128
##
e75128
## Automatically installed langpacks are tracked by .fedora-langpack-install
e75128
## config file.
e75128
##
e75128
FEDORA_LANGPACK_CONFIG="$MOZ_EXTENSIONS_PROFILE_DIR/.fedora-langpack-install"
e75128
e75128
# MOZ_DISABLE_LANGPACKS disables language packs completelly
e75128
MOZILLA_DOWN=0
e75128
if ! [ $MOZ_DISABLE_LANGPACKS ] || [ $MOZ_DISABLE_LANGPACKS -eq 0 ]; then
e02199
    pidof thunderbird > /dev/null 2>&1
e02199
    MOZILLA_DOWN=$?
e75128
fi
e75128
e75128
# Modify language pack configuration only when thunderbird is not running 
e75128
# and language packs are not disabled
e75128
if [ $MOZILLA_DOWN -ne 0 ]; then
e75128
e75128
    # Clear already installed langpacks
e75128
    mkdir -p $MOZ_EXTENSIONS_PROFILE_DIR
e75128
    if [ -f $FEDORA_LANGPACK_CONFIG ]; then
e75128
        rm `cat $FEDORA_LANGPACK_CONFIG` > /dev/null 2>&1
e75128
        rm $FEDORA_LANGPACK_CONFIG > /dev/null 2>&1
e75128
        # remove all empty langpacks dirs while they block installation of langpacks
e75128
        rmdir $MOZ_EXTENSIONS_PROFILE_DIR/lang* > /dev/null 2>&1
e75128
    fi
e75128
e75128
    # Get locale from system
e75128
    CURRENT_LOCALE=$LC_ALL
e75128
    CURRENT_LOCALE=${CURRENT_LOCALE:-$LC_MESSAGES}
e75128
    CURRENT_LOCALE=${CURRENT_LOCALE:-$LANG}
e75128
    
e75128
    # Try without a local variant first, then with a local variant
e75128
    # So that pt-BR doesn't try to use pt for example
e75128
    SHORTMOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*||g"`
e75128
    MOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*|-\1|g"`
e75128
e75128
    function create_langpack_link() {
e75128
        local language=$*
e75128
        local langpack=langpack-${language}@thunderbird.mozilla.org.xpi
e75128
        if [ -f $MOZ_LANGPACKS_DIR/$langpack ]; then
e75128
            rm -rf $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
e75128
            ln -s $MOZ_LANGPACKS_DIR/$langpack \
e75128
                  $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
e75128
            echo $MOZ_EXTENSIONS_PROFILE_DIR/$langpack > $FEDORA_LANGPACK_CONFIG
e75128
            return 0
e75128
        fi
e75128
        return 1
e75128
    }
e75128
e75128
    create_langpack_link $SHORTMOZLOCALE || create_langpack_link $MOZLOCALE || true
e75128
fi
e75128
e75128
# BEAST fix (rhbz#1005611)
e75128
NSS_SSL_CBC_RANDOM_IV=${NSS_SSL_CBC_RANDOM_IV-1}
e75128
export NSS_SSL_CBC_RANDOM_IV
e75128
ae11a9
# Linux version specific environment variables
ae11a9
%RHEL_ENV_VARS%
ae11a9
ae11a9
# Make sure at-spi-bus is running
ae11a9
if ! dbus-send --session            \
ae11a9
     --dest=org.freedesktop.DBus    \
ae11a9
     --type=method_call             \
ae11a9
     --print-reply                  \
ae11a9
     /org/freedesktop/DBus          \
ae11a9
     org.freedesktop.DBus.ListNames \
ae11a9
     | grep org.a11y.Bus > /dev/null; then
ae11a9
    if [ -f "$MOZ_LIB_DIR/firefox/bundled/libexec/at-spi-bus-launcher" ]; then
ae11a9
        echo "Starting a11y dbus service..."
ae11a9
        $MOZ_LIB_DIR/firefox/bundled/libexec/at-spi-bus-launcher &
ae11a9
    else
ae11a9
        echo "Running without a11y support!"
ae11a9
    fi
ae11a9
fi
ae11a9
ae11a9
exec $MOZ_PROGRAM "$@"